diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-06-07 17:14:01 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-06-09 13:42:24 +0000 |
commit | f9c5f0068aa2ffc794586b836d9b00396464b8b0 (patch) | |
tree | 05121fd6c63be908590871994f9561662ddb6e98 /tests | |
parent | 7ee240baa8353f56b9b8de790b95d35cfe489c35 (diff) |
Stabilize QFile::unixPipe/socketPair tests
We observe failures in CI on QNX because the measured timeout is ~995ms
rather than the expected 1000ms. Start the timer before the thread
starts to guarantee that at least as much time elapses as the thread
waits before writing the second byte to the pipe.
Otherwise, the thread might be sleeping already when the timer starts,
and then we can't rely on any measurements.
Change-Id: I6072569a987f5e952b0953e0e394a223f891fd25
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
(cherry picked from commit 30e5ff3ff223d665fbed3baf2d08ad3fcf2b8455)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qfile/tst_qfile.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index a7fbef2485..6d8a7368fa 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -2614,6 +2614,9 @@ static void unixPipe_helper(int pipes[2]) c = 2; qt_safe_write(fd, &c, 1); })); + + QElapsedTimer timer; + timer.start(); thr->start(); // synchronize with the thread having started @@ -2622,8 +2625,6 @@ static void unixPipe_helper(int pipes[2]) QCOMPARE(c, '\1'); QFETCH(bool, useStdio); - QElapsedTimer timer; - timer.start(); QFile f; if (useStdio) { FILE *fh = fdopen(pipes[0], "rb"); @@ -2636,8 +2637,8 @@ static void unixPipe_helper(int pipes[2]) c = 0; QCOMPARE(f.read(&c, 1), 1); QCOMPARE(c, '\2'); - int elapsed = timer.elapsed(); - QVERIFY2(elapsed >= Timeout, QByteArray::number(elapsed)); + const int elapsed = timer.elapsed(); + QCOMPARE_GE(elapsed, Timeout); thr->wait(); } |