Properly use Skip() function, add -test.v when running tests

- No need to separately log the skip message

Signed-off-by: Alessandro Boch <aboch@tetrationanalytics.com>
This commit is contained in:
Alessandro Boch 2017-11-07 15:41:07 -08:00 committed by Vish (Ishaya) Abrams
parent a47a543cef
commit 09a46322b2
2 changed files with 4 additions and 11 deletions

View File

@ -19,7 +19,7 @@ $(call goroot,$(DEPS)):
.PHONY: $(call testdirs,$(DIRS))
$(call testdirs,$(DIRS)):
sudo -E go test -test.parallel 4 -timeout 60s -v github.com/vishvananda/netlink/$@
go test -test.exec sudo -test.parallel 4 -timeout 60s -test.v github.com/vishvananda/netlink/$@
$(call fmt,$(call testdirs,$(DIRS))):
! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .

View File

@ -3,7 +3,6 @@ package netlink
import (
"fmt"
"io/ioutil"
"log"
"os"
"runtime"
"strings"
@ -17,9 +16,7 @@ type tearDownNetlinkTest func()
func skipUnlessRoot(t *testing.T) {
if os.Getuid() != 0 {
msg := "Skipped test because it requires root privileges."
log.Printf(msg)
t.Skip(msg)
t.Skip("Test requires root privileges.")
}
}
@ -43,9 +40,7 @@ func setUpNetlinkTest(t *testing.T) tearDownNetlinkTest {
func setUpMPLSNetlinkTest(t *testing.T) tearDownNetlinkTest {
if _, err := os.Stat("/proc/sys/net/mpls/platform_labels"); err != nil {
msg := "Skipped test because it requires MPLS support."
log.Printf(msg)
t.Skip(msg)
t.Skip("Test requires MPLS support.")
}
f := setUpNetlinkTest(t)
setUpF := func(path, value string) {
@ -76,9 +71,7 @@ func setUpNetlinkTestWithKModule(t *testing.T, name string) tearDownNetlinkTest
}
if !found {
msg := fmt.Sprintf("Skipped test because it requres kmodule %s.", name)
log.Println(msg)
t.Skip(msg)
t.Skipf("Test requires kmodule %q.", name)
}
return setUpNetlinkTest(t)
}