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>
This commit is contained in:
Liang Qi 2016-04-26 09:31:39 +02:00
parent 7565b4ec95
commit 2e9fc0d3f0

View File

@ -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();
}