From e25591ac2c329eee8ee9ee262cc603129b596484 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Fri, 18 Jul 2025 17:35:27 -0600 Subject: [PATCH] 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. --- test/sys/test_aio.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/test/sys/test_aio.rs b/test/sys/test_aio.rs index 2f4494facf..beb70448b6 100644 --- a/test/sys/test_aio.rs +++ b/test/sys/test_aio.rs @@ -70,15 +70,11 @@ mod aio_fsync { #[test] #[cfg_attr(any(target_os = "android", target_os = "linux"), ignore)] fn error() { - use std::mem; - - const INITIAL: &[u8] = b"abcdef123456"; - // Create an invalid AioFsyncMode - let mode = unsafe { mem::transmute::(666) }; - let mut f = tempfile().unwrap(); - f.write_all(INITIAL).unwrap(); + let mode = AioFsyncMode::O_SYNC; + // Operate on an invalid file descriptor. Should get EBADF + let fd = unsafe { BorrowedFd::borrow_raw(i32::MAX) }; let mut aiof = - Box::pin(AioFsync::new(f.as_fd(), mode, 0, SigevNotify::SigevNone)); + Box::pin(AioFsync::new(fd, mode, 0, SigevNotify::SigevNone)); let err = aiof.as_mut().submit(); err.expect_err("assertion failed"); }