blob: ea0ebf98f87c1d7e73db2fa7a40ae38318250a31 [file] [log] [blame]
minyue939df962017-04-19 08:58:381/*
2 * Copyright (c) 2017 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
minyue939df962017-04-19 08:58:3811#ifdef WEBRTC_NETWORK_TESTER_TEST_ENABLED
12
Yves Gerey3e707812018-11-28 15:47:4913#include <string>
minyue939df962017-04-19 08:58:3814
Mirko Bonadei92ea95e2017-09-15 04:47:3115#include "rtc_base/gunit.h"
Liad Rubina88a4b72023-10-18 13:44:0116#include "rtc_base/random.h"
Yves Gerey3e707812018-11-28 15:47:4917#include "rtc_tools/network_tester/test_controller.h"
Mirko Bonadei92ea95e2017-09-15 04:47:3118#include "test/gtest.h"
Steve Anton10542f22019-01-11 17:11:0019#include "test/testsupport/file_utils.h"
minyue939df962017-04-19 08:58:3820
21namespace webrtc {
22
23TEST(NetworkTesterTest, ServerClient) {
Liad Rubina88a4b72023-10-18 13:44:0124 // Use a unique port rather than a hard-coded one to avoid collision when
25 // running the test in parallel in stress runs. Skipping all reserved ports.
26 const int MIN_PORT = 49152;
27 const int MAX_PORT = 65535;
28 int port = webrtc::Random(rtc::TimeMicros()).Rand(MIN_PORT, MAX_PORT);
29
Byoungchan Leec931f702022-07-03 08:20:1730 rtc::AutoThread main_thread;
Liad Rubina88a4b72023-10-18 13:44:0131
minyue939df962017-04-19 08:58:3832 TestController client(
michaeltfcea39d2017-04-20 12:39:3033 0, 0, webrtc::test::ResourcePath("network_tester/client_config", "dat"),
34 webrtc::test::OutputPath() + "client_packet_log.dat");
minyue939df962017-04-19 08:58:3835 TestController server(
Liad Rubina88a4b72023-10-18 13:44:0136 port, port,
michaeltfcea39d2017-04-20 12:39:3037 webrtc::test::ResourcePath("network_tester/server_config", "dat"),
38 webrtc::test::OutputPath() + "server_packet_log.dat");
Liad Rubina88a4b72023-10-18 13:44:0139 client.SendConnectTo("127.0.0.1", port);
minyue939df962017-04-19 08:58:3840 EXPECT_TRUE_WAIT(server.IsTestDone() && client.IsTestDone(), 2000);
41}
42
43} // namespace webrtc
44
45#endif // WEBRTC_NETWORK_TESTER_TEST_ENABLED