From fe93a5f42d1a20697e82193e73fb35aafd5f8d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pasi=20Pet=C3=A4j=C3=A4j=C3=A4rvi?= Date: Wed, 23 Feb 2022 16:44:05 +0200 Subject: [PATCH] CI: Add docker support for tst_qiodevice test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: MÃ¥rten Nordheim --- tests/auto/corelib/io/qiodevice/CMakeLists.txt | 1 + .../auto/corelib/io/qiodevice/tst_qiodevice.cpp | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/auto/corelib/io/qiodevice/CMakeLists.txt b/tests/auto/corelib/io/qiodevice/CMakeLists.txt index ea799619d3e..ce15e80be5a 100644 --- a/tests/auto/corelib/io/qiodevice/CMakeLists.txt +++ b/tests/auto/corelib/io/qiodevice/CMakeLists.txt @@ -13,4 +13,5 @@ qt_internal_add_test(tst_qiodevice PUBLIC_LIBRARIES Qt::Network TESTDATA ${test_data} + QT_TEST_SERVER_LIST "apache2" "cyrus" ) diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp index 87e46bff09b..f6c230714ad 100644 --- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp +++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp @@ -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;