authorgravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-10-05 09:36:07+02:00
committergravatar for joran@ronomon.comJoran Dirk Greef <joran@ronomon.com> 2020-10-05 09:36:07+02:00
loge9ba12f456f37ec1f59a680cd9bf107e8e84e7b7
treeecff95f5362bf5cb496865437d94212b505f20a0
parent9be29410914e9d10171536fd275739dc8d1f437e

Test the range of user_data bits


1 files changed, 9 insertions(+), 9 deletions(-)

lib/std/os/linux/io_uring.zig+9-9
......@@ -1033,11 +1033,11 @@ test "write/read" {
10331033
10341034 const buffer_write = [_]u8{97} ** 20;
10351035 var buffer_read = [_]u8{98} ** 20;
1036 const sqe_write = try ring.write(123, fd, buffer_write[0..], 10);
1036 const sqe_write = try ring.write(0x11111111, fd, buffer_write[0..], 10);
10371037 testing.expectEqual(linux.IORING_OP.WRITE, sqe_write.opcode);
10381038 testing.expectEqual(@as(u64, 10), sqe_write.off);
10391039 sqe_write.flags |= linux.IOSQE_IO_LINK;
1040 const sqe_read = try ring.read(456, fd, buffer_read[0..], 10);
1040 const sqe_read = try ring.read(0x22222222, fd, buffer_read[0..], 10);
10411041 testing.expectEqual(linux.IORING_OP.READ, sqe_read.opcode);
10421042 testing.expectEqual(@as(u64, 10), sqe_read.off);
10431043 testing.expectEqual(@as(u32, 2), try ring.submit());
......@@ -1049,12 +1049,12 @@ test "write/read" {
10491049 if (cqe_write.res == -linux.EINVAL) return error.SkipZigTest;
10501050 if (cqe_read.res == -linux.EINVAL) return error.SkipZigTest;
10511051 testing.expectEqual(linux.io_uring_cqe {
1052 .user_data = 123,
1052 .user_data = 0x11111111,
10531053 .res = buffer_write.len,
10541054 .flags = 0,
10551055 }, cqe_write);
10561056 testing.expectEqual(linux.io_uring_cqe {
1057 .user_data = 456,
1057 .user_data = 0x22222222,
10581058 .res = buffer_read.len,
10591059 .flags = 0,
10601060 }, cqe_read);
......@@ -1076,7 +1076,7 @@ test "openat" {
10761076
10771077 const flags: u32 = os.O_CLOEXEC | os.O_RDWR | os.O_CREAT;
10781078 const mode: os.mode_t = 0o666;
1079 const sqe_openat = try ring.openat(789, linux.AT_FDCWD, path, flags, mode);
1079 const sqe_openat = try ring.openat(0x33333333, linux.AT_FDCWD, path, flags, mode);
10801080 testing.expectEqual(io_uring_sqe {
10811081 .opcode = .OPENAT,
10821082 .flags = 0,
......@@ -1086,7 +1086,7 @@ test "openat" {
10861086 .addr = @ptrToInt(path),
10871087 .len = mode,
10881088 .rw_flags = flags,
1089 .user_data = 789,
1089 .user_data = 0x33333333,
10901090 .buf_index = 0,
10911091 .personality = 0,
10921092 .splice_fd_in = 0,
......@@ -1095,7 +1095,7 @@ test "openat" {
10951095 testing.expectEqual(@as(u32, 1), try ring.submit());
10961096
10971097 const cqe_openat = try ring.copy_cqe();
1098 testing.expectEqual(@as(u64, 789), cqe_openat.user_data);
1098 testing.expectEqual(@as(u64, 0x33333333), cqe_openat.user_data);
10991099 if (cqe_openat.res == -linux.EINVAL) return error.SkipZigTest;
11001100 // AT_FDCWD is not fully supported before kernel 5.6:
11011101 // See https://lore.kernel.org/io-uring/20200207155039.12819-1-axboe@kernel.dk/T/
......@@ -1125,7 +1125,7 @@ test "close" {
11251125 errdefer file.close();
11261126 defer std.fs.cwd().deleteFile(path) catch {};
11271127
1128 const sqe_close = try ring.close(1011, file.handle);
1128 const sqe_close = try ring.close(0x44444444, file.handle);
11291129 testing.expectEqual(linux.IORING_OP.CLOSE, sqe_close.opcode);
11301130 testing.expectEqual(file.handle, sqe_close.fd);
11311131 testing.expectEqual(@as(u32, 1), try ring.submit());
......@@ -1133,7 +1133,7 @@ test "close" {
11331133 const cqe_close = try ring.copy_cqe();
11341134 if (cqe_close.res == -linux.EINVAL) return error.SkipZigTest;
11351135 testing.expectEqual(linux.io_uring_cqe {
1136 .user_data = 1011,
1136 .user_data = 0x44444444,
11371137 .res = 0,
11381138 .flags = 0,
11391139 }, cqe_close);