diff --git a/nl/down_test.go b/nl/down_test.go index aa0467a..a3126bb 100644 --- a/nl/down_test.go +++ b/nl/down_test.go @@ -1,12 +1,18 @@ package nl import ( + "os" "testing" "github.com/vishvananda/netlink" ) func TestDownInterface(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root or network capabilities - skipped") + return + } + CreateTestInterface("lyft3") defer RemoveInterface("lyft3") @@ -20,6 +26,11 @@ func TestDownInterface(t *testing.T) { } func TestRemoveInterface(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root or network capabilities - skipped") + return + } + CreateTestInterface("lyft4") if err := RemoveInterface("lyft4"); err != nil { diff --git a/nl/up_test.go b/nl/up_test.go index 9dc1fe0..3ebc06a 100644 --- a/nl/up_test.go +++ b/nl/up_test.go @@ -2,6 +2,7 @@ package nl import ( "fmt" + "os" "testing" "github.com/vishvananda/netlink" @@ -24,6 +25,11 @@ func CreateTestInterface(name string) { } func TestUpInterface(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root or network capabilities - skipped") + return + } + CreateTestInterface("lyft1") defer RemoveInterface("lyft1") @@ -33,6 +39,11 @@ func TestUpInterface(t *testing.T) { } func TestUpInterfacePoll(t *testing.T) { + if os.Getuid() != 0 { + t.Skip("Test requires root or network capabilities - skipped") + return + } + CreateTestInterface("lyft2") defer RemoveInterface("lyft2")