Commit f5f28e0d2c

Jacob Young <jacobly0@users.noreply.github.com>
2022-10-02 02:40:18
io_uring: ignore SOCK_NONEMPTY for reproducible tests
Fixes #12670
1 parent 0eb3b8f
Changed files (2)
lib
lib/std/os/linux/io_uring.zig
@@ -2007,7 +2007,8 @@ test "accept/connect/send/recv" {
     try testing.expectEqual(linux.io_uring_cqe{
         .user_data = 0xffffffff,
         .res = buffer_recv.len,
-        .flags = 0,
+        // ignore IORING_CQE_F_SOCK_NONEMPTY since it is only set on some systems
+        .flags = cqe_recv.flags & linux.IORING_CQE_F_SOCK_NONEMPTY,
     }, cqe_recv);
 
     try testing.expectEqualSlices(u8, buffer_send[0..buffer_recv.len], buffer_recv[0..]);
@@ -2089,7 +2090,8 @@ test "sendmsg/recvmsg" {
     try testing.expectEqual(linux.io_uring_cqe{
         .user_data = 0x22222222,
         .res = buffer_recv.len,
-        .flags = 0,
+        // ignore IORING_CQE_F_SOCK_NONEMPTY since it is set non-deterministically
+        .flags = cqe_recvmsg.flags & linux.IORING_CQE_F_SOCK_NONEMPTY,
     }, cqe_recvmsg);
 
     try testing.expectEqualSlices(u8, buffer_send[0..buffer_recv.len], buffer_recv[0..]);
lib/std/os/linux.zig
@@ -3761,6 +3761,8 @@ pub const IORING_CQE_F_BUFFER = 1 << 0;
 pub const IORING_CQE_F_MORE = 1 << 1;
 /// If set, more data to read after socket recv
 pub const IORING_CQE_F_SOCK_NONEMPTY = 1 << 2;
+/// Set for notification CQEs. Can be used to distinct them from sends.
+pub const IORING_CQE_F_NOTIF = 1 << 3;
 
 /// Magic offsets for the application to mmap the data it needs
 pub const IORING_OFF_SQ_RING = 0;