Codebase list golang-github-cilium-ebpf / 05894a4
testutils: switch mustKernelVersion() over to internal.KernelVersion() Signed-off-by: Timo Beckers <timo@isovalent.com> Timo Beckers authored 3 years ago Timo Beckers committed 3 years ago
1 changed file(s) with 5 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
00 package testutils
11
22 import (
3 "bytes"
43 "errors"
5 "sync"
64 "testing"
75
86 "github.com/cilium/ebpf/internal"
9 "github.com/cilium/ebpf/internal/unix"
10 )
11
12 var (
13 kernelVersionOnce sync.Once
14 kernelVersion internal.Version
157 )
168
179 func mustKernelVersion() internal.Version {
18 kernelVersionOnce.Do(func() {
19 var uname unix.Utsname
20 err := unix.Uname(&uname)
21 if err != nil {
22 panic(err)
23 }
24
25 end := bytes.IndexByte(uname.Release[:], 0)
26 release := string(uname.Release[:end])
27
28 kernelVersion, err = internal.NewVersion(release)
29 if err != nil {
30 panic(err)
31 }
32 })
33
34 return kernelVersion
10 v, err := internal.KernelVersion()
11 if err != nil {
12 panic(err)
13 }
14 return v
3515 }
3616
3717 func CheckFeatureTest(t *testing.T, fn func() error) {