Skip to content

Commit ff3d194

Browse files
committed
Fix the sys::test_aio::aio_fsync::error test on recent rust nightly
This test deliberately makes an invalid syscall. Rust no longer allows us to even construct an invalid enum (even with `unsafe`), so alter the test to get EBADF instead of EINVAL.
1 parent a72936d commit ff3d194

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

test/sys/test_aio.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,11 @@ mod aio_fsync {
7070
#[test]
7171
#[cfg_attr(any(target_os = "android", target_os = "linux"), ignore)]
7272
fn error() {
73-
use std::mem;
74-
75-
const INITIAL: &[u8] = b"abcdef123456";
76-
// Create an invalid AioFsyncMode
77-
let mode = unsafe { mem::transmute::<i32, AioFsyncMode>(666) };
78-
let mut f = tempfile().unwrap();
79-
f.write_all(INITIAL).unwrap();
73+
let mode = AioFsyncMode::O_SYNC;
74+
// Operate on an invalid file descriptor. Should get EBADF
75+
let fd = unsafe{ BorrowedFd::borrow_raw(i32::MAX) };
8076
let mut aiof =
81-
Box::pin(AioFsync::new(f.as_fd(), mode, 0, SigevNotify::SigevNone));
77+
Box::pin(AioFsync::new(fd, mode, 0, SigevNotify::SigevNone));
8278
let err = aiof.as_mut().submit();
8379
err.expect_err("assertion failed");
8480
}

0 commit comments

Comments
 (0)