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)) .PHONY: $(call testdirs,$(DIRS))
$(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))): $(call fmt,$(call testdirs,$(DIRS))):
! gofmt -l $(subst fmt-,,$@)/*.go | grep -q . ! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .

View File

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