tst_QTcpSocket::connectToHostError - increase the timeout
As suggested by the message from QTestLib. This, indeed, fixed the sadistic test. Also, make sure resources are not leaked. Pick-to: 5.15 Fixes: QTBUG-87009 Change-Id: Id693a5a562ea5ebacc853e5fc0ab9654ba851e72 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
e5e89d17b3
commit
cd6d53610a
@ -81,6 +81,8 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "private/qhostinfo_p.h"
|
||||
|
||||
#include "../../../network-settings.h"
|
||||
@ -2098,7 +2100,7 @@ void tst_QTcpSocket::connectToHostError_data()
|
||||
|
||||
void tst_QTcpSocket::connectToHostError()
|
||||
{
|
||||
QTcpSocket *socket = newSocket();
|
||||
std::unique_ptr<QTcpSocket> socket(newSocket());
|
||||
|
||||
QAbstractSocket::SocketError error = QAbstractSocket::UnknownSocketError;
|
||||
|
||||
@ -2106,15 +2108,14 @@ void tst_QTcpSocket::connectToHostError()
|
||||
QFETCH(int, port);
|
||||
QFETCH(QAbstractSocket::SocketError, expectedError);
|
||||
|
||||
connect(socket, &QAbstractSocket::errorOccurred, [&](QAbstractSocket::SocketError socketError){
|
||||
connect(socket.get(), &QAbstractSocket::errorOccurred, [&](QAbstractSocket::SocketError socketError){
|
||||
error = socketError;
|
||||
});
|
||||
socket->connectToHost(host, port); // no service running here, one suspects
|
||||
QTRY_COMPARE(socket->state(), QTcpSocket::UnconnectedState);
|
||||
QTRY_COMPARE_WITH_TIMEOUT(socket->state(), QTcpSocket::UnconnectedState, 7000);
|
||||
if (error != expectedError && error == QAbstractSocket::ConnectionRefusedError)
|
||||
QEXPECT_FAIL("unreachable", "CI firewall interfers with this test", Continue);
|
||||
QCOMPARE(error, expectedError);
|
||||
delete socket;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user