OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2009 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 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 NAT_SYMMETRIC_THEN_CONE, // Double NAT, symmetric outer, cone inner | 203 NAT_SYMMETRIC_THEN_CONE, // Double NAT, symmetric outer, cone inner |
204 BLOCK_UDP, // Firewall, UDP in/out blocked | 204 BLOCK_UDP, // Firewall, UDP in/out blocked |
205 BLOCK_UDP_AND_INCOMING_TCP, // Firewall, UDP in/out and TCP in blocked | 205 BLOCK_UDP_AND_INCOMING_TCP, // Firewall, UDP in/out and TCP in blocked |
206 BLOCK_ALL_BUT_OUTGOING_HTTP, // Firewall, only TCP out on 80/443 | 206 BLOCK_ALL_BUT_OUTGOING_HTTP, // Firewall, only TCP out on 80/443 |
207 PROXY_HTTPS, // All traffic through HTTPS proxy | 207 PROXY_HTTPS, // All traffic through HTTPS proxy |
208 PROXY_SOCKS, // All traffic through SOCKS proxy | 208 PROXY_SOCKS, // All traffic through SOCKS proxy |
209 NUM_CONFIGS | 209 NUM_CONFIGS |
210 }; | 210 }; |
211 | 211 |
212 struct Result { | 212 struct Result { |
213 Result(const std::string& lt, const std::string& lp, | 213 Result(const std::string& controlling_type, |
214 const std::string& rt, const std::string& rp, | 214 const std::string& controlling_protocol, |
215 const std::string& lt2, const std::string& lp2, | 215 const std::string& controlled_type, |
216 const std::string& rt2, const std::string& rp2, int wait) | 216 const std::string& controlled_protocol, |
217 : local_type(lt), local_proto(lp), remote_type(rt), remote_proto(rp), | 217 int wait) |
218 local_type2(lt2), local_proto2(lp2), remote_type2(rt2), | 218 : controlling_type(controlling_type), |
219 remote_proto2(rp2), connect_wait(wait) { | 219 controlling_protocol(controlling_protocol), |
220 } | 220 controlled_type(controlled_type), |
| 221 controlled_protocol(controlled_protocol), |
| 222 connect_wait(wait) {} |
221 | 223 |
222 std::string local_type; | 224 // The expected candidate type and protocol of the controlling ICE agent. |
223 std::string local_proto; | 225 std::string controlling_type; |
224 std::string remote_type; | 226 std::string controlling_protocol; |
225 std::string remote_proto; | 227 // The expected candidate type and protocol of the controlled ICE agent. |
226 std::string local_type2; | 228 std::string controlled_type; |
227 std::string local_proto2; | 229 std::string controlled_protocol; |
228 std::string remote_type2; | 230 // How long to wait before the correct candidate pair is selected. |
229 std::string remote_proto2; | |
230 int connect_wait; | 231 int connect_wait; |
231 }; | 232 }; |
232 | 233 |
233 struct ChannelData { | 234 struct ChannelData { |
234 bool CheckData(const char* data, int len) { | 235 bool CheckData(const char* data, int len) { |
235 bool ret = false; | 236 bool ret = false; |
236 if (!ch_packets_.empty()) { | 237 if (!ch_packets_.empty()) { |
237 std::string packet = ch_packets_.front(); | 238 std::string packet = ch_packets_.front(); |
238 ret = (packet == std::string(data, len)); | 239 ret = (packet == std::string(data, len)); |
239 ch_packets_.pop_front(); | 240 ch_packets_.pop_front(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 TestTurnServer* test_turn_server() { return &turn_server_; } | 375 TestTurnServer* test_turn_server() { return &turn_server_; } |
375 rtc::VirtualSocketServer* virtual_socket_server() { return vss_.get(); } | 376 rtc::VirtualSocketServer* virtual_socket_server() { return vss_.get(); } |
376 | 377 |
377 // Common results. | 378 // Common results. |
378 static const Result kLocalUdpToLocalUdp; | 379 static const Result kLocalUdpToLocalUdp; |
379 static const Result kLocalUdpToStunUdp; | 380 static const Result kLocalUdpToStunUdp; |
380 static const Result kLocalUdpToPrflxUdp; | 381 static const Result kLocalUdpToPrflxUdp; |
381 static const Result kPrflxUdpToLocalUdp; | 382 static const Result kPrflxUdpToLocalUdp; |
382 static const Result kStunUdpToLocalUdp; | 383 static const Result kStunUdpToLocalUdp; |
383 static const Result kStunUdpToStunUdp; | 384 static const Result kStunUdpToStunUdp; |
| 385 static const Result kStunUdpToPrflxUdp; |
384 static const Result kPrflxUdpToStunUdp; | 386 static const Result kPrflxUdpToStunUdp; |
385 static const Result kLocalUdpToRelayUdp; | 387 static const Result kLocalUdpToRelayUdp; |
386 static const Result kPrflxUdpToRelayUdp; | 388 static const Result kPrflxUdpToRelayUdp; |
| 389 static const Result kRelayUdpToPrflxUdp; |
387 static const Result kLocalTcpToLocalTcp; | 390 static const Result kLocalTcpToLocalTcp; |
388 static const Result kLocalTcpToPrflxTcp; | 391 static const Result kLocalTcpToPrflxTcp; |
389 static const Result kPrflxTcpToLocalTcp; | 392 static const Result kPrflxTcpToLocalTcp; |
390 | 393 |
391 rtc::NATSocketServer* nat() { return nss_.get(); } | 394 rtc::NATSocketServer* nat() { return nss_.get(); } |
392 rtc::FirewallSocketServer* fw() { return ss_.get(); } | 395 rtc::FirewallSocketServer* fw() { return ss_.get(); } |
393 | 396 |
394 Endpoint* GetEndpoint(int endpoint) { | 397 Endpoint* GetEndpoint(int endpoint) { |
395 if (endpoint == 0) { | 398 if (endpoint == 0) { |
396 return &ep1_; | 399 return &ep1_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 } | 438 } |
436 bool GetRoleConflict(int endpoint) { | 439 bool GetRoleConflict(int endpoint) { |
437 return GetEndpoint(endpoint)->role_conflict(); | 440 return GetEndpoint(endpoint)->role_conflict(); |
438 } | 441 } |
439 void SetAllocationStepDelay(int endpoint, uint32_t delay) { | 442 void SetAllocationStepDelay(int endpoint, uint32_t delay) { |
440 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); | 443 return GetEndpoint(endpoint)->SetAllocationStepDelay(delay); |
441 } | 444 } |
442 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { | 445 void SetAllowTcpListen(int endpoint, bool allow_tcp_listen) { |
443 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); | 446 return GetEndpoint(endpoint)->SetAllowTcpListen(allow_tcp_listen); |
444 } | 447 } |
445 bool IsLocalToPrflxOrTheReverse(const Result& expected) { | |
446 return ( | |
447 (expected.local_type == "local" && expected.remote_type == "prflx") || | |
448 (expected.local_type == "prflx" && expected.remote_type == "local")); | |
449 } | |
450 | 448 |
451 // Return true if the approprite parts of the expected Result, based | 449 // Return true if the approprite parts of the expected Result, based |
452 // on the local and remote candidate of ep1_ch1, match. This can be | 450 // on the local and remote candidate of ep1_ch1, match. This can be |
453 // used in an EXPECT_TRUE_WAIT. | 451 // used in an EXPECT_TRUE_WAIT. |
454 bool CheckCandidate1(const Result& expected) { | 452 bool CheckCandidate1(const Result& expected) { |
455 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); | 453 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); |
456 const std::string& local_proto = LocalCandidate(ep1_ch1())->protocol(); | 454 const std::string& local_protocol = LocalCandidate(ep1_ch1())->protocol(); |
457 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); | 455 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); |
458 const std::string& remote_proto = RemoteCandidate(ep1_ch1())->protocol(); | 456 const std::string& remote_protocol = RemoteCandidate(ep1_ch1())->protocol(); |
459 return ((local_proto == expected.local_proto && | 457 return (local_protocol == expected.controlling_protocol && |
460 remote_proto == expected.remote_proto) && | 458 remote_protocol == expected.controlled_protocol && |
461 ((local_type == expected.local_type && | 459 local_type == expected.controlling_type && |
462 remote_type == expected.remote_type) || | 460 remote_type == expected.controlled_type); |
463 // Sometimes we expect local -> prflx or prflx -> local | |
464 // and instead get prflx -> local or local -> prflx, and | |
465 // that's OK. | |
466 (IsLocalToPrflxOrTheReverse(expected) && | |
467 local_type == expected.remote_type && | |
468 remote_type == expected.local_type))); | |
469 } | 461 } |
470 | 462 |
471 // EXPECT_EQ on the approprite parts of the expected Result, based | 463 // EXPECT_EQ on the approprite parts of the expected Result, based |
472 // on the local and remote candidate of ep1_ch1. This is like | 464 // on the local and remote candidate of ep1_ch1. This is like |
473 // CheckCandidate1, except that it will provide more detail about | 465 // CheckCandidate1, except that it will provide more detail about |
474 // what didn't match. | 466 // what didn't match. |
475 void ExpectCandidate1(const Result& expected) { | 467 void ExpectCandidate1(const Result& expected) { |
476 if (CheckCandidate1(expected)) { | 468 if (CheckCandidate1(expected)) { |
477 return; | 469 return; |
478 } | 470 } |
479 | 471 |
480 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); | 472 const std::string& local_type = LocalCandidate(ep1_ch1())->type(); |
481 const std::string& local_proto = LocalCandidate(ep1_ch1())->protocol(); | 473 const std::string& local_protocol = LocalCandidate(ep1_ch1())->protocol(); |
482 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); | 474 const std::string& remote_type = RemoteCandidate(ep1_ch1())->type(); |
483 const std::string& remote_proto = RemoteCandidate(ep1_ch1())->protocol(); | 475 const std::string& remote_protocol = RemoteCandidate(ep1_ch1())->protocol(); |
484 EXPECT_EQ(expected.local_type, local_type); | 476 EXPECT_EQ(expected.controlling_type, local_type); |
485 EXPECT_EQ(expected.remote_type, remote_type); | 477 EXPECT_EQ(expected.controlled_type, remote_type); |
486 EXPECT_EQ(expected.local_proto, local_proto); | 478 EXPECT_EQ(expected.controlling_protocol, local_protocol); |
487 EXPECT_EQ(expected.remote_proto, remote_proto); | 479 EXPECT_EQ(expected.controlled_protocol, remote_protocol); |
488 } | 480 } |
489 | 481 |
490 // Return true if the approprite parts of the expected Result, based | 482 // Return true if the approprite parts of the expected Result, based |
491 // on the local and remote candidate of ep2_ch1, match. This can be | 483 // on the local and remote candidate of ep2_ch1, match. This can be |
492 // used in an EXPECT_TRUE_WAIT. | 484 // used in an EXPECT_TRUE_WAIT. |
493 bool CheckCandidate2(const Result& expected) { | 485 bool CheckCandidate2(const Result& expected) { |
494 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); | 486 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); |
495 const std::string& remote_proto = RemoteCandidate(ep2_ch1())->protocol(); | 487 const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); |
496 // Removed remote_type comparision aginst selected connection remote | 488 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); |
497 // candidate. This is done to handle remote type discrepancy from | 489 const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); |
498 // local to stun based on the test type. | 490 return (local_protocol == expected.controlled_protocol && |
499 // For example in case of Open -> NAT, ep2 channels will have LULU | 491 remote_protocol == expected.controlling_protocol && |
500 // and in other cases like NAT -> NAT it will be LUSU. To avoid these | 492 local_type == expected.controlled_type && |
501 // mismatches and we are doing comparision in different way. | 493 remote_type == expected.controlling_type); |
502 // i.e. when don't match its remote type is either local or stun. | |
503 // | |
504 // Update(deadbeef): Also had to remove local type comparison. There | |
505 // is currently an issue where the local type is not updated to stun. | |
506 // So one side may see local<->relay while the other sees relay<->stun. | |
507 // This mean the other side may prioritize prflx<->relay, and won't have | |
508 // a local type of relay no matter how long we wait. | |
509 // TODO(deadbeef): Fix this!! It's causing us to have very sparse test | |
510 // coverage and is a very real bug. | |
511 // | |
512 // TODO(ronghuawu): Refine the test criteria. | |
513 // https://code.google.com/p/webrtc/issues/detail?id=1953 | |
514 return ((local_proto == expected.local_proto2 && | |
515 remote_proto == expected.remote_proto2)); | |
516 } | 494 } |
517 | 495 |
518 // EXPECT_EQ on the approprite parts of the expected Result, based | 496 // EXPECT_EQ on the approprite parts of the expected Result, based |
519 // on the local and remote candidate of ep2_ch1. This is like | 497 // on the local and remote candidate of ep2_ch1. This is like |
520 // CheckCandidate2, except that it will provide more detail about | 498 // CheckCandidate2, except that it will provide more detail about |
521 // what didn't match. | 499 // what didn't match. |
522 void ExpectCandidate2(const Result& expected) { | 500 void ExpectCandidate2(const Result& expected) { |
523 if (CheckCandidate2(expected)) { | 501 if (CheckCandidate2(expected)) { |
524 return; | 502 return; |
525 } | 503 } |
526 | 504 |
527 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); | 505 const std::string& local_type = LocalCandidate(ep2_ch1())->type(); |
528 const std::string& local_proto = LocalCandidate(ep2_ch1())->protocol(); | 506 const std::string& local_protocol = LocalCandidate(ep2_ch1())->protocol(); |
529 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); | 507 const std::string& remote_type = RemoteCandidate(ep2_ch1())->type(); |
530 const std::string& remote_proto = RemoteCandidate(ep2_ch1())->protocol(); | 508 const std::string& remote_protocol = RemoteCandidate(ep2_ch1())->protocol(); |
531 EXPECT_EQ(expected.local_type2, local_type); | 509 EXPECT_EQ(expected.controlled_type, local_type); |
532 EXPECT_EQ(expected.remote_type2, remote_type); | 510 EXPECT_EQ(expected.controlling_type, remote_type); |
533 EXPECT_EQ(expected.local_proto2, local_proto); | 511 EXPECT_EQ(expected.controlled_protocol, local_protocol); |
534 EXPECT_EQ(expected.remote_proto2, remote_proto); | 512 EXPECT_EQ(expected.controlling_protocol, remote_protocol); |
535 } | 513 } |
536 | 514 |
537 void Test(const Result& expected) { | 515 void Test(const Result& expected) { |
538 int64_t connect_start = rtc::TimeMillis(); | 516 int64_t connect_start = rtc::TimeMillis(); |
539 int64_t connect_time; | 517 int64_t connect_time; |
540 | 518 |
541 // Create the channels and wait for them to connect. | 519 // Create the channels and wait for them to connect. |
542 CreateChannels(1); | 520 CreateChannels(1); |
543 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && | 521 EXPECT_TRUE_WAIT_MARGIN(ep1_ch1() != NULL && |
544 ep2_ch1() != NULL && | 522 ep2_ch1() != NULL && |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 Endpoint ep1_; | 850 Endpoint ep1_; |
873 Endpoint ep2_; | 851 Endpoint ep2_; |
874 RemoteIceCredentialSource remote_ice_credential_source_ = FROM_CANDIDATE; | 852 RemoteIceCredentialSource remote_ice_credential_source_ = FROM_CANDIDATE; |
875 bool force_relay_; | 853 bool force_relay_; |
876 int selected_candidate_pair_switches_ = 0; | 854 int selected_candidate_pair_switches_ = 0; |
877 | 855 |
878 bool nominated_ = false; | 856 bool nominated_ = false; |
879 }; | 857 }; |
880 | 858 |
881 // The tests have only a few outcomes, which we predefine. | 859 // The tests have only a few outcomes, which we predefine. |
882 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 860 const P2PTransportChannelTestBase::Result |
883 kLocalUdpToLocalUdp("local", "udp", "local", "udp", | 861 P2PTransportChannelTestBase::kLocalUdpToLocalUdp("local", |
884 "local", "udp", "local", "udp", 1000); | 862 "udp", |
885 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 863 "local", |
886 kLocalUdpToStunUdp("local", "udp", "stun", "udp", | 864 "udp", |
887 "local", "udp", "stun", "udp", 1000); | 865 1000); |
888 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 866 const P2PTransportChannelTestBase::Result |
889 kLocalUdpToPrflxUdp("local", "udp", "prflx", "udp", | 867 P2PTransportChannelTestBase::kLocalUdpToStunUdp("local", |
890 "prflx", "udp", "local", "udp", 1000); | 868 "udp", |
891 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 869 "stun", |
892 kPrflxUdpToLocalUdp("prflx", "udp", "local", "udp", | 870 "udp", |
893 "local", "udp", "prflx", "udp", 1000); | 871 1000); |
894 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 872 const P2PTransportChannelTestBase::Result |
895 kStunUdpToLocalUdp("stun", "udp", "local", "udp", | 873 P2PTransportChannelTestBase::kLocalUdpToPrflxUdp("local", |
896 "local", "udp", "stun", "udp", 1000); | 874 "udp", |
897 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 875 "prflx", |
898 kStunUdpToStunUdp("stun", "udp", "stun", "udp", | 876 "udp", |
899 "stun", "udp", "stun", "udp", 1000); | 877 1000); |
900 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 878 const P2PTransportChannelTestBase::Result |
901 kPrflxUdpToStunUdp("prflx", "udp", "stun", "udp", | 879 P2PTransportChannelTestBase::kPrflxUdpToLocalUdp("prflx", |
902 "local", "udp", "prflx", "udp", 1000); | 880 "udp", |
903 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 881 "local", |
904 kLocalUdpToRelayUdp("local", "udp", "relay", "udp", | 882 "udp", |
905 "relay", "udp", "local", "udp", 2000); | 883 1000); |
906 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 884 const P2PTransportChannelTestBase::Result |
907 kPrflxUdpToRelayUdp("prflx", "udp", "relay", "udp", | 885 P2PTransportChannelTestBase::kStunUdpToLocalUdp("stun", |
908 "relay", "udp", "prflx", "udp", 2000); | 886 "udp", |
909 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 887 "local", |
910 kLocalTcpToLocalTcp("local", "tcp", "local", "tcp", | 888 "udp", |
911 "local", "tcp", "local", "tcp", 3000); | 889 1000); |
912 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 890 const P2PTransportChannelTestBase::Result |
913 kLocalTcpToPrflxTcp("local", "tcp", "prflx", "tcp", | 891 P2PTransportChannelTestBase::kStunUdpToStunUdp("stun", |
914 "prflx", "tcp", "local", "tcp", 3000); | 892 "udp", |
915 const P2PTransportChannelTestBase::Result P2PTransportChannelTestBase:: | 893 "stun", |
916 kPrflxTcpToLocalTcp("prflx", "tcp", "local", "tcp", | 894 "udp", |
917 "local", "tcp", "prflx", "tcp", 3000); | 895 1000); |
| 896 const P2PTransportChannelTestBase::Result |
| 897 P2PTransportChannelTestBase::kStunUdpToPrflxUdp("stun", |
| 898 "udp", |
| 899 "prflx", |
| 900 "udp", |
| 901 1000); |
| 902 const P2PTransportChannelTestBase::Result |
| 903 P2PTransportChannelTestBase::kPrflxUdpToStunUdp("prflx", |
| 904 "udp", |
| 905 "stun", |
| 906 "udp", |
| 907 1000); |
| 908 const P2PTransportChannelTestBase::Result |
| 909 P2PTransportChannelTestBase::kLocalUdpToRelayUdp("local", |
| 910 "udp", |
| 911 "relay", |
| 912 "udp", |
| 913 2000); |
| 914 const P2PTransportChannelTestBase::Result |
| 915 P2PTransportChannelTestBase::kPrflxUdpToRelayUdp("prflx", |
| 916 "udp", |
| 917 "relay", |
| 918 "udp", |
| 919 2000); |
| 920 const P2PTransportChannelTestBase::Result |
| 921 P2PTransportChannelTestBase::kRelayUdpToPrflxUdp("relay", |
| 922 "udp", |
| 923 "prflx", |
| 924 "udp", |
| 925 2000); |
| 926 const P2PTransportChannelTestBase::Result |
| 927 P2PTransportChannelTestBase::kLocalTcpToLocalTcp("local", |
| 928 "tcp", |
| 929 "local", |
| 930 "tcp", |
| 931 3000); |
| 932 const P2PTransportChannelTestBase::Result |
| 933 P2PTransportChannelTestBase::kLocalTcpToPrflxTcp("local", |
| 934 "tcp", |
| 935 "prflx", |
| 936 "tcp", |
| 937 3000); |
| 938 const P2PTransportChannelTestBase::Result |
| 939 P2PTransportChannelTestBase::kPrflxTcpToLocalTcp("prflx", |
| 940 "tcp", |
| 941 "local", |
| 942 "tcp", |
| 943 3000); |
918 | 944 |
919 // Test the matrix of all the connectivity types we expect to see in the wild. | 945 // Test the matrix of all the connectivity types we expect to see in the wild. |
920 // Just test every combination of the configs in the Config enum. | 946 // Just test every combination of the configs in the Config enum. |
921 class P2PTransportChannelTest : public P2PTransportChannelTestBase { | 947 class P2PTransportChannelTest : public P2PTransportChannelTestBase { |
922 protected: | 948 protected: |
923 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; | 949 static const Result* kMatrix[NUM_CONFIGS][NUM_CONFIGS]; |
924 void ConfigureEndpoints(Config config1, | 950 void ConfigureEndpoints(Config config1, |
925 Config config2, | 951 Config config2, |
926 int allocator_flags1, | 952 int allocator_flags1, |
927 int allocator_flags2) { | 953 int allocator_flags2) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1020 } | 1046 } |
1021 }; | 1047 }; |
1022 | 1048 |
1023 // Shorthands for use in the test matrix. | 1049 // Shorthands for use in the test matrix. |
1024 #define LULU &kLocalUdpToLocalUdp | 1050 #define LULU &kLocalUdpToLocalUdp |
1025 #define LUSU &kLocalUdpToStunUdp | 1051 #define LUSU &kLocalUdpToStunUdp |
1026 #define LUPU &kLocalUdpToPrflxUdp | 1052 #define LUPU &kLocalUdpToPrflxUdp |
1027 #define PULU &kPrflxUdpToLocalUdp | 1053 #define PULU &kPrflxUdpToLocalUdp |
1028 #define SULU &kStunUdpToLocalUdp | 1054 #define SULU &kStunUdpToLocalUdp |
1029 #define SUSU &kStunUdpToStunUdp | 1055 #define SUSU &kStunUdpToStunUdp |
| 1056 #define SUPU &kStunUdpToPrflxUdp |
1030 #define PUSU &kPrflxUdpToStunUdp | 1057 #define PUSU &kPrflxUdpToStunUdp |
1031 #define LURU &kLocalUdpToRelayUdp | 1058 #define LURU &kLocalUdpToRelayUdp |
1032 #define PURU &kPrflxUdpToRelayUdp | 1059 #define PURU &kPrflxUdpToRelayUdp |
| 1060 #define RUPU &kRelayUdpToPrflxUdp |
1033 #define LTLT &kLocalTcpToLocalTcp | 1061 #define LTLT &kLocalTcpToLocalTcp |
1034 #define LTPT &kLocalTcpToPrflxTcp | 1062 #define LTPT &kLocalTcpToPrflxTcp |
1035 #define PTLT &kPrflxTcpToLocalTcp | 1063 #define PTLT &kPrflxTcpToLocalTcp |
1036 // TODO: Enable these once TestRelayServer can accept external TCP. | 1064 // TODO: Enable these once TestRelayServer can accept external TCP. |
1037 #define LTRT NULL | 1065 #define LTRT NULL |
1038 #define LSRS NULL | 1066 #define LSRS NULL |
1039 | 1067 |
1040 // Test matrix. Originator behavior defined by rows, receiever by columns. | 1068 // Test matrix. Originator behavior defined by rows, receiever by columns. |
1041 | 1069 |
1042 // TODO: Fix NULLs caused by lack of TCP support in NATSocket. | 1070 // TODO: Fix NULLs caused by lack of TCP support in NATSocket. |
1043 // TODO: Fix NULLs caused by no HTTP proxy support. | 1071 // TODO: Fix NULLs caused by no HTTP proxy support. |
1044 // TODO: Rearrange rows/columns from best to worst. | 1072 // TODO: Rearrange rows/columns from best to worst. |
1045 const P2PTransportChannelTest::Result* P2PTransportChannelTest::kMatrix[NUM_CONF
IGS][NUM_CONFIGS] = { | 1073 const P2PTransportChannelTest::Result* |
1046 // OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP PRXH PR
XS | 1074 P2PTransportChannelTest::kMatrix[NUM_CONFIGS][NUM_CONFIGS] = { |
1047 /*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, PTLT, LTPT, LSRS, NULL, LT
PT}, | 1075 // OPEN CONE ADDR PORT SYMM 2CON SCON !UDP !TCP HTTP PRXH PRXS |
1048 /*CO*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, NULL, NULL, LSRS, NULL, LT
RT}, | 1076 /*OP*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, LTPT, LTPT, LSRS, NULL, LTPT}, |
1049 /*AD*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, NULL, NULL, LSRS, NULL, LT
RT}, | 1077 /*CO*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LTRT}, |
1050 /*PO*/ {LULU, LUSU, LUSU, LUSU, LURU, LUSU, LURU, NULL, NULL, LSRS, NULL, LT
RT}, | 1078 /*AD*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LTRT}, |
1051 /*SY*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LT
RT}, | 1079 /*PO*/ {SULU, SUSU, SUSU, SUSU, RUPU, SUSU, RUPU, NULL, NULL, LSRS, NULL, LTRT}, |
1052 /*2C*/ {LULU, LUSU, LUSU, LUSU, LUPU, LUSU, LUPU, NULL, NULL, LSRS, NULL, LT
RT}, | 1080 /*SY*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, |
1053 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LT
RT}, | 1081 /*2C*/ {SULU, SUSU, SUSU, SUSU, SUPU, SUSU, SUPU, NULL, NULL, LSRS, NULL, LTRT}, |
1054 /*!U*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTPT, LSRS, NULL, LT
RT}, | 1082 /*SC*/ {PULU, PUSU, PUSU, PURU, PURU, PUSU, PURU, NULL, NULL, LSRS, NULL, LTRT}, |
1055 /*!T*/ {LTRT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LT
RT}, | 1083 /*!U*/ {LTPT, NULL, NULL, NULL, NULL, NULL, NULL, LTPT, LTPT, LSRS, NULL, LTRT}, |
1056 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LS
RS}, | 1084 /*!T*/ {PTLT, NULL, NULL, NULL, NULL, NULL, NULL, PTLT, LTRT, LSRS, NULL, LTRT}, |
1057 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NU
LL}, | 1085 /*HT*/ {LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, LSRS, NULL, LSRS}, |
1058 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LT
RT}, | 1086 /*PR*/ {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}, |
| 1087 /*PR*/ {LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LTRT, LSRS, NULL, LTRT}, |
1059 }; | 1088 }; |
1060 | 1089 |
1061 // The actual tests that exercise all the various configurations. | 1090 // The actual tests that exercise all the various configurations. |
1062 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE | 1091 // Test names are of the form P2PTransportChannelTest_TestOPENToNAT_FULL_CONE |
1063 #define P2P_TEST_DECLARATION(x, y, z) \ | 1092 #define P2P_TEST_DECLARATION(x, y, z) \ |
1064 TEST_F(P2PTransportChannelTest, z##Test##x##To##y) { \ | 1093 TEST_F(P2PTransportChannelTest, z##Test##x##To##y) { \ |
1065 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ | 1094 ConfigureEndpoints(x, y, PORTALLOCATOR_ENABLE_SHARED_SOCKET, \ |
1066 PORTALLOCATOR_ENABLE_SHARED_SOCKET); \ | 1095 PORTALLOCATOR_ENABLE_SHARED_SOCKET); \ |
1067 if (kMatrix[x][y] != NULL) \ | 1096 if (kMatrix[x][y] != NULL) \ |
1068 Test(*kMatrix[x][y]); \ | 1097 Test(*kMatrix[x][y]); \ |
1069 else \ | 1098 else \ |
1070 LOG(LS_WARNING) << "Not yet implemented"; \ | 1099 LOG(LS_WARNING) << "Not yet implemented"; \ |
1071 } | 1100 } |
1072 | 1101 |
1073 #define P2P_TEST(x, y) \ | 1102 #define P2P_TEST(x, y) \ |
1074 P2P_TEST_DECLARATION(x, y,) | 1103 P2P_TEST_DECLARATION(x, y,) |
1075 | 1104 |
1076 #define FLAKY_P2P_TEST(x, y) \ | 1105 #define P2P_TEST_SET(x) \ |
1077 P2P_TEST_DECLARATION(x, y, DISABLED_) | 1106 P2P_TEST(x, OPEN) \ |
1078 | 1107 P2P_TEST(x, NAT_FULL_CONE) \ |
1079 // TODO(holmer): Disabled due to randomly failing on webrtc buildbots. | 1108 P2P_TEST(x, NAT_ADDR_RESTRICTED) \ |
1080 // Issue: webrtc/2383 | 1109 P2P_TEST(x, NAT_PORT_RESTRICTED) \ |
1081 #define P2P_TEST_SET(x) \ | 1110 P2P_TEST(x, NAT_SYMMETRIC) \ |
1082 P2P_TEST(x, OPEN) \ | 1111 P2P_TEST(x, NAT_DOUBLE_CONE) \ |
1083 FLAKY_P2P_TEST(x, NAT_FULL_CONE) \ | 1112 P2P_TEST(x, NAT_SYMMETRIC_THEN_CONE) \ |
1084 FLAKY_P2P_TEST(x, NAT_ADDR_RESTRICTED) \ | 1113 P2P_TEST(x, BLOCK_UDP) \ |
1085 FLAKY_P2P_TEST(x, NAT_PORT_RESTRICTED) \ | 1114 P2P_TEST(x, BLOCK_UDP_AND_INCOMING_TCP) \ |
1086 P2P_TEST(x, NAT_SYMMETRIC) \ | |
1087 FLAKY_P2P_TEST(x, NAT_DOUBLE_CONE) \ | |
1088 P2P_TEST(x, NAT_SYMMETRIC_THEN_CONE) \ | |
1089 P2P_TEST(x, BLOCK_UDP) \ | |
1090 P2P_TEST(x, BLOCK_UDP_AND_INCOMING_TCP) \ | |
1091 P2P_TEST(x, BLOCK_ALL_BUT_OUTGOING_HTTP) \ | 1115 P2P_TEST(x, BLOCK_ALL_BUT_OUTGOING_HTTP) \ |
1092 P2P_TEST(x, PROXY_HTTPS) \ | 1116 P2P_TEST(x, PROXY_HTTPS) \ |
1093 P2P_TEST(x, PROXY_SOCKS) | 1117 P2P_TEST(x, PROXY_SOCKS) |
1094 | 1118 |
1095 P2P_TEST_SET(OPEN) | 1119 P2P_TEST_SET(OPEN) |
1096 P2P_TEST_SET(NAT_FULL_CONE) | 1120 P2P_TEST_SET(NAT_FULL_CONE) |
1097 P2P_TEST_SET(NAT_ADDR_RESTRICTED) | 1121 P2P_TEST_SET(NAT_ADDR_RESTRICTED) |
1098 P2P_TEST_SET(NAT_PORT_RESTRICTED) | 1122 P2P_TEST_SET(NAT_PORT_RESTRICTED) |
1099 P2P_TEST_SET(NAT_SYMMETRIC) | 1123 P2P_TEST_SET(NAT_SYMMETRIC) |
1100 P2P_TEST_SET(NAT_DOUBLE_CONE) | 1124 P2P_TEST_SET(NAT_DOUBLE_CONE) |
1101 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) | 1125 P2P_TEST_SET(NAT_SYMMETRIC_THEN_CONE) |
1102 P2P_TEST_SET(BLOCK_UDP) | 1126 P2P_TEST_SET(BLOCK_UDP) |
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1833 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); | 1857 AddAddress(endpoint, kCascadedPrivateAddrs[endpoint]); |
1834 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], | 1858 nat->AddTranslator(kPrivateAddrs[endpoint], kCascadedNatAddrs[endpoint], |
1835 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( | 1859 static_cast<rtc::NATType>(config - NAT_FULL_CONE))->AddClient( |
1836 kCascadedPrivateAddrs[endpoint]); | 1860 kCascadedPrivateAddrs[endpoint]); |
1837 } | 1861 } |
1838 } | 1862 } |
1839 }; | 1863 }; |
1840 | 1864 |
1841 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { | 1865 TEST_F(P2PTransportChannelSameNatTest, TestConesBehindSameCone) { |
1842 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); | 1866 ConfigureEndpoints(NAT_FULL_CONE, NAT_FULL_CONE, NAT_FULL_CONE); |
1843 Test(P2PTransportChannelTestBase::Result( | 1867 Test( |
1844 "prflx", "udp", "stun", "udp", "stun", "udp", "prflx", "udp", 1000)); | 1868 P2PTransportChannelTestBase::Result("prflx", "udp", "stun", "udp", 1000)); |
1845 } | 1869 } |
1846 | 1870 |
1847 // Test what happens when we have multiple available pathways. | 1871 // Test what happens when we have multiple available pathways. |
1848 // In the future we will try different RTTs and configs for the different | 1872 // In the future we will try different RTTs and configs for the different |
1849 // interfaces, so that we can simulate a user with Ethernet and VPN networks. | 1873 // interfaces, so that we can simulate a user with Ethernet and VPN networks. |
1850 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { | 1874 class P2PTransportChannelMultihomedTest : public P2PTransportChannelTestBase { |
1851 public: | 1875 public: |
1852 const cricket::Connection* GetConnectionWithRemoteAddress( | 1876 const cricket::Connection* GetConnectionWithRemoteAddress( |
1853 cricket::P2PTransportChannel* channel, | 1877 cricket::P2PTransportChannel* channel, |
1854 const SocketAddress& address) { | 1878 const SocketAddress& address) { |
(...skipping 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3954 | 3978 |
3955 // TCP Relay/Relay is the next. | 3979 // TCP Relay/Relay is the next. |
3956 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, | 3980 VerifyNextPingableConnection(RELAY_PORT_TYPE, RELAY_PORT_TYPE, |
3957 TCP_PROTOCOL_NAME); | 3981 TCP_PROTOCOL_NAME); |
3958 | 3982 |
3959 // Finally, Local/Relay will be pinged. | 3983 // Finally, Local/Relay will be pinged. |
3960 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); | 3984 VerifyNextPingableConnection(LOCAL_PORT_TYPE, RELAY_PORT_TYPE); |
3961 } | 3985 } |
3962 | 3986 |
3963 } // namespace cricket { | 3987 } // namespace cricket { |
OLD | NEW |