Skip to content

Commit 09a4632

Browse files
abochvishvananda
authored andcommitted
Properly use Skip() function, add -test.v when running tests
- No need to separately log the skip message Signed-off-by: Alessandro Boch <[email protected]>
1 parent a47a543 commit 09a4632

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $(call goroot,$(DEPS)):
1919

2020
.PHONY: $(call testdirs,$(DIRS))
2121
$(call testdirs,$(DIRS)):
22-
sudo -E go test -test.parallel 4 -timeout 60s -v github.com/vishvananda/netlink/$@
22+
go test -test.exec sudo -test.parallel 4 -timeout 60s -test.v github.com/vishvananda/netlink/$@
2323

2424
$(call fmt,$(call testdirs,$(DIRS))):
2525
! gofmt -l $(subst fmt-,,$@)/*.go | grep -q .

netlink_test.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package netlink
33
import (
44
"fmt"
55
"io/ioutil"
6-
"log"
76
"os"
87
"runtime"
98
"strings"
@@ -17,9 +16,7 @@ type tearDownNetlinkTest func()
1716

1817
func skipUnlessRoot(t *testing.T) {
1918
if os.Getuid() != 0 {
20-
msg := "Skipped test because it requires root privileges."
21-
log.Printf(msg)
22-
t.Skip(msg)
19+
t.Skip("Test requires root privileges.")
2320
}
2421
}
2522

@@ -43,9 +40,7 @@ func setUpNetlinkTest(t *testing.T) tearDownNetlinkTest {
4340

4441
func setUpMPLSNetlinkTest(t *testing.T) tearDownNetlinkTest {
4542
if _, err := os.Stat("/proc/sys/net/mpls/platform_labels"); err != nil {
46-
msg := "Skipped test because it requires MPLS support."
47-
log.Printf(msg)
48-
t.Skip(msg)
43+
t.Skip("Test requires MPLS support.")
4944
}
5045
f := setUpNetlinkTest(t)
5146
setUpF := func(path, value string) {
@@ -76,9 +71,7 @@ func setUpNetlinkTestWithKModule(t *testing.T, name string) tearDownNetlinkTest
7671

7772
}
7873
if !found {
79-
msg := fmt.Sprintf("Skipped test because it requres kmodule %s.", name)
80-
log.Println(msg)
81-
t.Skip(msg)
74+
t.Skipf("Test requires kmodule %q.", name)
8275
}
8376
return setUpNetlinkTest(t)
8477
}

0 commit comments

Comments
 (0)