Skip to content

Commit 90674f2

Browse files
committed
uname: add test for KernelVersion
Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 03a554f commit 90674f2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

uname/kernel_version_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2025 The uname Authors.
2+
package uname
3+
4+
import (
5+
"runtime"
6+
"testing"
7+
)
8+
9+
func TestKernelVersion(t *testing.T) {
10+
x, y := KernelVersion()
11+
t.Logf("KernelVersion: %d.%d (GOOS: %s)", x, y, runtime.GOOS)
12+
switch runtime.GOOS {
13+
case "linux":
14+
// Go requires Linux >= 2.x.
15+
if x < 2 {
16+
t.Errorf("want major >= 2, got %d", x)
17+
}
18+
// Sanity check.
19+
if y < 0 {
20+
t.Errorf("want minor >= 0, got %d", y)
21+
}
22+
default:
23+
if x != 0 || y != 0 {
24+
t.Fatalf("want 0.0, got %d.%d", x, y)
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)