summaryrefslogtreecommitdiffstats
path: root/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2020-02-07 09:47:24 -0800
committerThiago Macieira <thiago.macieira@intel.com>2020-02-13 15:11:21 -0800
commit210fd52e0d5e77105c676c064e7c3a69a00e2122 (patch)
treea4fff628a924fef706930f1cc08565ba99a01cfb /tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
parent5ff37f13ee577c006f0b99307d0afa1cf991db08 (diff)
Autotest: adapt to certain OSes always allowing binding to low ports
Apple changed on macOS 10.14 (Mojave). Windows has always allowed. Fixes: QTBUG-81905 Change-Id: I572733186b73423b89e5fffd15f12fee3f03c055 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp')
-rw-r--r--tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
index 5be00630ca..68c913ecfc 100644
--- a/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
+++ b/tests/auto/network/socket/platformsocketengine/tst_platformsocketengine.cpp
@@ -529,12 +529,11 @@ void tst_PlatformSocketEngine::tooManySockets()
//---------------------------------------------------------------------------
void tst_PlatformSocketEngine::bind()
{
-#if !defined Q_OS_WIN
PLATFORMSOCKETENGINE binder;
QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
- QVERIFY(!binder.bind(QHostAddress::AnyIPv4, 82));
- QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError);
-#endif
+ QCOMPARE(binder.bind(QHostAddress::AnyIPv4, 82), QtNetworkSettings::canBindToLowPorts());
+ if (!QtNetworkSettings::canBindToLowPorts())
+ QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError);
PLATFORMSOCKETENGINE binder2;
QVERIFY(binder2.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol));
@@ -546,6 +545,12 @@ void tst_PlatformSocketEngine::bind()
QCOMPARE(binder3.error(), QAbstractSocket::AddressInUseError);
if (QtNetworkSettings::hasIPv6()) {
+ PLATFORMSOCKETENGINE binder;
+ QVERIFY(binder.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv6Protocol));
+ QCOMPARE(binder.bind(QHostAddress::AnyIPv6, 82), QtNetworkSettings::canBindToLowPorts());
+ if (!QtNetworkSettings::canBindToLowPorts())
+ QCOMPARE(binder.error(), QAbstractSocket::SocketAccessError);
+
PLATFORMSOCKETENGINE binder4;
QVERIFY(binder4.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv6Protocol));
QVERIFY(binder4.bind(QHostAddress::AnyIPv6, 31180));