Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: webrtc/base/physicalsocketserver_unittest.cc

Issue 2881973002: Get tests working on systems that only support IPv6. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <memory> 11 #include <memory>
12 #include <signal.h> 12 #include <signal.h>
13 #include <stdarg.h> 13 #include <stdarg.h>
14 14
15 #include "webrtc/base/gunit.h" 15 #include "webrtc/base/gunit.h"
16 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
17 #include "webrtc/base/networkmonitor.h" 17 #include "webrtc/base/networkmonitor.h"
18 #include "webrtc/base/physicalsocketserver.h" 18 #include "webrtc/base/physicalsocketserver.h"
19 #include "webrtc/base/socket_unittest.h" 19 #include "webrtc/base/socket_unittest.h"
20 #include "webrtc/base/testutils.h" 20 #include "webrtc/base/testutils.h"
21 #include "webrtc/base/thread.h" 21 #include "webrtc/base/thread.h"
22 22
23 namespace rtc { 23 namespace rtc {
24 24
25 #define MAYBE_SKIP_IPV4 \
26 if (!HasIPv4Enabled()) { \
27 LOG(LS_INFO) << "No IPv4... skipping"; \
28 return; \
29 }
30
25 #define MAYBE_SKIP_IPV6 \ 31 #define MAYBE_SKIP_IPV6 \
26 if (!HasIPv6Enabled()) { \ 32 if (!HasIPv6Enabled()) { \
27 LOG(LS_INFO) << "No IPv6... skipping"; \ 33 LOG(LS_INFO) << "No IPv6... skipping"; \
28 return; \ 34 return; \
29 } 35 }
30 36
31 class PhysicalSocketTest; 37 class PhysicalSocketTest;
32 38
33 class FakeSocketDispatcher : public SocketDispatcher { 39 class FakeSocketDispatcher : public SocketDispatcher {
34 public: 40 public:
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 static_cast<FakePhysicalSocketServer*>(socketserver()); 163 static_cast<FakePhysicalSocketServer*>(socketserver());
158 if (ss->GetTest()->MaxSendSize() >= 0) { 164 if (ss->GetTest()->MaxSendSize() >= 0) {
159 len = std::min(len, ss->GetTest()->MaxSendSize()); 165 len = std::min(len, ss->GetTest()->MaxSendSize());
160 } 166 }
161 167
162 return SocketDispatcher::DoSendTo(socket, buf, len, flags, dest_addr, 168 return SocketDispatcher::DoSendTo(socket, buf, len, flags, dest_addr,
163 addrlen); 169 addrlen);
164 } 170 }
165 171
166 TEST_F(PhysicalSocketTest, TestConnectIPv4) { 172 TEST_F(PhysicalSocketTest, TestConnectIPv4) {
173 MAYBE_SKIP_IPV4;
167 SocketTest::TestConnectIPv4(); 174 SocketTest::TestConnectIPv4();
168 } 175 }
169 176
170 TEST_F(PhysicalSocketTest, TestConnectIPv6) { 177 TEST_F(PhysicalSocketTest, TestConnectIPv6) {
171 SocketTest::TestConnectIPv6(); 178 SocketTest::TestConnectIPv6();
172 } 179 }
173 180
174 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv4) { 181 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv4) {
182 MAYBE_SKIP_IPV4;
175 SocketTest::TestConnectWithDnsLookupIPv4(); 183 SocketTest::TestConnectWithDnsLookupIPv4();
176 } 184 }
177 185
178 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv6) { 186 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv6) {
179 SocketTest::TestConnectWithDnsLookupIPv6(); 187 SocketTest::TestConnectWithDnsLookupIPv6();
180 } 188 }
181 189
182 TEST_F(PhysicalSocketTest, TestConnectFailIPv4) { 190 TEST_F(PhysicalSocketTest, TestConnectFailIPv4) {
191 MAYBE_SKIP_IPV4;
183 SocketTest::TestConnectFailIPv4(); 192 SocketTest::TestConnectFailIPv4();
184 } 193 }
185 194
186 void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { 195 void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) {
187 webrtc::testing::StreamSink sink; 196 webrtc::testing::StreamSink sink;
188 SocketAddress accept_addr; 197 SocketAddress accept_addr;
189 198
190 // Create two clients. 199 // Create two clients.
191 std::unique_ptr<AsyncSocket> client1( 200 std::unique_ptr<AsyncSocket> client1(
192 server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM)); 201 server_->CreateAsyncSocket(loopback.family(), SOCK_STREAM));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 EXPECT_TRUE_WAIT((sink.Check(server.get(), webrtc::testing::SSE_READ)), 260 EXPECT_TRUE_WAIT((sink.Check(server.get(), webrtc::testing::SSE_READ)),
252 kTimeout); 261 kTimeout);
253 SetFailAccept(false); 262 SetFailAccept(false);
254 std::unique_ptr<AsyncSocket> accepted2(server->Accept(&accept_addr)); 263 std::unique_ptr<AsyncSocket> accepted2(server->Accept(&accept_addr));
255 ASSERT_TRUE(accepted2); 264 ASSERT_TRUE(accepted2);
256 EXPECT_FALSE(accept_addr.IsNil()); 265 EXPECT_FALSE(accept_addr.IsNil());
257 EXPECT_EQ(accepted2->GetRemoteAddress(), accept_addr); 266 EXPECT_EQ(accepted2->GetRemoteAddress(), accept_addr);
258 } 267 }
259 268
260 TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv4) { 269 TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv4) {
270 MAYBE_SKIP_IPV4;
261 ConnectInternalAcceptError(kIPv4Loopback); 271 ConnectInternalAcceptError(kIPv4Loopback);
262 } 272 }
263 273
264 TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv6) { 274 TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv6) {
265 MAYBE_SKIP_IPV6; 275 MAYBE_SKIP_IPV6;
266 ConnectInternalAcceptError(kIPv6Loopback); 276 ConnectInternalAcceptError(kIPv6Loopback);
267 } 277 }
268 278
269 void PhysicalSocketTest::WritableAfterPartialWrite(const IPAddress& loopback) { 279 void PhysicalSocketTest::WritableAfterPartialWrite(const IPAddress& loopback) {
270 // Simulate a really small maximum send size. 280 // Simulate a really small maximum send size.
271 const int kMaxSendSize = 128; 281 const int kMaxSendSize = 128;
272 SetMaxSendSize(kMaxSendSize); 282 SetMaxSendSize(kMaxSendSize);
273 283
274 // Run the default send/receive socket tests with a smaller amount of data 284 // Run the default send/receive socket tests with a smaller amount of data
275 // to avoid long running times due to the small maximum send size. 285 // to avoid long running times due to the small maximum send size.
276 const size_t kDataSize = 128 * 1024; 286 const size_t kDataSize = 128 * 1024;
277 TcpInternal(loopback, kDataSize, kMaxSendSize); 287 TcpInternal(loopback, kDataSize, kMaxSendSize);
278 } 288 }
279 289
280 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 290 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167
281 #if defined(WEBRTC_WIN) 291 #if defined(WEBRTC_WIN)
282 #define MAYBE_TestWritableAfterPartialWriteIPv4 DISABLED_TestWritableAfterPartia lWriteIPv4 292 #define MAYBE_TestWritableAfterPartialWriteIPv4 DISABLED_TestWritableAfterPartia lWriteIPv4
283 #else 293 #else
284 #define MAYBE_TestWritableAfterPartialWriteIPv4 TestWritableAfterPartialWriteIPv 4 294 #define MAYBE_TestWritableAfterPartialWriteIPv4 TestWritableAfterPartialWriteIPv 4
285 #endif 295 #endif
286 TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv4) { 296 TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv4) {
297 MAYBE_SKIP_IPV4;
287 WritableAfterPartialWrite(kIPv4Loopback); 298 WritableAfterPartialWrite(kIPv4Loopback);
288 } 299 }
289 300
290 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 301 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167
291 #if defined(WEBRTC_WIN) 302 #if defined(WEBRTC_WIN)
292 #define MAYBE_TestWritableAfterPartialWriteIPv6 DISABLED_TestWritableAfterPartia lWriteIPv6 303 #define MAYBE_TestWritableAfterPartialWriteIPv6 DISABLED_TestWritableAfterPartia lWriteIPv6
293 #else 304 #else
294 #define MAYBE_TestWritableAfterPartialWriteIPv6 TestWritableAfterPartialWriteIPv 6 305 #define MAYBE_TestWritableAfterPartialWriteIPv6 TestWritableAfterPartialWriteIPv 6
295 #endif 306 #endif
296 TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv6) { 307 TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv6) {
297 MAYBE_SKIP_IPV6; 308 MAYBE_SKIP_IPV6;
298 WritableAfterPartialWrite(kIPv6Loopback); 309 WritableAfterPartialWrite(kIPv6Loopback);
299 } 310 }
300 311
301 TEST_F(PhysicalSocketTest, TestConnectFailIPv6) { 312 TEST_F(PhysicalSocketTest, TestConnectFailIPv6) {
302 SocketTest::TestConnectFailIPv6(); 313 SocketTest::TestConnectFailIPv6();
303 } 314 }
304 315
305 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv4) { 316 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv4) {
317 MAYBE_SKIP_IPV4;
306 SocketTest::TestConnectWithDnsLookupFailIPv4(); 318 SocketTest::TestConnectWithDnsLookupFailIPv4();
307 } 319 }
308 320
309 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv6) { 321 TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv6) {
310 SocketTest::TestConnectWithDnsLookupFailIPv6(); 322 SocketTest::TestConnectWithDnsLookupFailIPv6();
311 } 323 }
312 324
313 325
314 TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv4) { 326 TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv4) {
327 MAYBE_SKIP_IPV4;
315 SocketTest::TestConnectWithClosedSocketIPv4(); 328 SocketTest::TestConnectWithClosedSocketIPv4();
316 } 329 }
317 330
318 TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv6) { 331 TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv6) {
319 SocketTest::TestConnectWithClosedSocketIPv6(); 332 SocketTest::TestConnectWithClosedSocketIPv6();
320 } 333 }
321 334
322 TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv4) { 335 TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv4) {
336 MAYBE_SKIP_IPV4;
323 SocketTest::TestConnectWhileNotClosedIPv4(); 337 SocketTest::TestConnectWhileNotClosedIPv4();
324 } 338 }
325 339
326 TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv6) { 340 TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv6) {
327 SocketTest::TestConnectWhileNotClosedIPv6(); 341 SocketTest::TestConnectWhileNotClosedIPv6();
328 } 342 }
329 343
330 TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv4) { 344 TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv4) {
345 MAYBE_SKIP_IPV4;
331 SocketTest::TestServerCloseDuringConnectIPv4(); 346 SocketTest::TestServerCloseDuringConnectIPv4();
332 } 347 }
333 348
334 TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv6) { 349 TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv6) {
335 SocketTest::TestServerCloseDuringConnectIPv6(); 350 SocketTest::TestServerCloseDuringConnectIPv6();
336 } 351 }
337 352
338 TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv4) { 353 TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv4) {
354 MAYBE_SKIP_IPV4;
339 SocketTest::TestClientCloseDuringConnectIPv4(); 355 SocketTest::TestClientCloseDuringConnectIPv4();
340 } 356 }
341 357
342 TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv6) { 358 TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv6) {
343 SocketTest::TestClientCloseDuringConnectIPv6(); 359 SocketTest::TestClientCloseDuringConnectIPv6();
344 } 360 }
345 361
346 TEST_F(PhysicalSocketTest, TestServerCloseIPv4) { 362 TEST_F(PhysicalSocketTest, TestServerCloseIPv4) {
363 MAYBE_SKIP_IPV4;
347 SocketTest::TestServerCloseIPv4(); 364 SocketTest::TestServerCloseIPv4();
348 } 365 }
349 366
350 TEST_F(PhysicalSocketTest, TestServerCloseIPv6) { 367 TEST_F(PhysicalSocketTest, TestServerCloseIPv6) {
351 SocketTest::TestServerCloseIPv6(); 368 SocketTest::TestServerCloseIPv6();
352 } 369 }
353 370
354 TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv4) { 371 TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv4) {
372 MAYBE_SKIP_IPV4;
355 SocketTest::TestCloseInClosedCallbackIPv4(); 373 SocketTest::TestCloseInClosedCallbackIPv4();
356 } 374 }
357 375
358 TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv6) { 376 TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv6) {
359 SocketTest::TestCloseInClosedCallbackIPv6(); 377 SocketTest::TestCloseInClosedCallbackIPv6();
360 } 378 }
361 379
362 TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv4) { 380 TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv4) {
381 MAYBE_SKIP_IPV4;
363 SocketTest::TestSocketServerWaitIPv4(); 382 SocketTest::TestSocketServerWaitIPv4();
364 } 383 }
365 384
366 TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv6) { 385 TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv6) {
367 SocketTest::TestSocketServerWaitIPv6(); 386 SocketTest::TestSocketServerWaitIPv6();
368 } 387 }
369 388
370 TEST_F(PhysicalSocketTest, TestTcpIPv4) { 389 TEST_F(PhysicalSocketTest, TestTcpIPv4) {
390 MAYBE_SKIP_IPV4;
371 SocketTest::TestTcpIPv4(); 391 SocketTest::TestTcpIPv4();
372 } 392 }
373 393
374 TEST_F(PhysicalSocketTest, TestTcpIPv6) { 394 TEST_F(PhysicalSocketTest, TestTcpIPv6) {
375 SocketTest::TestTcpIPv6(); 395 SocketTest::TestTcpIPv6();
376 } 396 }
377 397
378 TEST_F(PhysicalSocketTest, TestUdpIPv4) { 398 TEST_F(PhysicalSocketTest, TestUdpIPv4) {
399 MAYBE_SKIP_IPV4;
379 SocketTest::TestUdpIPv4(); 400 SocketTest::TestUdpIPv4();
380 } 401 }
381 402
382 TEST_F(PhysicalSocketTest, TestUdpIPv6) { 403 TEST_F(PhysicalSocketTest, TestUdpIPv6) {
383 SocketTest::TestUdpIPv6(); 404 SocketTest::TestUdpIPv6();
384 } 405 }
385 406
386 // Disable for TSan v2, see 407 // Disable for TSan v2, see
387 // https://code.google.com/p/webrtc/issues/detail?id=3498 for details. 408 // https://code.google.com/p/webrtc/issues/detail?id=3498 for details.
388 // Also disable for MSan, see: 409 // Also disable for MSan, see:
389 // https://code.google.com/p/webrtc/issues/detail?id=4958 410 // https://code.google.com/p/webrtc/issues/detail?id=4958
390 // TODO(deadbeef): Enable again once test is reimplemented to be unflaky. 411 // TODO(deadbeef): Enable again once test is reimplemented to be unflaky.
391 // Also disable for ASan. 412 // Also disable for ASan.
392 // Disabled on Android: https://code.google.com/p/webrtc/issues/detail?id=4364 413 // Disabled on Android: https://code.google.com/p/webrtc/issues/detail?id=4364
393 // Disabled on Linux: https://bugs.chromium.org/p/webrtc/issues/detail?id=5233 414 // Disabled on Linux: https://bugs.chromium.org/p/webrtc/issues/detail?id=5233
394 #if defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \ 415 #if defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \
395 defined(ADDRESS_SANITIZER) || defined(WEBRTC_ANDROID) || \ 416 defined(ADDRESS_SANITIZER) || defined(WEBRTC_ANDROID) || \
396 defined(WEBRTC_LINUX) 417 defined(WEBRTC_LINUX)
397 #define MAYBE_TestUdpReadyToSendIPv4 DISABLED_TestUdpReadyToSendIPv4 418 #define MAYBE_TestUdpReadyToSendIPv4 DISABLED_TestUdpReadyToSendIPv4
398 #else 419 #else
399 #define MAYBE_TestUdpReadyToSendIPv4 TestUdpReadyToSendIPv4 420 #define MAYBE_TestUdpReadyToSendIPv4 TestUdpReadyToSendIPv4
400 #endif 421 #endif
401 TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv4) { 422 TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv4) {
423 MAYBE_SKIP_IPV4;
402 SocketTest::TestUdpReadyToSendIPv4(); 424 SocketTest::TestUdpReadyToSendIPv4();
403 } 425 }
404 426
405 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 427 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167
406 #if defined(WEBRTC_WIN) 428 #if defined(WEBRTC_WIN)
407 #define MAYBE_TestUdpReadyToSendIPv6 DISABLED_TestUdpReadyToSendIPv6 429 #define MAYBE_TestUdpReadyToSendIPv6 DISABLED_TestUdpReadyToSendIPv6
408 #else 430 #else
409 #define MAYBE_TestUdpReadyToSendIPv6 TestUdpReadyToSendIPv6 431 #define MAYBE_TestUdpReadyToSendIPv6 TestUdpReadyToSendIPv6
410 #endif 432 #endif
411 TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv6) { 433 TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv6) {
412 SocketTest::TestUdpReadyToSendIPv6(); 434 SocketTest::TestUdpReadyToSendIPv6();
413 } 435 }
414 436
415 TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv4) { 437 TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv4) {
438 MAYBE_SKIP_IPV4;
416 SocketTest::TestGetSetOptionsIPv4(); 439 SocketTest::TestGetSetOptionsIPv4();
417 } 440 }
418 441
419 TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv6) { 442 TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv6) {
420 SocketTest::TestGetSetOptionsIPv6(); 443 SocketTest::TestGetSetOptionsIPv6();
421 } 444 }
422 445
423 #if defined(WEBRTC_POSIX) 446 #if defined(WEBRTC_POSIX)
424 447
425 // We don't get recv timestamps on Mac. 448 // We don't get recv timestamps on Mac.
426 #if !defined(WEBRTC_MAC) 449 #if !defined(WEBRTC_MAC)
427 TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4) { 450 TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4) {
451 MAYBE_SKIP_IPV4;
428 SocketTest::TestSocketRecvTimestampIPv4(); 452 SocketTest::TestSocketRecvTimestampIPv4();
429 } 453 }
430 454
431 TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6) { 455 TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6) {
432 SocketTest::TestSocketRecvTimestampIPv6(); 456 SocketTest::TestSocketRecvTimestampIPv6();
433 } 457 }
434 #endif 458 #endif
435 459
436 // Verify that if the socket was unable to be bound to a real network interface 460 // Verify that if the socket was unable to be bound to a real network interface
437 // (not loopback), Bind will return an error. 461 // (not loopback), Bind will return an error.
438 TEST_F(PhysicalSocketTest, 462 TEST_F(PhysicalSocketTest,
439 BindFailsIfNetworkBinderFailsForNonLoopbackInterface) { 463 BindFailsIfNetworkBinderFailsForNonLoopbackInterface) {
464 MAYBE_SKIP_IPV4;
440 FakeNetworkBinder fake_network_binder; 465 FakeNetworkBinder fake_network_binder;
441 server_->set_network_binder(&fake_network_binder); 466 server_->set_network_binder(&fake_network_binder);
442 std::unique_ptr<AsyncSocket> socket( 467 std::unique_ptr<AsyncSocket> socket(
443 server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM)); 468 server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM));
444 fake_network_binder.set_result(NetworkBindingResult::FAILURE); 469 fake_network_binder.set_result(NetworkBindingResult::FAILURE);
445 EXPECT_EQ(-1, socket->Bind(SocketAddress("192.168.0.1", 0))); 470 EXPECT_EQ(-1, socket->Bind(SocketAddress("192.168.0.1", 0)));
446 server_->set_network_binder(nullptr); 471 server_->set_network_binder(nullptr);
447 } 472 }
448 473
449 // Network binder shouldn't be used if the socket is bound to the "any" IP. 474 // Network binder shouldn't be used if the socket is bound to the "any" IP.
450 TEST_F(PhysicalSocketTest, 475 TEST_F(PhysicalSocketTest,
451 NetworkBinderIsNotUsedForAnyIp) { 476 NetworkBinderIsNotUsedForAnyIp) {
477 MAYBE_SKIP_IPV4;
452 FakeNetworkBinder fake_network_binder; 478 FakeNetworkBinder fake_network_binder;
453 server_->set_network_binder(&fake_network_binder); 479 server_->set_network_binder(&fake_network_binder);
454 std::unique_ptr<AsyncSocket> socket( 480 std::unique_ptr<AsyncSocket> socket(
455 server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM)); 481 server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM));
456 EXPECT_EQ(0, socket->Bind(SocketAddress("0.0.0.0", 0))); 482 EXPECT_EQ(0, socket->Bind(SocketAddress("0.0.0.0", 0)));
457 EXPECT_EQ(0, fake_network_binder.num_binds()); 483 EXPECT_EQ(0, fake_network_binder.num_binds());
458 server_->set_network_binder(nullptr); 484 server_->set_network_binder(nullptr);
459 } 485 }
460 486
461 // For a loopback interface, failures to bind to the interface should be 487 // For a loopback interface, failures to bind to the interface should be
462 // tolerated. 488 // tolerated.
463 TEST_F(PhysicalSocketTest, 489 TEST_F(PhysicalSocketTest,
464 BindSucceedsIfNetworkBinderFailsForLoopbackInterface) { 490 BindSucceedsIfNetworkBinderFailsForLoopbackInterface) {
491 MAYBE_SKIP_IPV4;
465 FakeNetworkBinder fake_network_binder; 492 FakeNetworkBinder fake_network_binder;
466 server_->set_network_binder(&fake_network_binder); 493 server_->set_network_binder(&fake_network_binder);
467 std::unique_ptr<AsyncSocket> socket( 494 std::unique_ptr<AsyncSocket> socket(
468 server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM)); 495 server_->CreateAsyncSocket(AF_INET, SOCK_DGRAM));
469 fake_network_binder.set_result(NetworkBindingResult::FAILURE); 496 fake_network_binder.set_result(NetworkBindingResult::FAILURE);
470 EXPECT_EQ(0, socket->Bind(SocketAddress(kIPv4Loopback, 0))); 497 EXPECT_EQ(0, socket->Bind(SocketAddress(kIPv4Loopback, 0)));
471 server_->set_network_binder(nullptr); 498 server_->set_network_binder(nullptr);
472 } 499 }
473 500
474 class PosixSignalDeliveryTest : public testing::Test { 501 class PosixSignalDeliveryTest : public testing::Test {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 thread->Start(runnable.get()); 615 thread->Start(runnable.get());
589 EXPECT_TRUE(ss_->Wait(1500, true)); 616 EXPECT_TRUE(ss_->Wait(1500, true));
590 EXPECT_TRUE(ExpectSignal(SIGTERM)); 617 EXPECT_TRUE(ExpectSignal(SIGTERM));
591 EXPECT_EQ(Thread::Current(), signaled_thread_); 618 EXPECT_EQ(Thread::Current(), signaled_thread_);
592 EXPECT_TRUE(ExpectNone()); 619 EXPECT_TRUE(ExpectNone());
593 } 620 }
594 621
595 #endif 622 #endif
596 623
597 } // namespace rtc 624 } // namespace rtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698