diff options
author | Jeff Vander Stoep <jeffv@google.com> | 2021-05-26 16:20:35 +0200 |
---|---|---|
committer | Jeff Vander Stoep <jeffv@google.com> | 2021-05-27 08:53:31 +0200 |
commit | 87b2985bce1879af059636003b0a16e533befaf8 (patch) | |
tree | 8d20532f6b72cf3f3dca34b95374243293864bda /tests | |
parent | f1a1047f595f273f50d8bc39e3b9eea74a0b73b4 (diff) | |
download | tokio-87b2985bce1879af059636003b0a16e533befaf8.tar.gz |
tcp_into_std: assign an unused port
Assigning a specific port can lead to colisions and test failures.
This results in this test failing ~0.5% of the time on Android's CI.
Fixes:
test tcp_into_std ... FAILED
failures:
---- tcp_into_std stdout ----
Error: Os { code: 98, kind: AddrInUse, message: "Address already in use" }
Bug: 187561179
Test: atest tokio_host_test_tests_tcp_into_std
Change-Id: Ifeb9adddc68fb4c03cbf6fd310731ae99f61d0d5
Diffstat (limited to 'tests')
-rw-r--r-- | tests/tcp_into_std.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/tcp_into_std.rs b/tests/tcp_into_std.rs index a46aace..4bf24c1 100644 --- a/tests/tcp_into_std.rs +++ b/tests/tcp_into_std.rs @@ -10,10 +10,11 @@ use tokio::net::TcpStream; #[tokio::test] async fn tcp_into_std() -> Result<()> { let mut data = [0u8; 12]; - let listener = TcpListener::bind("127.0.0.1:34254").await?; + let listener = TcpListener::bind("127.0.0.1:0").await?; + let addr = listener.local_addr().unwrap().to_string(); let handle = tokio::spawn(async { - let stream: TcpStream = TcpStream::connect("127.0.0.1:34254").await.unwrap(); + let stream: TcpStream = TcpStream::connect(addr).await.unwrap(); stream }); |