diff options
author | Tobias Markmann <tm@ayena.de> | 2016-01-09 23:44:03 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-01-11 09:22:54 (GMT) |
commit | e314293415c9691bb98188b514f6b13e33994d86 (patch) | |
tree | d43dd1a39a0b4416a7d1fc8f901f711040c65dac /Swiften/QA/NetworkTest/BoostConnectionTest.cpp | |
parent | 1941a4b684f3c5f852eb94deac4550c0450fe1b9 (diff) | |
download | swift-e314293415c9691bb98188b514f6b13e33994d86.zip swift-e314293415c9691bb98188b514f6b13e33994d86.tar.bz2 |
Fix IPv6 DNS resolution issues on Windows
Use values instead of define names for _WIN32_WINNT and
NTDDI_VERSION defined needed for Windows.h configuration.
Using the names boost fails to correctly detect getaddrinfo()
support on Windows.
Only run IPv6 related test cases in DomainNameResolverTest on
Windows, if test_ipv6=1 is passed to the scons arguments.
This is because on Windows getaddrinfo() will not return
IPv6 related results when called with the AF_UNSPEC hint,
unless the Windows host has global IPv6 connectivity.
Changed the BoostConnectionTest to time out and not endlessly
wait on a response from the remote host.
Test-Information:
Ran the following test configurations:
* (SUCCESS) On Windows 8 with HE.net IPv6 tunnel to provide
full IPv6 connectiviy:
scons.bat test=system test_ipv6=1 Swiften/QA/NetworkTest
* (SUCCESS) On Windows 8 with HE.net IPv6 tunnel to provide
full IPv6 connectiviy:
scons.bat test=system Swiften/QA/NetworkTest
* (EXPECTED FAIL) On Windows 8 with no IPv6 connectiviy:
scons.bat test=system test_ipv6=1 Swiften/QA/NetworkTest
* (SUCCESS) On Windows 8 with no IPv6 connectiviy:
scons.bat test=system Swiften/QA/NetworkTest
Change-Id: I5adcd28e09e22acf61f7cca40b614e71df75dd70
Diffstat (limited to 'Swiften/QA/NetworkTest/BoostConnectionTest.cpp')
-rwxr-xr-x[-rw-r--r--] | Swiften/QA/NetworkTest/BoostConnectionTest.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp index 484c5e3..a122686 100644..100755 --- a/Swiften/QA/NetworkTest/BoostConnectionTest.cpp +++ b/Swiften/QA/NetworkTest/BoostConnectionTest.cpp @@ -1,11 +1,12 @@ /* - * Copyright (c) 2010-2015 Isode Limited. + * Copyright (c) 2010-2016 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <string> +#include <boost/date_time/posix_time/posix_time_types.hpp> #include <boost/shared_ptr.hpp> #include <boost/smart_ptr/make_shared.hpp> @@ -69,28 +70,38 @@ class BoostConnectionTest : public CppUnit::TestFixture { } void testWrite() { + using namespace boost::posix_time; + BoostConnection::ref testling(BoostConnection::create(boostIOServiceThread_->getIOService(), eventLoop_)); testling->onConnectFinished.connect(boost::bind(&BoostConnectionTest::doWrite, this, testling.get())); testling->onDataRead.connect(boost::bind(&BoostConnectionTest::handleDataRead, this, _1)); testling->onDisconnected.connect(boost::bind(&BoostConnectionTest::handleDisconnected, this)); testling->connect(HostAddressPort(HostAddress(getenv("SWIFT_NETWORK_TEST_IPV4")), 5222)); - while (receivedData_.empty()) { + + boost::posix_time::ptime start = second_clock::local_time(); + while (receivedData_.empty() && ((second_clock::local_time() - start) < seconds(60))) { Swift::sleep(10); eventLoop_->processEvents(); } + CPPUNIT_ASSERT_EQUAL(false, receivedData_.empty()); testling->disconnect(); } void testWrite_IPv6() { + using namespace boost::posix_time; + BoostConnection::ref testling(BoostConnection::create(boostIOServiceThread_->getIOService(), eventLoop_)); testling->onConnectFinished.connect(boost::bind(&BoostConnectionTest::doWrite, this, testling.get())); testling->onDataRead.connect(boost::bind(&BoostConnectionTest::handleDataRead, this, _1)); testling->onDisconnected.connect(boost::bind(&BoostConnectionTest::handleDisconnected, this)); - testling->connect(HostAddressPort(HostAddress(getenv("SWIFT_NETWORK_TEST_IPV6")), 80)); - while (receivedData_.empty()) { + testling->connect(HostAddressPort(HostAddress(getenv("SWIFT_NETWORK_TEST_IPV6")), 5222)); + + boost::posix_time::ptime start = second_clock::local_time(); + while (receivedData_.empty() && ((second_clock::local_time() - start) < seconds(60))) { Swift::sleep(10); eventLoop_->processEvents(); } + CPPUNIT_ASSERT_EQUAL(false, receivedData_.empty()); testling->disconnect(); } |