From ccf5a6cc5c5070a130f4879069390933f9c738f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Igor=20Anic=CC=81?= Date: Fri, 17 Nov 2023 22:17:00 +0100 Subject: [PATCH] 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. --- lib/std/os/linux/io_uring.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/std/os/linux/io_uring.zig b/lib/std/os/linux/io_uring.zig index d2be31d5af..52bb74848c 100644 --- a/lib/std/os/linux/io_uring.zig +++ b/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; }