diff options
author | Haruki Okada <ocadaruma@gmail.com> | 2021-09-23 20:31:17 +0900 |
---|---|---|
committer | Alan Somers <asomers@gmail.com> | 2021-09-28 19:17:48 -0600 |
commit | a60703430ee708f3899b411f7756e65ea44c8f2a (patch) | |
tree | 7d74d50dbc87efc0810eb1cdc64d4d49ad35e906 /test | |
parent | 759b34adea682c5434ea88cea5d666da816149cc (diff) | |
download | nix-a60703430ee708f3899b411f7756e65ea44c8f2a.zip |
Fix return value of posix_fadvise
libc::posix_fadvise returns errnos directly rather than in the errno
variable.
Diffstat (limited to 'test')
-rw-r--r-- | test/test_fcntl.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/test/test_fcntl.rs b/test/test_fcntl.rs index 76252e6e..db2acfbf 100644 --- a/test/test_fcntl.rs +++ b/test/test_fcntl.rs @@ -473,17 +473,16 @@ mod test_posix_fadvise { fn test_success() { let tmp = NamedTempFile::new().unwrap(); let fd = tmp.as_raw_fd(); - let res = posix_fadvise(fd, 0, 100, PosixFadviseAdvice::POSIX_FADV_WILLNEED).unwrap(); + let res = posix_fadvise(fd, 0, 100, PosixFadviseAdvice::POSIX_FADV_WILLNEED); - assert_eq!(res, 0); + assert!(res.is_ok()); } #[test] fn test_errno() { let (rd, _wr) = pipe().unwrap(); - let errno = posix_fadvise(rd as RawFd, 0, 100, PosixFadviseAdvice::POSIX_FADV_WILLNEED) - .unwrap(); - assert_eq!(errno, Errno::ESPIPE as i32); + let res = posix_fadvise(rd as RawFd, 0, 100, PosixFadviseAdvice::POSIX_FADV_WILLNEED); + assert_eq!(res, Err(Errno::ESPIPE)); } } |