Skip to content

Commit 7755285

Browse files
committed
Check all last error in test
1 parent 05218ba commit 7755285

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/pass-dep/libc/libc-eventfd.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ fn test_read_write() {
4141
// value -1.
4242
let mut buf: [u8; 8] = [0; 8];
4343
let res = read_bytes(fd, &mut buf);
44+
let e = std::io::Error::last_os_error();
45+
assert_eq!(e.raw_os_error(), Some(libc::EAGAIN));
4446
assert_eq!(res, -1);
4547

4648
// Write with supplied buffer bigger than 8 bytes should be allowed.
@@ -58,12 +60,16 @@ fn test_read_write() {
5860
// value -1.
5961
let mut buf: [u8; 7] = [1; 7];
6062
let res = read_bytes(fd, &mut buf);
63+
let e = std::io::Error::last_os_error();
64+
assert_eq!(e.raw_os_error(), Some(libc::EINVAL));
6165
assert_eq!(res, -1);
6266

6367
// Write with supplied buffer smaller than 8 bytes should fail with return
6468
// value -1.
6569
let size_7_data: [u8; 7] = [1; 7];
6670
let res = write_bytes(fd, size_7_data);
71+
let e = std::io::Error::last_os_error();
72+
assert_eq!(e.raw_os_error(), Some(libc::EINVAL));
6773
assert_eq!(res, -1);
6874

6975
// Read with supplied buffer bigger than 8 bytes should be allowed.
@@ -74,6 +80,8 @@ fn test_read_write() {
7480
// Write u64::MAX should fail.
7581
let u64_max_bytes: [u8; 8] = [255; 8];
7682
let res = write_bytes(fd, u64_max_bytes);
83+
let e = std::io::Error::last_os_error();
84+
assert_eq!(e.raw_os_error(), Some(libc::EINVAL));
7785
assert_eq!(res, -1);
7886
}
7987

0 commit comments

Comments
 (0)