summaryrefslogtreecommitdiffstats
path: root/tests/auto/network
diff options
context:
space:
mode:
authorTimur Pocheptsov <timur.pocheptsov@qt.io>2018-11-07 12:48:29 +0100
committerTimur Pocheptsov <timur.pocheptsov@qt.io>2018-11-07 12:25:12 +0000
commitd786c55b9e03c3cb8444ebeef8d31ca9d84071a0 (patch)
tree642b1502ba84b2fc5dd232c02f9a6ddea779a214 /tests/auto/network
parentedacfd2f0b6f95430b62296853c3ae5b3405b406 (diff)
Make tst_qsslsocket::protocolServerSide() less flaky
By accident, when we erroneously tried testing TlsV1_3 on macOS with SecureTransport (which does not support TLS 1.3) we hit this quite subtle problem: it can happen that a server-side socket is never created but a client (after TCP connection was established) fails in TLS initialization and ... stops the loop preventing SslServer::incomingConnection() from creating its socket. Then we dereference nullptr. Task-number: QTBUG-71638 Change-Id: I8dc5a4c53022a25aafe2c80a6931087517a48441 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/network')
-rw-r--r--tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
index b759aed074..f45a5af5a1 100644
--- a/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
+++ b/tests/auto/network/ssl/qsslsocket/tst_qsslsocket.cpp
@@ -1343,13 +1343,19 @@ void tst_QSslSocket::protocolServerSide()
QAbstractSocket::SocketState expectedState = (works) ? QAbstractSocket::ConnectedState : QAbstractSocket::UnconnectedState;
// Determine whether the client or the server caused the event loop
// to quit due to a socket error, and investigate the culprit.
- if (server.socket->error() != QAbstractSocket::UnknownSocketError) {
+ if (client.error() != QAbstractSocket::UnknownSocketError) {
+ // It can happen that the client, after TCP connection established, before
+ // incomingConnection() slot fired, hits TLS initialization error and stops
+ // the loop, so the server socket is not created yet.
+ if (server.socket)
+ QVERIFY(server.socket->error() == QAbstractSocket::UnknownSocketError);
+
+ QCOMPARE(int(client.state()), int(expectedState));
+ } else if (server.socket->error() != QAbstractSocket::UnknownSocketError) {
QVERIFY(client.error() == QAbstractSocket::UnknownSocketError);
QCOMPARE(int(server.socket->state()), int(expectedState));
- } else if (client.error() != QAbstractSocket::UnknownSocketError) {
- QVERIFY(server.socket->error() == QAbstractSocket::UnknownSocketError);
- QCOMPARE(int(client.state()), int(expectedState));
}
+
QCOMPARE(client.isEncrypted(), works);
}