Avoid global time function in network_tester tool Bug: webrtc:42223992 Change-Id: Ic72d58c26781cb0e3cc46f7396552462456145cc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/481022 Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#47979}
diff --git a/rtc_tools/network_tester/BUILD.gn b/rtc_tools/network_tester/BUILD.gn index eeac69b..554ff37 100644 --- a/rtc_tools/network_tester/BUILD.gn +++ b/rtc_tools/network_tester/BUILD.gn
@@ -87,12 +87,8 @@ deps = [ ":network_tester", - "../../api:rtc_error_matchers", "../../api/environment", - "../../api/environment:environment_factory", "../../rtc_base:random", - "../../rtc_base:threading", - "../../rtc_base:timeutils", "../../test:create_test_environment", "../../test:fileutils", "../../test:run_loop",
diff --git a/rtc_tools/network_tester/network_tester_unittest.cc b/rtc_tools/network_tester/network_tester_unittest.cc index 8798bf5..dc18aa3 100644 --- a/rtc_tools/network_tester/network_tester_unittest.cc +++ b/rtc_tools/network_tester/network_tester_unittest.cc
@@ -14,7 +14,6 @@ #include "api/environment/environment.h" #include "rtc_base/random.h" -#include "rtc_base/time_utils.h" #include "rtc_tools/network_tester/test_controller.h" #include "test/create_test_environment.h" #include "test/gtest.h" @@ -25,15 +24,15 @@ namespace webrtc { TEST(NetworkTesterTest, ServerClient) { - // Use a unique port rather than a hard-coded one to avoid collision when - // running the test in parallel in stress runs. Skipping all reserved ports. - const int MIN_PORT = 49152; - const int MAX_PORT = 65535; - int port = Random(TimeMicros()).Rand(MIN_PORT, MAX_PORT); - test::RunLoop main_thread; Environment env = CreateTestEnvironment(); + // Use a unique port rather than a hard-coded one to avoid collision when + // running the test in parallel in stress runs. Skipping all reserved ports. + const int kMinPort = 49152; + const int kMaxPort = 65535; + int port = Random(env.clock().TimeInMicroseconds()).Rand(kMinPort, kMaxPort); + TestController client( env, 0, 0, test::ResourcePath("network_tester/client_config", "dat"), test::OutputPath() + "client_packet_log.dat");