Remove warnings about sleep times from QTest::qSleep()
The collected data doesn't reveal any obvious correlation between sleep times and test failures but the many warnings are a hassle for anyone reading the test results. Change-Id: I71bd0c90c20c730573693f23f4435e538b635d44 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
f0579fa68e
commit
a17aaed1cd
@ -2863,8 +2863,6 @@ bool QTest::currentTestFailed()
|
||||
void QTest::qSleep(int ms)
|
||||
{
|
||||
QTEST_ASSERT(ms > 0);
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
#if defined(Q_OS_WINRT)
|
||||
WaitForSingleObjectEx(GetCurrentThread(), ms, true);
|
||||
@ -2874,20 +2872,6 @@ void QTest::qSleep(int ms)
|
||||
struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
|
||||
nanosleep(&ts, NULL);
|
||||
#endif
|
||||
// Warn if the elapsed time was more than 50% longer or more than 10% shorter than the
|
||||
// requested time.
|
||||
qint64 requested = 1000000 * (qint64)ms;
|
||||
qint64 diff = timer.nsecsElapsed() - requested;
|
||||
#ifndef Q_OS_WIN
|
||||
const qint64 factor = 2; // more than 50% longer
|
||||
#else
|
||||
const qint64 factor = 1; // Windows: 50% is quite common, warn about 100%
|
||||
#endif
|
||||
if (diff * factor > requested || diff * 10 < -requested) {
|
||||
QTestLog::warn(qPrintable(
|
||||
QString::fromLatin1("QTest::qSleep() should have taken %1ns, but actually took %2ns!")
|
||||
.arg(requested).arg(diff + requested)), __FILE__, __LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
/*! \internal
|
||||
|
Loading…
Reference in New Issue
Block a user