henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2004 The WebRTC Project Authors. All rights reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 11 | #include "rtc_base/physical_socket_server.h" |
| 12 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 13 | #include <signal.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 14 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 15 | #include <algorithm> |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 16 | #include <memory> |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 17 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 18 | #include "rtc_base/gunit.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 19 | #include "rtc_base/ip_address.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "rtc_base/logging.h" |
Mirko Bonadei | e5f4c6b | 2021-01-15 10:41:01 +0100 | [diff] [blame] | 21 | #include "rtc_base/net_helpers.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 22 | #include "rtc_base/network_monitor.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 23 | #include "rtc_base/socket_unittest.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 24 | #include "rtc_base/test_utils.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "rtc_base/thread.h" |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 26 | #include "test/gtest.h" |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 27 | |
| 28 | namespace rtc { |
| 29 | |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 30 | #define MAYBE_SKIP_IPV4 \ |
| 31 | if (!HasIPv4Enabled()) { \ |
| 32 | RTC_LOG(LS_INFO) << "No IPv4... skipping"; \ |
| 33 | return; \ |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 34 | } |
| 35 | |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 36 | #define MAYBE_SKIP_IPV6 \ |
| 37 | if (!HasIPv6Enabled()) { \ |
| 38 | RTC_LOG(LS_INFO) << "No IPv6... skipping"; \ |
| 39 | return; \ |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 40 | } |
| 41 | |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 42 | class PhysicalSocketTest; |
| 43 | |
| 44 | class FakeSocketDispatcher : public SocketDispatcher { |
| 45 | public: |
| 46 | explicit FakeSocketDispatcher(PhysicalSocketServer* ss) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 47 | : SocketDispatcher(ss) {} |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 48 | |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 49 | FakeSocketDispatcher(SOCKET s, PhysicalSocketServer* ss) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 50 | : SocketDispatcher(s, ss) {} |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 51 | |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 52 | protected: |
| 53 | SOCKET DoAccept(SOCKET socket, sockaddr* addr, socklen_t* addrlen) override; |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 54 | int DoSend(SOCKET socket, const char* buf, int len, int flags) override; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 55 | int DoSendTo(SOCKET socket, |
| 56 | const char* buf, |
| 57 | int len, |
| 58 | int flags, |
| 59 | const struct sockaddr* dest_addr, |
| 60 | socklen_t addrlen) override; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 61 | }; |
| 62 | |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 63 | class FakePhysicalSocketServer : public PhysicalSocketServer { |
| 64 | public: |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 65 | explicit FakePhysicalSocketServer(PhysicalSocketTest* test) : test_(test) {} |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 66 | |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 67 | Socket* CreateSocket(int family, int type) override { |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 68 | SocketDispatcher* dispatcher = new FakeSocketDispatcher(this); |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 69 | if (!dispatcher->Create(family, type)) { |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 70 | delete dispatcher; |
| 71 | return nullptr; |
| 72 | } |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 73 | return dispatcher; |
| 74 | } |
| 75 | |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 76 | Socket* WrapSocket(SOCKET s) override { |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 77 | SocketDispatcher* dispatcher = new FakeSocketDispatcher(s, this); |
| 78 | if (!dispatcher->Initialize()) { |
| 79 | delete dispatcher; |
| 80 | return nullptr; |
| 81 | } |
| 82 | return dispatcher; |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 83 | } |
| 84 | |
| 85 | PhysicalSocketTest* GetTest() const { return test_; } |
| 86 | |
| 87 | private: |
| 88 | PhysicalSocketTest* test_; |
| 89 | }; |
| 90 | |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 91 | class FakeNetworkBinder : public NetworkBinderInterface { |
| 92 | public: |
| 93 | NetworkBindingResult BindSocketToNetwork(int, const IPAddress&) override { |
deadbeef | 9ffa13f | 2017-02-21 16:18:00 -0800 | [diff] [blame] | 94 | ++num_binds_; |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 95 | return result_; |
| 96 | } |
| 97 | |
| 98 | void set_result(NetworkBindingResult result) { result_ = result; } |
| 99 | |
deadbeef | 9ffa13f | 2017-02-21 16:18:00 -0800 | [diff] [blame] | 100 | int num_binds() { return num_binds_; } |
| 101 | |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 102 | private: |
| 103 | NetworkBindingResult result_ = NetworkBindingResult::SUCCESS; |
deadbeef | 9ffa13f | 2017-02-21 16:18:00 -0800 | [diff] [blame] | 104 | int num_binds_ = 0; |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 105 | }; |
| 106 | |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 107 | class PhysicalSocketTest : public SocketTest { |
| 108 | public: |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 109 | // Set flag to simluate failures when calling "::accept" on a Socket. |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 110 | void SetFailAccept(bool fail) { fail_accept_ = fail; } |
| 111 | bool FailAccept() const { return fail_accept_; } |
| 112 | |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 113 | // Maximum size to ::send to a socket. Set to < 0 to disable limiting. |
| 114 | void SetMaxSendSize(int max_size) { max_send_size_ = max_size; } |
| 115 | int MaxSendSize() const { return max_send_size_; } |
| 116 | |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 117 | protected: |
| 118 | PhysicalSocketTest() |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 119 | : SocketTest(&server_), |
| 120 | server_(this), |
| 121 | thread_(&server_), |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 122 | fail_accept_(false), |
| 123 | max_send_size_(-1) {} |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 124 | |
| 125 | void ConnectInternalAcceptError(const IPAddress& loopback); |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 126 | void WritableAfterPartialWrite(const IPAddress& loopback); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 127 | |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 128 | FakePhysicalSocketServer server_; |
nisse | 7eaa4ea | 2017-05-08 05:25:41 -0700 | [diff] [blame] | 129 | rtc::AutoSocketServerThread thread_; |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 130 | bool fail_accept_; |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 131 | int max_send_size_; |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 132 | }; |
| 133 | |
| 134 | SOCKET FakeSocketDispatcher::DoAccept(SOCKET socket, |
| 135 | sockaddr* addr, |
| 136 | socklen_t* addrlen) { |
| 137 | FakePhysicalSocketServer* ss = |
| 138 | static_cast<FakePhysicalSocketServer*>(socketserver()); |
| 139 | if (ss->GetTest()->FailAccept()) { |
| 140 | return INVALID_SOCKET; |
| 141 | } |
| 142 | |
| 143 | return SocketDispatcher::DoAccept(socket, addr, addrlen); |
| 144 | } |
| 145 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 146 | int FakeSocketDispatcher::DoSend(SOCKET socket, |
| 147 | const char* buf, |
| 148 | int len, |
| 149 | int flags) { |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 150 | FakePhysicalSocketServer* ss = |
| 151 | static_cast<FakePhysicalSocketServer*>(socketserver()); |
| 152 | if (ss->GetTest()->MaxSendSize() >= 0) { |
| 153 | len = std::min(len, ss->GetTest()->MaxSendSize()); |
| 154 | } |
| 155 | |
| 156 | return SocketDispatcher::DoSend(socket, buf, len, flags); |
| 157 | } |
| 158 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 159 | int FakeSocketDispatcher::DoSendTo(SOCKET socket, |
| 160 | const char* buf, |
| 161 | int len, |
| 162 | int flags, |
| 163 | const struct sockaddr* dest_addr, |
| 164 | socklen_t addrlen) { |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 165 | FakePhysicalSocketServer* ss = |
| 166 | static_cast<FakePhysicalSocketServer*>(socketserver()); |
| 167 | if (ss->GetTest()->MaxSendSize() >= 0) { |
| 168 | len = std::min(len, ss->GetTest()->MaxSendSize()); |
| 169 | } |
| 170 | |
| 171 | return SocketDispatcher::DoSendTo(socket, buf, len, flags, dest_addr, |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 172 | addrlen); |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 173 | } |
| 174 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 175 | TEST_F(PhysicalSocketTest, TestConnectIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 176 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 177 | SocketTest::TestConnectIPv4(); |
| 178 | } |
| 179 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 180 | TEST_F(PhysicalSocketTest, TestConnectIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 181 | SocketTest::TestConnectIPv6(); |
| 182 | } |
| 183 | |
| 184 | TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 185 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 186 | SocketTest::TestConnectWithDnsLookupIPv4(); |
| 187 | } |
| 188 | |
| 189 | TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupIPv6) { |
| 190 | SocketTest::TestConnectWithDnsLookupIPv6(); |
| 191 | } |
| 192 | |
| 193 | TEST_F(PhysicalSocketTest, TestConnectFailIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 194 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 195 | SocketTest::TestConnectFailIPv4(); |
| 196 | } |
| 197 | |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 198 | void PhysicalSocketTest::ConnectInternalAcceptError(const IPAddress& loopback) { |
kwiberg | d0d8148 | 2017-04-18 03:18:22 -0700 | [diff] [blame] | 199 | webrtc::testing::StreamSink sink; |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 200 | SocketAddress accept_addr; |
| 201 | |
| 202 | // Create two clients. |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 203 | std::unique_ptr<Socket> client1( |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 204 | server_.CreateSocket(loopback.family(), SOCK_STREAM)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 205 | sink.Monitor(client1.get()); |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 206 | EXPECT_EQ(Socket::CS_CLOSED, client1->GetState()); |
Jonas Olsson | abbe841 | 2018-04-03 13:40:05 +0200 | [diff] [blame] | 207 | EXPECT_TRUE(IsUnspecOrEmptyIP(client1->GetLocalAddress().ipaddr())); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 208 | |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 209 | std::unique_ptr<Socket> client2( |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 210 | server_.CreateSocket(loopback.family(), SOCK_STREAM)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 211 | sink.Monitor(client2.get()); |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 212 | EXPECT_EQ(Socket::CS_CLOSED, client2->GetState()); |
Jonas Olsson | abbe841 | 2018-04-03 13:40:05 +0200 | [diff] [blame] | 213 | EXPECT_TRUE(IsUnspecOrEmptyIP(client2->GetLocalAddress().ipaddr())); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 214 | |
| 215 | // Create server and listen. |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 216 | std::unique_ptr<Socket> server( |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 217 | server_.CreateSocket(loopback.family(), SOCK_STREAM)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 218 | sink.Monitor(server.get()); |
| 219 | EXPECT_EQ(0, server->Bind(SocketAddress(loopback, 0))); |
| 220 | EXPECT_EQ(0, server->Listen(5)); |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 221 | EXPECT_EQ(Socket::CS_CONNECTING, server->GetState()); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 222 | |
| 223 | // Ensure no pending server connections, since we haven't done anything yet. |
kwiberg | d0d8148 | 2017-04-18 03:18:22 -0700 | [diff] [blame] | 224 | EXPECT_FALSE(sink.Check(server.get(), webrtc::testing::SSE_READ)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 225 | EXPECT_TRUE(nullptr == server->Accept(&accept_addr)); |
| 226 | EXPECT_TRUE(accept_addr.IsNil()); |
| 227 | |
| 228 | // Attempt first connect to listening socket. |
| 229 | EXPECT_EQ(0, client1->Connect(server->GetLocalAddress())); |
| 230 | EXPECT_FALSE(client1->GetLocalAddress().IsNil()); |
| 231 | EXPECT_NE(server->GetLocalAddress(), client1->GetLocalAddress()); |
| 232 | |
| 233 | // Client is connecting, outcome not yet determined. |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 234 | EXPECT_EQ(Socket::CS_CONNECTING, client1->GetState()); |
kwiberg | d0d8148 | 2017-04-18 03:18:22 -0700 | [diff] [blame] | 235 | EXPECT_FALSE(sink.Check(client1.get(), webrtc::testing::SSE_OPEN)); |
| 236 | EXPECT_FALSE(sink.Check(client1.get(), webrtc::testing::SSE_CLOSE)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 237 | |
| 238 | // Server has pending connection, try to accept it (will fail). |
kwiberg | d0d8148 | 2017-04-18 03:18:22 -0700 | [diff] [blame] | 239 | EXPECT_TRUE_WAIT((sink.Check(server.get(), webrtc::testing::SSE_READ)), |
| 240 | kTimeout); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 241 | // Simulate "::accept" returning an error. |
| 242 | SetFailAccept(true); |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 243 | std::unique_ptr<Socket> accepted(server->Accept(&accept_addr)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 244 | EXPECT_FALSE(accepted); |
| 245 | ASSERT_TRUE(accept_addr.IsNil()); |
| 246 | |
| 247 | // Ensure no more pending server connections. |
kwiberg | d0d8148 | 2017-04-18 03:18:22 -0700 | [diff] [blame] | 248 | EXPECT_FALSE(sink.Check(server.get(), webrtc::testing::SSE_READ)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 249 | EXPECT_TRUE(nullptr == server->Accept(&accept_addr)); |
| 250 | EXPECT_TRUE(accept_addr.IsNil()); |
| 251 | |
| 252 | // Attempt second connect to listening socket. |
| 253 | EXPECT_EQ(0, client2->Connect(server->GetLocalAddress())); |
| 254 | EXPECT_FALSE(client2->GetLocalAddress().IsNil()); |
| 255 | EXPECT_NE(server->GetLocalAddress(), client2->GetLocalAddress()); |
| 256 | |
| 257 | // Client is connecting, outcome not yet determined. |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 258 | EXPECT_EQ(Socket::CS_CONNECTING, client2->GetState()); |
kwiberg | d0d8148 | 2017-04-18 03:18:22 -0700 | [diff] [blame] | 259 | EXPECT_FALSE(sink.Check(client2.get(), webrtc::testing::SSE_OPEN)); |
| 260 | EXPECT_FALSE(sink.Check(client2.get(), webrtc::testing::SSE_CLOSE)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 261 | |
| 262 | // Server has pending connection, try to accept it (will succeed). |
kwiberg | d0d8148 | 2017-04-18 03:18:22 -0700 | [diff] [blame] | 263 | EXPECT_TRUE_WAIT((sink.Check(server.get(), webrtc::testing::SSE_READ)), |
| 264 | kTimeout); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 265 | SetFailAccept(false); |
Niels Möller | d0b8879 | 2021-08-12 10:32:30 +0200 | [diff] [blame] | 266 | std::unique_ptr<Socket> accepted2(server->Accept(&accept_addr)); |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 267 | ASSERT_TRUE(accepted2); |
| 268 | EXPECT_FALSE(accept_addr.IsNil()); |
| 269 | EXPECT_EQ(accepted2->GetRemoteAddress(), accept_addr); |
| 270 | } |
| 271 | |
| 272 | TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 273 | MAYBE_SKIP_IPV4; |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 274 | ConnectInternalAcceptError(kIPv4Loopback); |
| 275 | } |
| 276 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 277 | TEST_F(PhysicalSocketTest, TestConnectAcceptErrorIPv6) { |
| 278 | MAYBE_SKIP_IPV6; |
jbauch | 095ae15 | 2015-12-18 01:39:55 -0800 | [diff] [blame] | 279 | ConnectInternalAcceptError(kIPv6Loopback); |
| 280 | } |
| 281 | |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 282 | void PhysicalSocketTest::WritableAfterPartialWrite(const IPAddress& loopback) { |
| 283 | // Simulate a really small maximum send size. |
| 284 | const int kMaxSendSize = 128; |
| 285 | SetMaxSendSize(kMaxSendSize); |
| 286 | |
| 287 | // Run the default send/receive socket tests with a smaller amount of data |
| 288 | // to avoid long running times due to the small maximum send size. |
| 289 | const size_t kDataSize = 128 * 1024; |
| 290 | TcpInternal(loopback, kDataSize, kMaxSendSize); |
| 291 | } |
| 292 | |
danilchap | b7b9dca | 2016-08-05 05:55:43 -0700 | [diff] [blame] | 293 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 |
| 294 | #if defined(WEBRTC_WIN) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 295 | #define MAYBE_TestWritableAfterPartialWriteIPv4 \ |
| 296 | DISABLED_TestWritableAfterPartialWriteIPv4 |
danilchap | b7b9dca | 2016-08-05 05:55:43 -0700 | [diff] [blame] | 297 | #else |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 298 | #define MAYBE_TestWritableAfterPartialWriteIPv4 \ |
| 299 | TestWritableAfterPartialWriteIPv4 |
danilchap | b7b9dca | 2016-08-05 05:55:43 -0700 | [diff] [blame] | 300 | #endif |
| 301 | TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 302 | MAYBE_SKIP_IPV4; |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 303 | WritableAfterPartialWrite(kIPv4Loopback); |
| 304 | } |
| 305 | |
danilchap | b7b9dca | 2016-08-05 05:55:43 -0700 | [diff] [blame] | 306 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 |
| 307 | #if defined(WEBRTC_WIN) |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 308 | #define MAYBE_TestWritableAfterPartialWriteIPv6 \ |
| 309 | DISABLED_TestWritableAfterPartialWriteIPv6 |
danilchap | b7b9dca | 2016-08-05 05:55:43 -0700 | [diff] [blame] | 310 | #else |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 311 | #define MAYBE_TestWritableAfterPartialWriteIPv6 \ |
| 312 | TestWritableAfterPartialWriteIPv6 |
danilchap | b7b9dca | 2016-08-05 05:55:43 -0700 | [diff] [blame] | 313 | #endif |
| 314 | TEST_F(PhysicalSocketTest, MAYBE_TestWritableAfterPartialWriteIPv6) { |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 315 | MAYBE_SKIP_IPV6; |
jbauch | f2a2bf4 | 2016-02-03 16:45:32 -0800 | [diff] [blame] | 316 | WritableAfterPartialWrite(kIPv6Loopback); |
| 317 | } |
| 318 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 319 | TEST_F(PhysicalSocketTest, TestConnectFailIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 320 | SocketTest::TestConnectFailIPv6(); |
| 321 | } |
| 322 | |
| 323 | TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 324 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 325 | SocketTest::TestConnectWithDnsLookupFailIPv4(); |
| 326 | } |
| 327 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 328 | TEST_F(PhysicalSocketTest, TestConnectWithDnsLookupFailIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 329 | SocketTest::TestConnectWithDnsLookupFailIPv6(); |
| 330 | } |
| 331 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 332 | TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 333 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 334 | SocketTest::TestConnectWithClosedSocketIPv4(); |
| 335 | } |
| 336 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 337 | TEST_F(PhysicalSocketTest, TestConnectWithClosedSocketIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 338 | SocketTest::TestConnectWithClosedSocketIPv6(); |
| 339 | } |
| 340 | |
| 341 | TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 342 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 343 | SocketTest::TestConnectWhileNotClosedIPv4(); |
| 344 | } |
| 345 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 346 | TEST_F(PhysicalSocketTest, TestConnectWhileNotClosedIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 347 | SocketTest::TestConnectWhileNotClosedIPv6(); |
| 348 | } |
| 349 | |
| 350 | TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 351 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 352 | SocketTest::TestServerCloseDuringConnectIPv4(); |
| 353 | } |
| 354 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 355 | TEST_F(PhysicalSocketTest, TestServerCloseDuringConnectIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 356 | SocketTest::TestServerCloseDuringConnectIPv6(); |
| 357 | } |
| 358 | |
| 359 | TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 360 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 361 | SocketTest::TestClientCloseDuringConnectIPv4(); |
| 362 | } |
| 363 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 364 | TEST_F(PhysicalSocketTest, TestClientCloseDuringConnectIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 365 | SocketTest::TestClientCloseDuringConnectIPv6(); |
| 366 | } |
| 367 | |
| 368 | TEST_F(PhysicalSocketTest, TestServerCloseIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 369 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 370 | SocketTest::TestServerCloseIPv4(); |
| 371 | } |
| 372 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 373 | TEST_F(PhysicalSocketTest, TestServerCloseIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 374 | SocketTest::TestServerCloseIPv6(); |
| 375 | } |
| 376 | |
| 377 | TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 378 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 379 | SocketTest::TestCloseInClosedCallbackIPv4(); |
| 380 | } |
| 381 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 382 | TEST_F(PhysicalSocketTest, TestCloseInClosedCallbackIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 383 | SocketTest::TestCloseInClosedCallbackIPv6(); |
| 384 | } |
| 385 | |
Taylor Brandstetter | 7b69a44 | 2020-08-20 23:43:13 +0000 | [diff] [blame] | 386 | TEST_F(PhysicalSocketTest, TestDeleteInReadCallbackIPv4) { |
| 387 | MAYBE_SKIP_IPV4; |
| 388 | SocketTest::TestDeleteInReadCallbackIPv4(); |
| 389 | } |
| 390 | |
| 391 | TEST_F(PhysicalSocketTest, TestDeleteInReadCallbackIPv6) { |
| 392 | SocketTest::TestDeleteInReadCallbackIPv6(); |
| 393 | } |
| 394 | |
henrike@webrtc.org | c732a3e | 2014-10-09 22:08:15 +0000 | [diff] [blame] | 395 | TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 396 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 397 | SocketTest::TestSocketServerWaitIPv4(); |
| 398 | } |
| 399 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 400 | TEST_F(PhysicalSocketTest, TestSocketServerWaitIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 401 | SocketTest::TestSocketServerWaitIPv6(); |
| 402 | } |
| 403 | |
| 404 | TEST_F(PhysicalSocketTest, TestTcpIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 405 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 406 | SocketTest::TestTcpIPv4(); |
| 407 | } |
| 408 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 409 | TEST_F(PhysicalSocketTest, TestTcpIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 410 | SocketTest::TestTcpIPv6(); |
| 411 | } |
| 412 | |
| 413 | TEST_F(PhysicalSocketTest, TestUdpIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 414 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 415 | SocketTest::TestUdpIPv4(); |
| 416 | } |
| 417 | |
Taylor Brandstetter | 2b3bf6b | 2016-05-19 14:57:31 -0700 | [diff] [blame] | 418 | TEST_F(PhysicalSocketTest, TestUdpIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 419 | SocketTest::TestUdpIPv6(); |
| 420 | } |
| 421 | |
henrike@webrtc.org | 6f833c3 | 2014-06-27 16:21:49 +0000 | [diff] [blame] | 422 | // Disable for TSan v2, see |
| 423 | // https://code.google.com/p/webrtc/issues/detail?id=3498 for details. |
deadbeef | c97be6a | 2015-09-25 11:00:38 -0700 | [diff] [blame] | 424 | // Also disable for MSan, see: |
| 425 | // https://code.google.com/p/webrtc/issues/detail?id=4958 |
| 426 | // TODO(deadbeef): Enable again once test is reimplemented to be unflaky. |
minyue | df200d1 | 2015-10-17 13:10:46 -0700 | [diff] [blame] | 427 | // Also disable for ASan. |
Henrik Kjellander | 0be3e04 | 2015-10-30 21:21:03 +0100 | [diff] [blame] | 428 | // Disabled on Android: https://code.google.com/p/webrtc/issues/detail?id=4364 |
ivoc | f399f21 | 2015-11-19 06:44:32 -0800 | [diff] [blame] | 429 | // Disabled on Linux: https://bugs.chromium.org/p/webrtc/issues/detail?id=5233 |
minyue | df200d1 | 2015-10-17 13:10:46 -0700 | [diff] [blame] | 430 | #if defined(THREAD_SANITIZER) || defined(MEMORY_SANITIZER) || \ |
ivoc | f399f21 | 2015-11-19 06:44:32 -0800 | [diff] [blame] | 431 | defined(ADDRESS_SANITIZER) || defined(WEBRTC_ANDROID) || \ |
| 432 | defined(WEBRTC_LINUX) |
minyue | df200d1 | 2015-10-17 13:10:46 -0700 | [diff] [blame] | 433 | #define MAYBE_TestUdpReadyToSendIPv4 DISABLED_TestUdpReadyToSendIPv4 |
| 434 | #else |
| 435 | #define MAYBE_TestUdpReadyToSendIPv4 TestUdpReadyToSendIPv4 |
| 436 | #endif |
| 437 | TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 438 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 439 | SocketTest::TestUdpReadyToSendIPv4(); |
| 440 | } |
| 441 | |
danilchap | b7b9dca | 2016-08-05 05:55:43 -0700 | [diff] [blame] | 442 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=6167 |
| 443 | #if defined(WEBRTC_WIN) |
| 444 | #define MAYBE_TestUdpReadyToSendIPv6 DISABLED_TestUdpReadyToSendIPv6 |
| 445 | #else |
| 446 | #define MAYBE_TestUdpReadyToSendIPv6 TestUdpReadyToSendIPv6 |
| 447 | #endif |
| 448 | TEST_F(PhysicalSocketTest, MAYBE_TestUdpReadyToSendIPv6) { |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 449 | SocketTest::TestUdpReadyToSendIPv6(); |
| 450 | } |
| 451 | |
| 452 | TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 453 | MAYBE_SKIP_IPV4; |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 454 | SocketTest::TestGetSetOptionsIPv4(); |
| 455 | } |
| 456 | |
| 457 | TEST_F(PhysicalSocketTest, TestGetSetOptionsIPv6) { |
| 458 | SocketTest::TestGetSetOptionsIPv6(); |
| 459 | } |
| 460 | |
| 461 | #if defined(WEBRTC_POSIX) |
| 462 | |
Taylor Brandstetter | 6f82535 | 2016-08-11 15:38:28 -0700 | [diff] [blame] | 463 | // We don't get recv timestamps on Mac. |
Stefan Holmer | 9131efd | 2016-05-23 18:19:26 +0200 | [diff] [blame] | 464 | #if !defined(WEBRTC_MAC) |
| 465 | TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv4) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 466 | MAYBE_SKIP_IPV4; |
Taylor Brandstetter | 6f82535 | 2016-08-11 15:38:28 -0700 | [diff] [blame] | 467 | SocketTest::TestSocketRecvTimestampIPv4(); |
Stefan Holmer | 9131efd | 2016-05-23 18:19:26 +0200 | [diff] [blame] | 468 | } |
| 469 | |
Taylor Brandstetter | 6f82535 | 2016-08-11 15:38:28 -0700 | [diff] [blame] | 470 | TEST_F(PhysicalSocketTest, TestSocketRecvTimestampIPv6) { |
| 471 | SocketTest::TestSocketRecvTimestampIPv6(); |
Stefan Holmer | 9131efd | 2016-05-23 18:19:26 +0200 | [diff] [blame] | 472 | } |
| 473 | #endif |
| 474 | |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 475 | // Verify that if the socket was unable to be bound to a real network interface |
| 476 | // (not loopback), Bind will return an error. |
| 477 | TEST_F(PhysicalSocketTest, |
| 478 | BindFailsIfNetworkBinderFailsForNonLoopbackInterface) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 479 | MAYBE_SKIP_IPV4; |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 480 | FakeNetworkBinder fake_network_binder; |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 481 | server_.set_network_binder(&fake_network_binder); |
| 482 | std::unique_ptr<Socket> socket(server_.CreateSocket(AF_INET, SOCK_DGRAM)); |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 483 | fake_network_binder.set_result(NetworkBindingResult::FAILURE); |
| 484 | EXPECT_EQ(-1, socket->Bind(SocketAddress("192.168.0.1", 0))); |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 485 | server_.set_network_binder(nullptr); |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 486 | } |
| 487 | |
deadbeef | 9ffa13f | 2017-02-21 16:18:00 -0800 | [diff] [blame] | 488 | // Network binder shouldn't be used if the socket is bound to the "any" IP. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 489 | TEST_F(PhysicalSocketTest, NetworkBinderIsNotUsedForAnyIp) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 490 | MAYBE_SKIP_IPV4; |
deadbeef | 9ffa13f | 2017-02-21 16:18:00 -0800 | [diff] [blame] | 491 | FakeNetworkBinder fake_network_binder; |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 492 | server_.set_network_binder(&fake_network_binder); |
| 493 | std::unique_ptr<Socket> socket(server_.CreateSocket(AF_INET, SOCK_DGRAM)); |
deadbeef | 9ffa13f | 2017-02-21 16:18:00 -0800 | [diff] [blame] | 494 | EXPECT_EQ(0, socket->Bind(SocketAddress("0.0.0.0", 0))); |
| 495 | EXPECT_EQ(0, fake_network_binder.num_binds()); |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 496 | server_.set_network_binder(nullptr); |
deadbeef | 9ffa13f | 2017-02-21 16:18:00 -0800 | [diff] [blame] | 497 | } |
| 498 | |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 499 | // For a loopback interface, failures to bind to the interface should be |
| 500 | // tolerated. |
| 501 | TEST_F(PhysicalSocketTest, |
| 502 | BindSucceedsIfNetworkBinderFailsForLoopbackInterface) { |
deadbeef | 9a6f4d4 | 2017-05-15 19:43:33 -0700 | [diff] [blame] | 503 | MAYBE_SKIP_IPV4; |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 504 | FakeNetworkBinder fake_network_binder; |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 505 | server_.set_network_binder(&fake_network_binder); |
| 506 | std::unique_ptr<Socket> socket(server_.CreateSocket(AF_INET, SOCK_DGRAM)); |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 507 | fake_network_binder.set_result(NetworkBindingResult::FAILURE); |
| 508 | EXPECT_EQ(0, socket->Bind(SocketAddress(kIPv4Loopback, 0))); |
Niels Möller | 50f7c2c | 2021-09-08 14:05:16 +0200 | [diff] [blame] | 509 | server_.set_network_binder(nullptr); |
deadbeef | c874d12 | 2017-02-13 15:41:59 -0800 | [diff] [blame] | 510 | } |
| 511 | |
henrike@webrtc.org | f048872 | 2014-05-13 18:00:26 +0000 | [diff] [blame] | 512 | #endif |
| 513 | |
| 514 | } // namespace rtc |