From fc9ae22c88dd085c7c31599037132fc756feeb04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 11 Mar 2019 15:56:51 +0100 Subject: tst_qsslsocket: fix racy test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this threaded setup the server can sometimes have the data before it calls "waitForReadyRead", what happens then is that we fail the wait and as a result the test fails overall. Let's check if we actually got some data after all and then continue if we did. Since both the client and the server currently wait the same amount of time (2s) the max timeout for the client was increased by 0.5s so it has some time to notice that the server got the message. Change-Id: Ib5915958853413047aa5a7574712585bcae28f79 Reviewed-by: Edward Welbourne Reviewed-by: Timur Pocheptsov (cherry picked from commit e79b1dcdf542be3a20d5c21ea163ff857ed875bf) Reviewed-by: Simo Fält (cherry picked from commit d53b8b77bc8de236e148ef2652806015a9a87e2b) Change-Id: I2f6ffb8e0a9b4d591edb6925e48baffcefc14511 Reviewed-by: Timur Pocheptsov --- tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp index b4dc9bed33..66475e55ad 100644 --- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp @@ -2096,7 +2096,7 @@ protected: // delayed reading data QTest::qSleep(100); - if (!socket->waitForReadyRead(2000)) + if (!socket->waitForReadyRead(2000) && socket->bytesAvailable() == 0) return; // error socket->readAll(); dataReadSemaphore.release(); @@ -2167,7 +2167,7 @@ void tst_QSslSocket::waitForMinusOne() socket.write("How are you doing?"); QVERIFY(socket.bytesToWrite() != 0); QVERIFY(socket.waitForBytesWritten(-1)); - QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2000)); + QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2500)); // third verification: it should wait for 100 ms: QVERIFY(socket.waitForReadyRead(-1)); -- cgit v1.2.3