From 8da467e9da323bec50ab7d6a6b8a71cc3d9797f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20W=C3=BCrtz?= Date: Fri, 18 May 2018 00:23:24 +0200 Subject: [PATCH] Relax timing constraints when checking timeout in tst_timeout --- tests/auto/qtpromise/qpromise/delay/tst_delay.cpp | 10 +++++++--- tests/auto/qtpromise/qpromise/timeout/tst_timeout.cpp | 8 ++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/auto/qtpromise/qpromise/delay/tst_delay.cpp b/tests/auto/qtpromise/qpromise/delay/tst_delay.cpp index 5a35aec..4b018db 100644 --- a/tests/auto/qtpromise/qpromise/delay/tst_delay.cpp +++ b/tests/auto/qtpromise/qpromise/delay/tst_delay.cpp @@ -34,8 +34,12 @@ void tst_qpromise_delay::fulfilled() QCOMPARE(waitForValue(p, -1), 42); QCOMPARE(p.isFulfilled(), true); - QVERIFY(elapsed >= 1000 * 0.95); // Qt::CoarseTimer (default) Coarse timers try to - QVERIFY(elapsed <= 1000 * 1.05); // keep accuracy within 5% of the desired interval. + + // Qt::CoarseTimer (default) Coarse timers try to + // keep accuracy within 5% of the desired interval. + // Require accuracy within 6% for passing the test. + QVERIFY(elapsed >= 1000 * 0.94); + QVERIFY(elapsed <= 1000 * 1.06); } void tst_qpromise_delay::rejected() @@ -51,5 +55,5 @@ void tst_qpromise_delay::rejected() QCOMPARE(waitForError(p, QString()), QString("foo")); QCOMPARE(p.isRejected(), true); - QVERIFY(elapsed < 5); + QVERIFY(elapsed <= 10); } diff --git a/tests/auto/qtpromise/qpromise/timeout/tst_timeout.cpp b/tests/auto/qtpromise/qpromise/timeout/tst_timeout.cpp index bf43c61..fd40348 100644 --- a/tests/auto/qtpromise/qpromise/timeout/tst_timeout.cpp +++ b/tests/auto/qtpromise/qpromise/timeout/tst_timeout.cpp @@ -87,6 +87,10 @@ void tst_qpromise_timeout::timeout() QCOMPARE(waitForValue(p, -1), -1); QCOMPARE(p.isRejected(), true); QCOMPARE(failed, true); - QVERIFY(elapsed >= 2000 * 0.95); // Qt::CoarseTimer (default) Coarse timers try to - QVERIFY(elapsed <= 2000 * 1.05); // keep accuracy within 5% of the desired interval. + + // Qt::CoarseTimer (default) Coarse timers try to + // keep accuracy within 5% of the desired interval. + // Require accuracy within 6% for passing the test. + QVERIFY(elapsed >= 2000 * 0.94); + QVERIFY(elapsed <= 2000 * 1.06); }