diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-11-28 14:51:12 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-11-28 15:45:07 +0100 |
| commit | 4325e66ebc806f5b00f3b7a895aba8dbd4f2d804 (patch) | |
| tree | c378fef602468e97772a7eadde6e3b4c63100df2 /pkg/host/syscalls_linux_test.go | |
| parent | 76b4dcc777ca842ee42225411c5c9d5ac3e91b8a (diff) | |
pkg/host: make wifi check more precise
WiFi setup fails on 4.4 kernel with:
2020/11/28 12:22:49 BUG: program execution failed: executor 0: exit status 67
initialize_wifi_devices: failed to create device #0 (errno 19)
There is at least HWSIM_ATTR_PERM_ADDR not support, but maybe something else.
The setup seems to work at least on 4.17 where HWSIM_ATTR_PERM_ADDR was added.
So require at least 4.17 for WiFi testing.
Diffstat (limited to 'pkg/host/syscalls_linux_test.go')
| -rw-r--r-- | pkg/host/syscalls_linux_test.go | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/pkg/host/syscalls_linux_test.go b/pkg/host/syscalls_linux_test.go index 5d4f60082..70adfbae9 100644 --- a/pkg/host/syscalls_linux_test.go +++ b/pkg/host/syscalls_linux_test.go @@ -6,6 +6,7 @@ package host import ( + "fmt" "runtime" "syscall" "testing" @@ -185,3 +186,120 @@ ffffffe0005c9c76 T __se_sys_listen } } } + +func TestMatchKernelVersion(t *testing.T) { + tests := []struct { + version string + major int + minor int + res bool + bad bool + }{ + { + version: "5.9.0-rc5-next-20200918", + major: 5, + minor: 8, + res: true, + }, + { + version: "5.9.0-rc5-next-20200918", + major: 4, + minor: 10, + res: true, + }, + { + version: "5.9.0-rc5-next-20200918", + major: 5, + minor: 9, + res: true, + }, + { + version: "5.9.0-rc5-next-20200918", + major: 5, + minor: 10, + res: false, + }, + { + version: "5.9.0-rc5-next-20200918", + major: 6, + minor: 0, + res: false, + }, + { + version: "4.4.246-19567-g2c01e3dada31", + major: 4, + minor: 3, + res: true, + }, + { + version: "4.4.246-19567-g2c01e3dada31", + major: 4, + minor: 4, + res: true, + }, + { + version: "5.17.17-1debian-amd64", + major: 5, + minor: 16, + res: true, + }, + { + version: "5.17.17-1debian-amd64", + major: 5, + minor: 17, + res: true, + }, + { + version: "3.5", + major: 3, + minor: 4, + res: true, + }, + { + version: "3.5", + major: 3, + minor: 5, + res: true, + }, + { + version: "3.5", + major: 3, + minor: 6, + res: false, + }, + { + version: "", + bad: true, + }, + { + version: "something unparsable", + bad: true, + }, + { + version: "mykernel 4.17-5", + bad: true, + }, + { + version: "999999.999999", + bad: true, + }, + { + version: "4.abc.def", + bad: true, + }, + } + for i, test := range tests { + t.Run(fmt.Sprint(i), func(t *testing.T) { + ok, bad := matchKernelVersion(test.version, test.major, test.minor) + if test.bad && !bad { + t.Fatal("want error, but got no error") + } + if !test.bad && bad { + t.Fatalf("want no error, but got error") + } + if test.res != ok { + t.Fatalf("want match %v, but got %v", test.res, ok) + } + }) + } +} |
