From a316820fa403cc8dfe82fb87e51c166cbe51c13c Mon Sep 17 00:00:00 2001 From: Phil Phauler <128394598+philphauler@users.noreply.github.com> Date: Sun, 6 Sep 2026 18:05:49 +0200 Subject: [PATCH] tests: handle EPERM in io_uring_supported helper (#8416) Co-authored-by: philphauler --- tokio/tests/support/io_uring.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tokio/tests/support/io_uring.rs b/tokio/tests/support/io_uring.rs index bdc57bf2a..3b07cbf3d 100644 --- a/tokio/tests/support/io_uring.rs +++ b/tokio/tests/support/io_uring.rs @@ -20,10 +20,15 @@ use io_uring::IoUring; pub fn io_uring_supported() -> bool { match IoUring::new(256) { Ok(_) => true, - // The Kernel does not support io-uring - Err(e) if e.raw_os_error() == Some(libc::ENOSYS) => false, - Err(_) => unreachable!( - "The target should either support io_uring or return ENOSYS if not supported" + // ENOSYS: kernel does not support io_uring. + // EPERM: io_uring disabled via sysctl kernel.io_uring_disabled (#7691). + Err(e) + if e.raw_os_error() == Some(libc::ENOSYS) || e.raw_os_error() == Some(libc::EPERM) => + { + false + } + Err(e) => unreachable!( + "IoUring::new failed with an unexpected error (expected ENOSYS or EPERM): {e}" ), } }