File tree 3 files changed +28
-12
lines changed
3 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -1548,8 +1548,9 @@ mod tests {
1548
1548
1549
1549
let mut buf = [ 0 ; 10 ] ;
1550
1550
let start = Instant :: now ( ) ;
1551
- let kind = stream. read ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1552
- assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ) ;
1551
+ let kind = stream. read_exact ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1552
+ assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ,
1553
+ "unexpected_error: {:?}" , kind) ;
1553
1554
assert ! ( start. elapsed( ) > Duration :: from_millis( 400 ) ) ;
1554
1555
drop ( listener) ;
1555
1556
}
@@ -1570,8 +1571,9 @@ mod tests {
1570
1571
assert_eq ! ( b"hello world" , & buf[ ..] ) ;
1571
1572
1572
1573
let start = Instant :: now ( ) ;
1573
- let kind = stream. read ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1574
- assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ) ;
1574
+ let kind = stream. read_exact ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1575
+ assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ,
1576
+ "unexpected_error: {:?}" , kind) ;
1575
1577
assert ! ( start. elapsed( ) > Duration :: from_millis( 400 ) ) ;
1576
1578
drop ( listener) ;
1577
1579
}
Original file line number Diff line number Diff line change @@ -1030,8 +1030,14 @@ mod tests {
1030
1030
let mut buf = [ 0 ; 10 ] ;
1031
1031
1032
1032
let start = Instant :: now ( ) ;
1033
- let kind = stream. recv_from ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1034
- assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ) ;
1033
+ loop {
1034
+ let kind = stream. recv_from ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1035
+ if kind != ErrorKind :: Interrupted {
1036
+ assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ,
1037
+ "unexpected_error: {:?}" , kind) ;
1038
+ break ;
1039
+ }
1040
+ }
1035
1041
assert ! ( start. elapsed( ) > Duration :: from_millis( 400 ) ) ;
1036
1042
}
1037
1043
@@ -1049,8 +1055,14 @@ mod tests {
1049
1055
assert_eq ! ( b"hello world" , & buf[ ..] ) ;
1050
1056
1051
1057
let start = Instant :: now ( ) ;
1052
- let kind = stream. recv_from ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1053
- assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ) ;
1058
+ loop {
1059
+ let kind = stream. recv_from ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1060
+ if kind != ErrorKind :: Interrupted {
1061
+ assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ,
1062
+ "unexpected_error: {:?}" , kind) ;
1063
+ break ;
1064
+ }
1065
+ }
1054
1066
assert ! ( start. elapsed( ) > Duration :: from_millis( 400 ) ) ;
1055
1067
}
1056
1068
Original file line number Diff line number Diff line change @@ -1654,8 +1654,9 @@ mod test {
1654
1654
or_panic ! ( stream. set_read_timeout( Some ( Duration :: from_millis( 1000 ) ) ) ) ;
1655
1655
1656
1656
let mut buf = [ 0 ; 10 ] ;
1657
- let kind = stream. read ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1658
- assert ! ( kind == io:: ErrorKind :: WouldBlock || kind == io:: ErrorKind :: TimedOut ) ;
1657
+ let kind = stream. read_exact ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1658
+ assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ,
1659
+ "unexpected_error: {:?}" , kind) ;
1659
1660
}
1660
1661
1661
1662
#[ test]
@@ -1675,8 +1676,9 @@ mod test {
1675
1676
or_panic ! ( stream. read( & mut buf) ) ;
1676
1677
assert_eq ! ( b"hello world" , & buf[ ..] ) ;
1677
1678
1678
- let kind = stream. read ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1679
- assert ! ( kind == io:: ErrorKind :: WouldBlock || kind == io:: ErrorKind :: TimedOut ) ;
1679
+ let kind = stream. read_exact ( & mut buf) . err ( ) . expect ( "expected error" ) . kind ( ) ;
1680
+ assert ! ( kind == ErrorKind :: WouldBlock || kind == ErrorKind :: TimedOut ,
1681
+ "unexpected_error: {:?}" , kind) ;
1680
1682
}
1681
1683
1682
1684
// Ensure the `set_read_timeout` and `set_write_timeout` calls return errors
You can’t perform that action at this time.
0 commit comments