diff options
author | Liang Qi <liang.qi@qt.io> | 2016-04-26 09:31:39 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-04-27 06:07:16 +0000 |
commit | 2e9fc0d3f06c41f0a3d6c68d321ea56a761b25bf (patch) | |
tree | 6c53e1069860f5f43672471b809ce17008f99bb1 /src/testlib | |
parent | 7565b4ec9565cb8e52c113c693a0865da86eaeed (diff) |
testlib: added env QTEST_FUNCTION_TIMEOUT for single test function timeout
This is a regression with 5.5, it causes some customer test functions
crash. d3d10cf2 introduced the 5 minutes timeout. The timeout could be
changed after this.
Task-number: QTBUG-52402
Change-Id: I8940bbde5004b4d888732b551274f079ddf20563
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/qtestcase.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 4643013371..6e30a5d429 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1455,6 +1455,7 @@ namespace QTest static int keyDelay = -1; static int mouseDelay = -1; static int eventDelay = -1; + static int timeout = -1; static bool noCrashHandler = false; /*! \internal @@ -1506,6 +1507,18 @@ int Q_TESTLIB_EXPORT defaultKeyDelay() return keyDelay; } +static int defaultTimeout() +{ + if (timeout == -1) { + bool ok = false; + timeout = qEnvironmentVariableIntValue("QTEST_FUNCTION_TIMEOUT", &ok); + + if (!ok || timeout <= 0) + timeout = 5*60*1000; + } + return timeout; +} + static bool isValidSlot(const QMetaMethod &sl) { if (sl.access() != QMetaMethod::Private || sl.parameterCount() != 0 @@ -2119,7 +2132,7 @@ public: void beginTest() { QMutexLocker locker(&mutex); - timeout.store(5*60*1000); + timeout.store(defaultTimeout()); waitCondition.wakeAll(); } |