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