Commit ccf5a6cc5c

Igor Anić <igor.anic@gmail.com>
2023-11-17 22:17:00
io_uring: make Linux version check runtime instead od comptime
Reverting previous change. I'm building test bin and then running it in virtual machines with different kernels. So Linux kernel checks has to be runtime instead of comptime.
1 parent a7001b8
Changed files (1)
lib
std
os
lib/std/os/linux/io_uring.zig
@@ -4123,5 +4123,16 @@ test "openat_direct/close_direct" {
 /// For use in tests. Returns SkipZigTest is kernel version is less than required.
 fn skipKernelLessThan(required: std.SemanticVersion) !void {
     if (builtin.os.tag != .linux) return error.SkipZigTest;
-    if (required.order(builtin.os.version_range.linux.range.max) == .gt) return error.SkipZigTest;
+
+    var uts: linux.utsname = undefined;
+    const res = linux.uname(&uts);
+    switch (linux.getErrno(res)) {
+        .SUCCESS => {},
+        else => |errno| return os.unexpectedErrno(errno),
+    }
+
+    const release = mem.sliceTo(&uts.release, 0);
+    var current = try std.SemanticVersion.parse(release);
+    current.pre = null; // don't check pre field
+    if (required.order(current) == .gt) return error.SkipZigTest;
 }