diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-23 15:34:24 -0200 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-12-24 22:49:20 +0100 |
commit | 14c5f149cdbec51df297d4849ba4eb98fb47fbe2 (patch) | |
tree | 89307c67352b5406f5efe5afa9e4dfc2155bc77e /tests/auto/network | |
parent | 11b282d58121ec63316ec11da0af10023b593549 (diff) |
Fix tst_QUdpSocket::multicastLeaveAfterClose
With IPv6, you cannot bind to a multicast address. You need to bind to a
local address only. The previous tests either checked this or didn't
check the result of bind().
Change-Id: Ief70887d8988fc1bc4394cf6ff34b5d560e5748e
Reviewed-by: Richard J. Moore <rich@kde.org>
Diffstat (limited to 'tests/auto/network')
-rw-r--r-- | tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp index 0a56807a7f..a49f284938 100644 --- a/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp +++ b/tests/auto/network/socket/qudpsocket/tst_qudpsocket.cpp @@ -1163,8 +1163,8 @@ void tst_QUdpSocket::multicastJoinBeforeBind() void tst_QUdpSocket::multicastLeaveAfterClose_data() { QTest::addColumn<QHostAddress>("groupAddress"); - QTest::newRow("valid ipv4 group address") << QHostAddress("239.255.118.62"); - QTest::newRow("valid ipv6 group address") << QHostAddress("FF01::114"); + QTest::newRow("ipv4") << QHostAddress("239.255.118.62"); + QTest::newRow("ipv6") << QHostAddress("FF01::114"); } void tst_QUdpSocket::multicastLeaveAfterClose() @@ -1180,7 +1180,10 @@ void tst_QUdpSocket::multicastLeaveAfterClose() #ifdef FORCE_SESSION udpSocket.setProperty("_q_networksession", QVariant::fromValue(networkSession)); #endif - QVERIFY2(udpSocket.bind(groupAddress, 0), + QHostAddress bindAddress = QHostAddress::AnyIPv4; + if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) + bindAddress = QHostAddress::AnyIPv6; + QVERIFY2(udpSocket.bind(bindAddress, 0), qPrintable(udpSocket.errorString())); QVERIFY2(udpSocket.joinMulticastGroup(groupAddress), qPrintable(udpSocket.errorString())); |