Mark skipUnlessRoot and minKernelRequired as test helpers

With this, the skip message will display the position of the
helper invocation (i.e. the test that caused the skip) instead of the
position of the t.Skip call in minKernelRequired the helper.
This commit is contained in:
Tobias Klauser 2023-10-06 13:24:47 +02:00 committed by Alessandro Boch
parent d18d70b0d9
commit ccef072df0
1 changed files with 4 additions and 0 deletions

View File

@ -24,6 +24,8 @@ import (
type tearDownNetlinkTest func() type tearDownNetlinkTest func()
func skipUnlessRoot(t *testing.T) { func skipUnlessRoot(t *testing.T) {
t.Helper()
if os.Getuid() != 0 { if os.Getuid() != 0 {
t.Skip("Test requires root privileges.") t.Skip("Test requires root privileges.")
} }
@ -187,6 +189,8 @@ func remountSysfs() error {
} }
func minKernelRequired(t *testing.T, kernel, major int) { func minKernelRequired(t *testing.T, kernel, major int) {
t.Helper()
k, m, err := KernelVersion() k, m, err := KernelVersion()
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)