Skip to content

Commit

Permalink
Mark skipUnlessRoot and minKernelRequired as test helpers
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tklauser authored and aboch committed Oct 24, 2023
1 parent d18d70b commit ccef072
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions netlink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
type tearDownNetlinkTest func()

func skipUnlessRoot(t *testing.T) {
t.Helper()

if os.Getuid() != 0 {
t.Skip("Test requires root privileges.")
}
Expand Down Expand Up @@ -187,6 +189,8 @@ func remountSysfs() error {
}

func minKernelRequired(t *testing.T, kernel, major int) {
t.Helper()

k, m, err := KernelVersion()
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit ccef072

Please sign in to comment.