CI: Add docker support for tst_qiodevice test

Currently test relies solely for external test server. This makes it
not possible to run test successfully with environment where docker is
used.

Pick-to: 6.2 6.3
Change-Id: Idf7e99c19ab630065b651f2f6d957311f45f0db7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
Pasi Petäjäjärvi 2022-02-23 16:44:05 +02:00
parent f00e332d39
commit fe93a5f42d
2 changed files with 14 additions and 3 deletions
tests/auto/corelib/io/qiodevice

View File

@ -13,4 +13,5 @@ qt_internal_add_test(tst_qiodevice
PUBLIC_LIBRARIES
Qt::Network
TESTDATA ${test_data}
QT_TEST_SERVER_LIST "apache2" "cyrus"
)

View File

@ -104,15 +104,20 @@ void tst_QIODevice::getSetCheck()
//----------------------------------------------------------------------------------
void tst_QIODevice::constructing_QTcpSocket()
{
#ifdef QT_TEST_SERVER
if (!QtNetworkSettings::verifyConnection(QtNetworkSettings::imapServerName(), 143))
QSKIP("No network test server available");
#else
if (!QtNetworkSettings::verifyTestNetworkSettings())
QSKIP("No network test server available");
#endif
QTcpSocket socket;
QIODevice *device = &socket;
QVERIFY(!device->isOpen());
socket.connectToHost(QtNetworkSettings::serverName(), 143);
socket.connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket.waitForConnected(30000));
QVERIFY(device->isOpen());
QCOMPARE(device->readChannelCount(), 1);
@ -130,7 +135,7 @@ void tst_QIODevice::constructing_QTcpSocket()
socket.close();
QCOMPARE(socket.readChannelCount(), 0);
QCOMPARE(socket.writeChannelCount(), 0);
socket.connectToHost(QtNetworkSettings::serverName(), 143);
socket.connectToHost(QtNetworkSettings::imapServerName(), 143);
QVERIFY(socket.waitForConnected(30000));
QVERIFY(device->isOpen());
@ -270,9 +275,14 @@ void tst_QIODevice::unget()
result = QByteArray("ZXCV");
lineResult = "ZXCV";
} else {
#ifdef QT_TEST_SERVER
if (!QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80))
QSKIP("No network test server available");
#else
if (!QtNetworkSettings::verifyTestNetworkSettings())
QSKIP("No network test server available");
socket.connectToHost(QtNetworkSettings::serverName(), 80);
#endif
socket.connectToHost(QtNetworkSettings::httpServerName(), 80);
socket.write("GET / HTTP/1.0\r\n\r\n");
QVERIFY(socket.waitForReadyRead());
dev = &socket;