tst_QNetworkInterface: Update network test server handling

Adds docker support and makes it no longer skip the whole test
if there is no docker or network server.

Pick-to: 6.2 6.3
Change-Id: Ie98496df338a804d5c9842cce372e3410fdf9990
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Pasi Petäjäjärvi 2022-03-15 11:35:24 +02:00 committed by Mårten Nordheim
parent 82188607e3
commit 8e08286d45
2 changed files with 10 additions and 3 deletions

View File

@ -9,4 +9,5 @@ qt_internal_add_test(tst_qnetworkinterface
tst_qnetworkinterface.cpp
PUBLIC_LIBRARIES
Qt::Network
QT_TEST_SERVER_LIST "apache2"
)

View File

@ -60,6 +60,8 @@ private slots:
void interfaceFromXXX_data();
void interfaceFromXXX();
void copyInvalidInterface();
private:
bool hasNetworkServer = false;
};
tst_QNetworkInterface::tst_QNetworkInterface()
@ -84,8 +86,11 @@ bool tst_QNetworkInterface::isIPv6Working()
void tst_QNetworkInterface::initTestCase()
{
if (!QtNetworkSettings::verifyTestNetworkSettings())
QSKIP("No network test server available");
#ifdef QT_TEST_SERVER
hasNetworkServer = QtNetworkSettings::verifyConnection(QtNetworkSettings::httpServerName(), 80);
#else
hasNetworkServer = QtNetworkSettings::verifyTestNetworkSettings();
#endif
}
void tst_QNetworkInterface::dump()
@ -195,7 +200,8 @@ void tst_QNetworkInterface::localAddress_data()
if (ipv6)
QTest::newRow("localhost-ipv6") << QHostAddress(QHostAddress::LocalHostIPv6);
QTest::newRow("test-server") << QtNetworkSettings::serverIP();
if (hasNetworkServer)
QTest::newRow("test-server") << QtNetworkSettings::httpServerIp();
QSet<QHostAddress> added;
const QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();