diff options
| author | Steven Fackler <sfackler@gmail.com> | 2015-05-29 19:09:29 -0700 |
|---|---|---|
| committer | Steven Fackler <sfackler@gmail.com> | 2015-05-29 19:09:29 -0700 |
| commit | b5c6c7ed408c1c7afb8d4f0430f67255a140d183 (patch) | |
| tree | fea76362e44445ebc55d3e3184ab1a7e3d40ce45 /src/libstd | |
| parent | 494901a8b46c699b530e7209114bde44b1de4451 (diff) | |
| download | rust-b5c6c7ed408c1c7afb8d4f0430f67255a140d183.tar.gz rust-b5c6c7ed408c1c7afb8d4f0430f67255a140d183.zip | |
Loosen timeout restrictions
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/net/tcp.rs | 16 | ||||
| -rw-r--r-- | src/libstd/net/udp.rs | 16 |
2 files changed, 12 insertions, 20 deletions
diff --git a/src/libstd/net/tcp.rs b/src/libstd/net/tcp.rs index ff1f4b4c4c7..cffccab7e09 100644 --- a/src/libstd/net/tcp.rs +++ b/src/libstd/net/tcp.rs @@ -933,17 +933,15 @@ mod tests { let listener = t!(TcpListener::bind(&addr)); let mut stream = t!(TcpStream::connect(&("localhost", addr.port()))); - t!(stream.set_read_timeout(Some(Duration::from_millis(10)))); + t!(stream.set_read_timeout(Some(Duration::from_millis(1000)))); let mut buf = [0; 10]; let wait = Duration::span(|| { let kind = stream.read(&mut buf).err().expect("expected error").kind(); assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut); }); - assert!(wait > Duration::from_millis(5)); - // windows will sometimes extend this by ~500ms, so we'll just take the - // fact that we did time out as a win :( - assert!(cfg!(windows) || wait < Duration::from_millis(15)); + assert!(wait > Duration::from_millis(400)); + assert!(wait < Duration::from_millis(1600)); } #[test] @@ -952,7 +950,7 @@ mod tests { let listener = t!(TcpListener::bind(&addr)); let mut stream = t!(TcpStream::connect(&("localhost", addr.port()))); - t!(stream.set_read_timeout(Some(Duration::from_millis(10)))); + t!(stream.set_read_timeout(Some(Duration::from_millis(1000)))); let mut other_end = t!(listener.accept()).0; t!(other_end.write_all(b"hello world")); @@ -965,9 +963,7 @@ mod tests { let kind = stream.read(&mut buf).err().expect("expected error").kind(); assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut); }); - assert!(wait > Duration::from_millis(5)); - // windows will sometimes extend this by ~500ms, so we'll just take the - // fact that we did time out as a win :( - assert!(cfg!(windows) || wait < Duration::from_millis(15)); + assert!(wait > Duration::from_millis(400)); + assert!(wait < Duration::from_millis(1600)); } } diff --git a/src/libstd/net/udp.rs b/src/libstd/net/udp.rs index f1f40216385..ebabba7def1 100644 --- a/src/libstd/net/udp.rs +++ b/src/libstd/net/udp.rs @@ -389,17 +389,15 @@ mod tests { let addr = next_test_ip4(); let mut stream = t!(UdpSocket::bind(&addr)); - t!(stream.set_read_timeout(Some(Duration::from_millis(10)))); + t!(stream.set_read_timeout(Some(Duration::from_millis(1000)))); let mut buf = [0; 10]; let wait = Duration::span(|| { let kind = stream.recv_from(&mut buf).err().expect("expected error").kind(); assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut); }); - assert!(wait > Duration::from_millis(5)); - // windows will sometimes extend this by ~500ms, so we'll just take the - // fact that we did time out as a win :( - assert!(cfg!(windows) || wait < Duration::from_millis(15)); + assert!(wait > Duration::from_millis(400)); + assert!(wait < Duration::from_millis(1600)); } #[test] @@ -407,7 +405,7 @@ mod tests { let addr = next_test_ip4(); let mut stream = t!(UdpSocket::bind(&addr)); - t!(stream.set_read_timeout(Some(Duration::from_millis(10)))); + t!(stream.set_read_timeout(Some(Duration::from_millis(1000)))); t!(stream.send_to(b"hello world", &addr)); @@ -419,9 +417,7 @@ mod tests { let kind = stream.recv_from(&mut buf).err().expect("expected error").kind(); assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut); }); - assert!(wait > Duration::from_millis(5)); - // windows will sometimes extend this by ~500ms, so we'll just take the - // fact that we did time out as a win :( - assert!(cfg!(windows) || wait < Duration::from_millis(15)); + assert!(wait > Duration::from_millis(400)); + assert!(wait < Duration::from_millis(1600)); } } |
