Network tests: don't try to test against disabled network interfaces

Other parts of tst_qudpsocket.cpp already did this check.

Change-Id: Iee8cbc07c4434ce9b560ffff13ca545a03c9596a
Reviewed-by: Richard J. Moore <rich@kde.org>
This commit is contained in:
Thiago Macieira 2015-03-10 20:36:17 -07:00
parent ba60722b46
commit 97f489e7b9
2 changed files with 8 additions and 5 deletions

View File

@ -864,11 +864,12 @@ void tst_QTcpServer::serverAddress_data()
QTest::newRow("AnyIPv4") << QHostAddress(QHostAddress::AnyIPv4) << QHostAddress(QHostAddress::AnyIPv4); QTest::newRow("AnyIPv4") << QHostAddress(QHostAddress::AnyIPv4) << QHostAddress(QHostAddress::AnyIPv4);
if (QtNetworkSettings::hasIPv6()) if (QtNetworkSettings::hasIPv6())
QTest::newRow("AnyIPv6") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv6); QTest::newRow("AnyIPv6") << QHostAddress(QHostAddress::AnyIPv6) << QHostAddress(QHostAddress::AnyIPv6);
foreach (const QHostAddress& addr, QNetworkInterface::allAddresses()) { foreach (const QNetworkInterface &iface, QNetworkInterface::allInterfaces()) {
if (addr.isInSubnet(QHostAddress::parseSubnet("fe80::/10")) if ((iface.flags() & QNetworkInterface::IsUp) == 0)
|| addr.isInSubnet(QHostAddress::parseSubnet("169.254/16"))) continue;
continue; //cannot bind on link local addresses foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) {
QTest::newRow(qPrintable(addr.toString())) << addr << addr; QTest::newRow(qPrintable(entry.ip().toString())) << entry.ip() << entry.ip();
}
} }
} }

View File

@ -1233,6 +1233,8 @@ void tst_QUdpSocket::setMulticastInterface_data()
QTest::addColumn<QHostAddress>("address"); QTest::addColumn<QHostAddress>("address");
QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
foreach (const QNetworkInterface &iface, interfaces) { foreach (const QNetworkInterface &iface, interfaces) {
if ((iface.flags() & QNetworkInterface::IsUp) == 0)
continue;
foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) { foreach (const QNetworkAddressEntry &entry, iface.addressEntries()) {
QTest::newRow(QString("%1:%2").arg(iface.name()).arg(entry.ip().toString()).toLatin1()) QTest::newRow(QString("%1:%2").arg(iface.name()).arg(entry.ip().toString()).toLatin1())
<< iface << iface