Get tests working on systems that only support IPv6.
For every failing test, the solution was either to do a "has IPv4" check
before the test is run, or avoid depending on real network interfaces
altogether.
This specifically fixes rtc_unittests, peerconnection_unittests, and
webrtc_nonparallel_tests.
BUG=None
Review-Url: https://codereview.webrtc.org/2881973002
Cr-Commit-Position: refs/heads/master@{#18155}
diff --git a/webrtc/base/testclient_unittest.cc b/webrtc/base/testclient_unittest.cc
index 6854994..8392abf 100644
--- a/webrtc/base/testclient_unittest.cc
+++ b/webrtc/base/testclient_unittest.cc
@@ -18,6 +18,18 @@
using namespace rtc;
+#define MAYBE_SKIP_IPV4 \
+ if (!HasIPv4Enabled()) { \
+ LOG(LS_INFO) << "No IPv4... skipping"; \
+ return; \
+ }
+
+#define MAYBE_SKIP_IPV6 \
+ if (!HasIPv6Enabled()) { \
+ LOG(LS_INFO) << "No IPv6... skipping"; \
+ return; \
+ }
+
void TestUdpInternal(const SocketAddress& loopback) {
Thread *main = Thread::Current();
AsyncSocket* socket = main->socketserver()
@@ -53,6 +65,7 @@
// Tests whether the TestClient can send UDP to itself.
TEST(TestClientTest, TestUdpIPv4) {
+ MAYBE_SKIP_IPV4;
TestUdpInternal(SocketAddress("127.0.0.1", 0));
}
@@ -62,15 +75,13 @@
#define MAYBE_TestUdpIPv6 TestUdpIPv6
#endif
TEST(TestClientTest, MAYBE_TestUdpIPv6) {
- if (HasIPv6Enabled()) {
- TestUdpInternal(SocketAddress("::1", 0));
- } else {
- LOG(LS_INFO) << "Skipping IPv6 test.";
- }
+ MAYBE_SKIP_IPV6;
+ TestUdpInternal(SocketAddress("::1", 0));
}
// Tests whether the TestClient can connect to a server and exchange data.
TEST(TestClientTest, TestTcpIPv4) {
+ MAYBE_SKIP_IPV4;
TestTcpInternal(SocketAddress("127.0.0.1", 0));
}
@@ -80,9 +91,6 @@
#define MAYBE_TestTcpIPv6 TestTcpIPv6
#endif
TEST(TestClientTest, MAYBE_TestTcpIPv6) {
- if (HasIPv6Enabled()) {
- TestTcpInternal(SocketAddress("::1", 0));
- } else {
- LOG(LS_INFO) << "Skipping IPv6 test.";
- }
+ MAYBE_SKIP_IPV6;
+ TestTcpInternal(SocketAddress("::1", 0));
}