Loosen timeout restrictions
This commit is contained in:
@@ -933,17 +933,15 @@ mod tests {
|
|||||||
let listener = t!(TcpListener::bind(&addr));
|
let listener = t!(TcpListener::bind(&addr));
|
||||||
|
|
||||||
let mut stream = t!(TcpStream::connect(&("localhost", addr.port())));
|
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 mut buf = [0; 10];
|
||||||
let wait = Duration::span(|| {
|
let wait = Duration::span(|| {
|
||||||
let kind = stream.read(&mut buf).err().expect("expected error").kind();
|
let kind = stream.read(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
});
|
||||||
assert!(wait > Duration::from_millis(5));
|
assert!(wait > Duration::from_millis(400));
|
||||||
// windows will sometimes extend this by ~500ms, so we'll just take the
|
assert!(wait < Duration::from_millis(1600));
|
||||||
// fact that we did time out as a win :(
|
|
||||||
assert!(cfg!(windows) || wait < Duration::from_millis(15));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -952,7 +950,7 @@ mod tests {
|
|||||||
let listener = t!(TcpListener::bind(&addr));
|
let listener = t!(TcpListener::bind(&addr));
|
||||||
|
|
||||||
let mut stream = t!(TcpStream::connect(&("localhost", addr.port())));
|
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;
|
let mut other_end = t!(listener.accept()).0;
|
||||||
t!(other_end.write_all(b"hello world"));
|
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();
|
let kind = stream.read(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
});
|
||||||
assert!(wait > Duration::from_millis(5));
|
assert!(wait > Duration::from_millis(400));
|
||||||
// windows will sometimes extend this by ~500ms, so we'll just take the
|
assert!(wait < Duration::from_millis(1600));
|
||||||
// fact that we did time out as a win :(
|
|
||||||
assert!(cfg!(windows) || wait < Duration::from_millis(15));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -389,17 +389,15 @@ mod tests {
|
|||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
|
|
||||||
let mut stream = t!(UdpSocket::bind(&addr));
|
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 mut buf = [0; 10];
|
||||||
let wait = Duration::span(|| {
|
let wait = Duration::span(|| {
|
||||||
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
|
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
});
|
||||||
assert!(wait > Duration::from_millis(5));
|
assert!(wait > Duration::from_millis(400));
|
||||||
// windows will sometimes extend this by ~500ms, so we'll just take the
|
assert!(wait < Duration::from_millis(1600));
|
||||||
// fact that we did time out as a win :(
|
|
||||||
assert!(cfg!(windows) || wait < Duration::from_millis(15));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -407,7 +405,7 @@ mod tests {
|
|||||||
let addr = next_test_ip4();
|
let addr = next_test_ip4();
|
||||||
|
|
||||||
let mut stream = t!(UdpSocket::bind(&addr));
|
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));
|
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();
|
let kind = stream.recv_from(&mut buf).err().expect("expected error").kind();
|
||||||
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
|
||||||
});
|
});
|
||||||
assert!(wait > Duration::from_millis(5));
|
assert!(wait > Duration::from_millis(400));
|
||||||
// windows will sometimes extend this by ~500ms, so we'll just take the
|
assert!(wait < Duration::from_millis(1600));
|
||||||
// fact that we did time out as a win :(
|
|
||||||
assert!(cfg!(windows) || wait < Duration::from_millis(15));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user