summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-08-29 11:53:20 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-09-25 05:38:27 +0000
commit9467ebcf15ae908d566d2c8d38f5fddda8e139f4 (patch)
tree7b86e1dcea1d4ec950e62b104883fc2c598be038
parent8656ee950b4f57eae605180fd8328441b3e670b9 (diff)
Autotest: centralize the detection of IPv6 support
I'll need it again in the next commit. Change-Id: I209fcd5dbc2b4e5381cffffd14df65dcee71ca7e Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp24
1 files changed, 12 insertions, 12 deletions
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index e9034deff7..94c355aadc 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -48,6 +48,8 @@ public:
tst_QNetworkInterface();
virtual ~tst_QNetworkInterface();
+ bool isIPv6Working();
+
private slots:
void initTestCase();
void cleanupTestCase();
@@ -76,6 +78,13 @@ tst_QNetworkInterface::~tst_QNetworkInterface()
{
}
+bool tst_QNetworkInterface::isIPv6Working()
+{
+ QUdpSocket socket;
+ socket.connectToHost(QHostAddress::LocalHostIPv6, 1234);
+ return socket.state() == QAbstractSocket::ConnectedState || socket.waitForConnected(100);
+}
+
void tst_QNetworkInterface::initTestCase()
{
if (!QtNetworkSettings::verifyTestNetworkSettings())
@@ -172,19 +181,10 @@ void tst_QNetworkInterface::loopbackIPv4()
void tst_QNetworkInterface::loopbackIPv6()
{
+ if (!isIPv6Working())
+ QSKIP("IPv6 not active on this machine");
QList<QHostAddress> all = QNetworkInterface::allAddresses();
-
- bool loopbackfound = false;
- bool anyIPv6 = false;
- foreach (QHostAddress addr, all)
- if (addr == QHostAddress::LocalHostIPv6) {
- loopbackfound = true;
- anyIPv6 = true;
- break;
- } else if (addr.protocol() == QAbstractSocket::IPv6Protocol)
- anyIPv6 = true;
-
- QVERIFY(!anyIPv6 || loopbackfound);
+ QVERIFY(all.contains(QHostAddress(QHostAddress::LocalHostIPv6)));
}
void tst_QNetworkInterface::localAddress()