summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-02-12 17:50:44 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-02-12 22:16:26 +0100
commit67491e2df5357706dbf88ddaf1f030ff095b4528 (patch)
tree343fc2fc825da3a9db7273d7510cb0bcda415182
parent5e83a2eed2dc42a732bd9154bebe8dcb34cd6bb5 (diff)
Detect double timer during single timeout in registerTimer test, and skip
We observe this happening on macOS in the CI system, and it might happen if a VM doesn't get CPU cycles for long enough time so that two timers time out. Then event processing will process two timer events, and we overwrite the timerIdFromEvent with the second event. Instead, skip the test when this happens. This is an ammendment to 5c520f4b0ad4b539dc0184c764ca9f12c98730d9 Change-Id: Ibc1169b5458c8dce9d4fe9ce715f49c396e17b86 Fixes: QTBUG-71751 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
index 025106a81f..85a2dae3b6 100644
--- a/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
+++ b/tests/auto/corelib/kernel/qeventdispatcher/tst_qeventdispatcher.cpp
@@ -45,8 +45,10 @@ class tst_QEventDispatcher : public QObject
Q_OBJECT
QAbstractEventDispatcher *eventDispatcher;
- int receivedEventType;
- int timerIdFromEvent;
+
+ int receivedEventType = -1;
+ int timerIdFromEvent = -1;
+ bool doubleTimer = false;
protected:
bool event(QEvent *e);
@@ -54,9 +56,7 @@ protected:
public:
inline tst_QEventDispatcher()
: QObject(),
- eventDispatcher(QAbstractEventDispatcher::instance(thread())),
- receivedEventType(-1),
- timerIdFromEvent(-1)
+ eventDispatcher(QAbstractEventDispatcher::instance(thread()))
{ }
private slots:
@@ -75,6 +75,9 @@ bool tst_QEventDispatcher::event(QEvent *e)
switch (receivedEventType = e->type()) {
case QEvent::Timer:
{
+ // sometimes, two timers fire during a single QTRY_xxx wait loop
+ if (timerIdFromEvent != -1)
+ doubleTimer = true;
timerIdFromEvent = static_cast<QTimerEvent *>(e)->timerId();
return true;
}
@@ -220,12 +223,17 @@ void tst_QEventDispatcher::registerTimer()
// process events, waiting for the next event... this should only fire the precise timer
receivedEventType = -1;
timerIdFromEvent = -1;
+ doubleTimer = false;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), PreciseTimerInterval * 2);
+
#ifdef Q_OS_DARWIN
+ if (doubleTimer)
+ QSKIP("Double timer during a single timeout - aborting test as flaky on macOS");
if (timerIdFromEvent != timers.preciseTimerId()
&& elapsedTimer.elapsed() > PreciseTimerInterval * 3)
QSKIP("Ignore flaky test behavior due to VM scheduling on macOS");
#endif
+
QCOMPARE(timerIdFromEvent, timers.preciseTimerId());
// now unregister it and make sure it's gone
timers.unregister(timers.preciseTimerId());
@@ -239,8 +247,12 @@ void tst_QEventDispatcher::registerTimer()
// do the same again for the coarse timer
receivedEventType = -1;
timerIdFromEvent = -1;
+ doubleTimer = false;
QTRY_COMPARE_WITH_TIMEOUT(receivedEventType, int(QEvent::Timer), CoarseTimerInterval * 2);
+
#ifdef Q_OS_DARWIN
+ if (doubleTimer)
+ QSKIP("Double timer during a single timeout - aborting test as flaky on macOS");
if (timerIdFromEvent != timers.coarseTimerId()
&& elapsedTimer.elapsed() > CoarseTimerInterval * 3)
QSKIP("Ignore flaky test behavior due to VM scheduling on macOS");