From 7a1dbbd4f93f7e6221eab7f8c26b464685728bf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Anic=CC=81?= Date: Wed, 8 Nov 2023 18:25:29 +0100 Subject: [PATCH 1/2] fix io_uring timeout_remove test on kernel 5.4 There is no grantee that `copy_cqes` will return exactly wait_nr number of cqes. If there are ready cqes it can return > 0 but < wait_nr number of cqes. --- lib/std/os/linux/io_uring.zig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index d90561e6e4..2372dba09b 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -2329,7 +2329,8 @@ test "timeout_remove" { // * kernel 5.18 gives user data 0x99999999 first, 0x88888888 second var cqes: [2]os.linux.io_uring_cqe = undefined; - try testing.expectEqual(@as(u32, 2), try ring.copy_cqes(cqes[0..], 2)); + cqes[0] = try ring.copy_cqe(); + cqes[1] = try ring.copy_cqe(); for (cqes) |cqe| { // IORING_OP_TIMEOUT_REMOVE is not supported by this kernel version: From 715e5f757f4768825d923ef473af1e02f6c7754c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Anic=CC=81?= Date: Wed, 8 Nov 2023 18:52:03 +0100 Subject: [PATCH 2/2] fix io_uring tests on kernel 5.4 Unsupported tests are now skipped on kernel 5.4: ``` uname -a Linux d20 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:31:37 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux zig test lib/std/std.zig --zig-lib-dir lib --main-mod-path lib/std 2>&1 | cat 709/2616 test.nop... OK 710/2616 test.readv... OK 711/2616 test.writev/fsync/readv... OK 712/2616 test.write/read... SKIP 713/2616 test.splice/read... SKIP 714/2616 test.write_fixed/read_fixed... OK 715/2616 test.openat... SKIP 716/2616 test.close... SKIP 717/2616 test.accept/connect/send/recv... SKIP 718/2616 test.sendmsg/recvmsg... OK 719/2616 test.timeout (after a relative time)... SKIP 720/2616 test.timeout (after a number of completions)... OK 721/2616 test.timeout_remove... SKIP 722/2616 test.accept/connect/recv/link_timeout... SKIP 723/2616 test.fallocate... SKIP 724/2616 test.statx... SKIP 725/2616 test.accept/connect/recv/cancel... SKIP 726/2616 test.register_files_update... SKIP 727/2616 test.shutdown... SKIP 728/2616 test.renameat... SKIP 729/2616 test.unlinkat... SKIP 730/2616 test.mkdirat... SKIP 731/2616 test.symlinkat... SKIP 732/2616 test.linkat... SKIP 733/2616 test.provide_buffers: read... SKIP 734/2616 test.remove_buffers... SKIP 735/2616 test.provide_buffers: accept/connect/send/recv... SKIP 736/2616 test.accept multishot... SKIP ``` --- lib/std/os/linux/io_uring.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index 2372dba09b..3b282422ae 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/lib/std/os/linux/io_uring.zig @@ -2072,6 +2072,7 @@ test "openat" { const cqe_openat = try ring.copy_cqe(); try testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data); if (cqe_openat.err() == .INVAL) return error.SkipZigTest; + if (cqe_openat.err() == .BADF) return error.SkipZigTest; if (cqe_openat.res <= 0) std.debug.print("\ncqe_openat.res={}\n", .{cqe_openat.res}); try testing.expect(cqe_openat.res > 0); try testing.expectEqual(@as(u32, 0), cqe_openat.flags); @@ -2500,6 +2501,8 @@ test "statx" { // The filesystem containing the file referred to by fd does not support this operation; // or the mode is not supported by the filesystem containing the file referred to by fd: .OPNOTSUPP => return error.SkipZigTest, + // not supported on older kernels (5.4) + .BADF => return error.SkipZigTest, else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), } try testing.expectEqual(linux.io_uring_cqe{ @@ -3145,6 +3148,7 @@ test "remove_buffers" { const cqe = try ring.copy_cqe(); switch (cqe.err()) { + .INVAL => return error.SkipZigTest, .SUCCESS => {}, else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), } @@ -3235,6 +3239,8 @@ test "provide_buffers: accept/connect/send/recv" { switch (cqe.err()) { // Happens when the kernel is < 5.7 .INVAL => return error.SkipZigTest, + // Happens on the kernel 5.4 + .BADF => return error.SkipZigTest, .SUCCESS => {}, else => |errno| std.debug.panic("unhandled errno: {}", .{errno}), }