From 68c6a73380e82a0ea9a93c1a75ab8a38f28f3a3d Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 3 Sep 2025 16:12:39 -0700 Subject: internal/syscall/unix: add KernelVersionGE There are a few places in the code which checks that the running kernel is greater than or equal to x.y. The check takes a few lines and the checking code is somewhat distracting. Let's abstract this check into a simple function, KernelVersionGE, and convert the users accordingly. Add a test case (I'm not sure it has much value, can be dropped). Change-Id: I8ec91dcc7452363361f95e46794701c0ae57d956 Reviewed-on: https://go-review.googlesource.com/c/go/+/700796 LUCI-TryBot-Result: Go LUCI Reviewed-by: Damien Neil Reviewed-by: Mark Freeman --- src/os/exec/lp_linux_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/os/exec') diff --git a/src/os/exec/lp_linux_test.go b/src/os/exec/lp_linux_test.go index a7f9aa24b8..1436763038 100644 --- a/src/os/exec/lp_linux_test.go +++ b/src/os/exec/lp_linux_test.go @@ -19,7 +19,7 @@ func TestFindExecutableVsNoexec(t *testing.T) { t.Parallel() // This test case relies on faccessat2(2) syscall, which appeared in Linux v5.8. - if major, minor := unix.KernelVersion(); major < 5 || (major == 5 && minor < 8) { + if !unix.KernelVersionGE(5, 8) { t.Skip("requires Linux kernel v5.8 with faccessat2(2) syscall") } -- cgit v1.3-5-g9baa