summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-08-26 08:37:54 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-08-29 07:20:49 -0700
commit2e51fbf89a748ad3550e786f1bdbf623169550d2 (patch)
tree9cf19806bfd53323b1ed22be8ecc05984c781cfb
parent695948fad028f97521135ecb3478f2798ae6700f (diff)
tst_QNetworkInterface: enable IPv6 detection for Windows
This was disabled in d0d1d7403377363a101d4f1781d06a9b44787d0a, I guess accidentally, by a too-wide conditional. The change the same commit applied to QtNetworkSettings didn't make the same mistake. I am also opportunistically updating the conditional to QT_CONFIG (I missed this in 9d4579c1cd0aae5f75c8702826b5d874a6aae83e) and adding the Linux-specific check, as the AF_NETLINK implementation does not rely on getifaddrs() or if_nametoindex(). Drive-by fix indentation. Pick-to: 6.6 Change-Id: Ifa1111900d6945ea8e05fffd177ef8fcb11b4e1e Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/CMakeLists.txt2
-rw-r--r--tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp17
2 files changed, 10 insertions, 9 deletions
diff --git a/tests/auto/network/kernel/qnetworkinterface/CMakeLists.txt b/tests/auto/network/kernel/qnetworkinterface/CMakeLists.txt
index 3efec91e96..3e5dab63e0 100644
--- a/tests/auto/network/kernel/qnetworkinterface/CMakeLists.txt
+++ b/tests/auto/network/kernel/qnetworkinterface/CMakeLists.txt
@@ -15,6 +15,6 @@ qt_internal_add_test(tst_qnetworkinterface
SOURCES
tst_qnetworkinterface.cpp
LIBRARIES
- Qt::Network
+ Qt::NetworkPrivate
QT_TEST_SERVER_LIST "apache2"
)
diff --git a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
index 9f33cce509..b57a83f5df 100644
--- a/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
+++ b/tests/auto/network/kernel/qnetworkinterface/tst_qnetworkinterface.cpp
@@ -11,6 +11,8 @@
#include <qudpsocket.h>
#include "../../../network-settings.h"
+#include <private/qtnetwork-config_p.h>
+
Q_DECLARE_METATYPE(QHostAddress)
class tst_QNetworkInterface : public QObject
@@ -48,14 +50,13 @@ tst_QNetworkInterface::~tst_QNetworkInterface()
bool tst_QNetworkInterface::isIPv6Working()
{
- // Version without following cannot get IPV6 information
- #if !defined(QT_NO_GETIFADDRS) && !defined(QT_NO_IPV6IFNAME)
- QUdpSocket socket;
- socket.connectToHost(QHostAddress::LocalHostIPv6, 1234);
- return socket.state() == QAbstractSocket::ConnectedState || socket.waitForConnected(100);
- #else
- return false;
- #endif
+ // QNetworkInterface may be unable to detect IPv6 addresses even if they
+ // are there, due to limitations of the implementation.
+ if (QOperatingSystemVersion::currentType() == QOperatingSystemVersion::Windows ||
+ QT_CONFIG(linux_netlink) || (QT_CONFIG(getifaddrs) && QT_CONFIG(ipv6ifname))) {
+ return QtNetworkSettings::hasIPv6();
+ }
+ return false;
}
void tst_QNetworkInterface::initTestCase()