diff options
| author | Josh Stone <jistone@redhat.com> | 2018-11-30 15:33:40 -0800 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2018-11-30 15:33:40 -0800 |
| commit | f107514aef0b25b0d959941df1e45b18a478151b (patch) | |
| tree | 2d82a76865ada6adc5a8a0325c55f1d13c290ba4 /src/libstd/sys | |
| parent | d48ab693d1ce99f30c0cf9abdf45c209824fe825 (diff) | |
| download | rust-f107514aef0b25b0d959941df1e45b18a478151b.tar.gz rust-f107514aef0b25b0d959941df1e45b18a478151b.zip | |
Deal with EINTR in net timeout tests
We've seen sporadic QE failures in the timeout tests on this assertion:
assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut);
So there's an error, but not either of the expected kinds. Adding a
format to show the kind revealed `ErrorKind::Interrupted` (`EINTR`).
For the cases that were using `read`, we can just use `read_exact` to
keep trying after interruption. For those using `recv_from`, we have to
manually loop until we get a non-interrupted result.
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/ext/net.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index 55f43ccd7db..737437c76b7 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -1654,8 +1654,9 @@ mod test { or_panic!(stream.set_read_timeout(Some(Duration::from_millis(1000)))); let mut buf = [0; 10]; - let kind = stream.read(&mut buf).err().expect("expected error").kind(); - assert!(kind == io::ErrorKind::WouldBlock || kind == io::ErrorKind::TimedOut); + let kind = stream.read_exact(&mut buf).err().expect("expected error").kind(); + assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut, + "unexpected_error: {:?}", kind); } #[test] @@ -1675,8 +1676,9 @@ mod test { or_panic!(stream.read(&mut buf)); assert_eq!(b"hello world", &buf[..]); - let kind = stream.read(&mut buf).err().expect("expected error").kind(); - assert!(kind == io::ErrorKind::WouldBlock || kind == io::ErrorKind::TimedOut); + let kind = stream.read_exact(&mut buf).err().expect("expected error").kind(); + assert!(kind == ErrorKind::WouldBlock || kind == ErrorKind::TimedOut, + "unexpected_error: {:?}", kind); } // Ensure the `set_read_timeout` and `set_write_timeout` calls return errors |
