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

Unified Diff: webrtc/base/socket_unittest.cc

Issue 2111043004: Enabling IPv6 socket recv timestamp test, and making less flaky. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/socket_unittest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/socket_unittest.cc
diff --git a/webrtc/base/socket_unittest.cc b/webrtc/base/socket_unittest.cc
index 0b282cd66053bbfa723517a19b3a75ff31c208a4..8aaa2bb827b156a60971c5fcf3404fd01acf3cc4 100644
--- a/webrtc/base/socket_unittest.cc
+++ b/webrtc/base/socket_unittest.cc
@@ -184,10 +184,15 @@ void SocketTest::TestGetSetOptionsIPv6() {
GetSetOptionsInternal(kIPv6Loopback);
}
-void SocketTest::TestSocketRecvTimestamp() {
+void SocketTest::TestSocketRecvTimestampIPv4() {
SocketRecvTimestamp(kIPv4Loopback);
}
+void SocketTest::TestSocketRecvTimestampIPv6() {
+ MAYBE_SKIP_IPV6;
+ SocketRecvTimestamp(kIPv6Loopback);
+}
+
// For unbound sockets, GetLocalAddress / GetRemoteAddress return AF_UNSPEC
// values on Windows, but an empty address of the same family on Linux/MacOS X.
bool IsUnspecOrEmptyIP(const IPAddress& address) {
@@ -1033,19 +1038,26 @@ void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) {
EXPECT_EQ(0, socket->Bind(SocketAddress(loopback, 0)));
SocketAddress address = socket->GetLocalAddress();
+ uint64_t send_time_1 = TimeMicros();
socket->SendTo("foo", 3, address);
- int64_t timestamp;
+ int64_t recv_timestamp_1;
char buffer[3];
- socket->RecvFrom(buffer, 3, nullptr, &timestamp);
- EXPECT_GT(timestamp, -1);
- int64_t prev_timestamp = timestamp;
+ socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_1);
+ EXPECT_GT(recv_timestamp_1, -1);
- const int64_t kTimeBetweenPacketsMs = 10;
+ const int64_t kTimeBetweenPacketsMs = 100;
Thread::SleepMs(kTimeBetweenPacketsMs);
+ uint64_t send_time_2 = TimeMicros();
socket->SendTo("bar", 3, address);
- socket->RecvFrom(buffer, 3, nullptr, &timestamp);
- EXPECT_NEAR(timestamp, prev_timestamp + kTimeBetweenPacketsMs * 1000, 2000);
+ int64_t recv_timestamp_2;
+ socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_2);
+
+ int64_t system_time_diff = send_time_2 - send_time_1;
+ int64_t recv_timestamp_diff = recv_timestamp_2 - recv_timestamp_1;
+ // Compare against the system time at the point of sending, because
+ // SleepMs may not sleep for exactly the requested time.
+ EXPECT_NEAR(system_time_diff, recv_timestamp_diff, 10000);
}
} // namespace rtc
« no previous file with comments | « webrtc/base/socket_unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698