summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-08-08 16:40:29 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-11-07 22:15:35 +0000
commita93437342b9bf60c24a0d339244e8a0b308d4a7f (patch)
treece31739abc29db80bc0d4b42ed83342cfb786409 /tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
parent5193ab97f448ed6897ccceae9ce6bdcda55eeb5a (diff)
QNetworkInterface: add support for extracting address lifetime
[ChangeLog][QtNetwork][QNetworkInterface] Added preferredLifetime() and validityLifetime() to QNetworkAddressEntry that report the remaining lifetime of the address in the network interface. Change-Id: I292b84e2193979446e43344b0727642812cba630 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp')
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index 0a15da71f8..95dbfc749a 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -152,6 +152,12 @@ void tst_QNetworkInterface::dump()
<< " (" << qPrintable(e.netmask().toString()) << ')';
if (!e.broadcast().isNull())
s.nospace() << " broadcast " << qPrintable(e.broadcast().toString());
+ if (e.isLifetimeKnown()) {
+#define printable(l) qPrintable(l.isForever() ? "forever" : QString::fromLatin1("%1ms").arg(l.remainingTime()))
+ s.nospace() << " preferred:" << printable(e.preferredLifetime())
+ << " valid:" << printable(e.validityLifetime());
+#undef printable
+ }
}
}
}
@@ -163,6 +169,7 @@ void tst_QNetworkInterface::consistencyCheck()
QVector<int> interfaceIndexes;
foreach (const QNetworkInterface &iface, ifaces) {
+ QVERIFY(iface.isValid());
QVERIFY2(!interfaceNames.contains(iface.name()),
"duplicate name = " + iface.name().toLocal8Bit());
interfaceNames << iface.name();
@@ -171,6 +178,15 @@ void tst_QNetworkInterface::consistencyCheck()
"duplicate index = " + QByteArray::number(iface.index()));
if (iface.index())
interfaceIndexes << iface.index();
+
+ const QList<QNetworkAddressEntry> addresses = iface.addressEntries();
+ for (auto entry : addresses) {
+ QVERIFY(entry.ip().protocol() != QAbstractSocket::UnknownNetworkLayerProtocol);
+ if (!entry.preferredLifetime().isForever() || !entry.validityLifetime().isForever())
+ QVERIFY(entry.isLifetimeKnown());
+ if (!entry.validityLifetime().isForever())
+ QVERIFY(entry.isTemporary());
+ }
}
}