| ... | ... | @@ -1061,7 +1061,7 @@ test "write/read" { |
| 1061 | 1061 | testing.expectEqualSlices(u8, buffer_write[0..], buffer_read[0..]); |
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | | test "openat/close" { |
| 1064 | test "openat" { |
| 1065 | 1065 | if (builtin.os.tag != .linux) return error.SkipZigTest; |
| 1066 | 1066 | |
| 1067 | 1067 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { |
| ... | ... | @@ -1071,7 +1071,7 @@ test "openat/close" { |
| 1071 | 1071 | }; |
| 1072 | 1072 | defer ring.deinit(); |
| 1073 | 1073 | |
| 1074 | | const path = "test_io_uring_openat_close"; |
| 1074 | const path = "test_io_uring_openat"; |
| 1075 | 1075 | defer std.fs.cwd().deleteFile(path) catch {}; |
| 1076 | 1076 | |
| 1077 | 1077 | const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT; |
| ... | ... | @@ -1107,9 +1107,27 @@ test "openat/close" { |
| 1107 | 1107 | testing.expect(cqe_openat.res > 0); |
| 1108 | 1108 | testing.expectEqual(@as(u32, 0), cqe_openat.flags); |
| 1109 | 1109 | |
| 1110 | | const sqe_close = try ring.close(1011, cqe_openat.res); |
| 1110 | os.close(cqe_openat.res); |
| 1111 | } |
| 1112 | |
| 1113 | test "close" { |
| 1114 | if (builtin.os.tag != .linux) return error.SkipZigTest; |
| 1115 | |
| 1116 | var ring = IO_Uring.init(1, 0) catch |err| switch (err) { |
| 1117 | error.SystemOutdated => return error.SkipZigTest, |
| 1118 | error.PermissionDenied => return error.SkipZigTest, |
| 1119 | else => return err |
| 1120 | }; |
| 1121 | defer ring.deinit(); |
| 1122 | |
| 1123 | const path = "test_io_uring_close"; |
| 1124 | const file = try std.fs.cwd().createFile(path, .{}); |
| 1125 | errdefer file.close(); |
| 1126 | defer std.fs.cwd().deleteFile(path) catch {}; |
| 1127 | |
| 1128 | const sqe_close = try ring.close(1011, file.handle); |
| 1111 | 1129 | testing.expectEqual(linux.IORING_OP.CLOSE, sqe_close.opcode); |
| 1112 | | testing.expectEqual(cqe_openat.res, sqe_close.fd); |
| 1130 | testing.expectEqual(file.handle, sqe_close.fd); |
| 1113 | 1131 | testing.expectEqual(@as(u32, 1), try ring.submit()); |
| 1114 | 1132 | |
| 1115 | 1133 | const cqe_close = try ring.copy_cqe(); |