tst_qsslsocket: fix racy test
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 <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit e79b1dcdf5
)
Reviewed-by: Simo Fält <simo.falt@qt.io>
This commit is contained in:
parent
8c87a1402c
commit
d53b8b77bc
@ -2171,7 +2171,7 @@ protected:
|
|||||||
|
|
||||||
// delayed reading data
|
// delayed reading data
|
||||||
QTest::qSleep(100);
|
QTest::qSleep(100);
|
||||||
if (!socket->waitForReadyRead(2000))
|
if (!socket->waitForReadyRead(2000) && socket->bytesAvailable() == 0)
|
||||||
return; // error
|
return; // error
|
||||||
socket->readAll();
|
socket->readAll();
|
||||||
dataReadSemaphore.release();
|
dataReadSemaphore.release();
|
||||||
@ -2242,7 +2242,7 @@ void tst_QSslSocket::waitForMinusOne()
|
|||||||
socket.write("How are you doing?");
|
socket.write("How are you doing?");
|
||||||
QVERIFY(socket.bytesToWrite() != 0);
|
QVERIFY(socket.bytesToWrite() != 0);
|
||||||
QVERIFY(socket.waitForBytesWritten(-1));
|
QVERIFY(socket.waitForBytesWritten(-1));
|
||||||
QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2000));
|
QVERIFY(server.dataReadSemaphore.tryAcquire(1, 2500));
|
||||||
|
|
||||||
// third verification: it should wait for 100 ms:
|
// third verification: it should wait for 100 ms:
|
||||||
QVERIFY(socket.waitForReadyRead(-1));
|
QVERIFY(socket.waitForReadyRead(-1));
|
||||||
|
Loading…
Reference in New Issue
Block a user