mirror of
https://github.com/vishvananda/netlink.git
synced 2025-10-24 00:03:24 +08:00
Allow to skip tests based on min kernel version required
Signed-off-by: Alessandro Boch <aboch@tetrationanalytics.com>
This commit is contained in:

committed by
Vish (Ishaya) Abrams

parent
71fa81e220
commit
a47a543cef
@@ -3,14 +3,11 @@ package netlink
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestBridgeVlan(t *testing.T) {
|
func TestBridgeVlan(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 3, 10)
|
||||||
t.Skipf("Travis CI worker Linux kernel version (3.13) is too old for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
@@ -577,8 +577,10 @@ func TestFilterClsActBpfAddDel(t *testing.T) {
|
|||||||
QdiscType: "clsact",
|
QdiscType: "clsact",
|
||||||
}
|
}
|
||||||
// This feature was added in kernel 4.5
|
// This feature was added in kernel 4.5
|
||||||
|
minKernelRequired(t, 4, 5)
|
||||||
|
|
||||||
if err := QdiscAdd(qdisc); err != nil {
|
if err := QdiscAdd(qdisc); err != nil {
|
||||||
t.Skipf("Failed adding clsact qdisc, unsupported kernel")
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
qdiscs, err := SafeQdiscList(link)
|
qdiscs, err := SafeQdiscList(link)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
34
link_test.go
34
link_test.go
@@ -336,9 +336,8 @@ func TestLinkAddDelGretunPointToMultiPoint(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkAddDelGretapFlowBased(t *testing.T) {
|
func TestLinkAddDelGretapFlowBased(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
t.Skip("Fails with \"link_test.go:29: numerical result out of range\". Need to investigate.")
|
||||||
t.Skipf("Kernel in travis is too old for this test")
|
minKernelRequired(t, 4, 3)
|
||||||
}
|
|
||||||
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -732,9 +731,7 @@ func TestLinkAddDelVxlan(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkAddDelVxlanGbp(t *testing.T) {
|
func TestLinkAddDelVxlanGbp(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 4, 0)
|
||||||
t.Skipf("Kernel in travis is too old for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -765,9 +762,7 @@ func TestLinkAddDelVxlanGbp(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkAddDelVxlanFlowBased(t *testing.T) {
|
func TestLinkAddDelVxlanFlowBased(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 4, 3)
|
||||||
t.Skipf("Kernel in travis is too old for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -784,9 +779,7 @@ func TestLinkAddDelVxlanFlowBased(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkAddDelIPVlanL2(t *testing.T) {
|
func TestLinkAddDelIPVlanL2(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 4, 2)
|
||||||
t.Skipf("Kernel in travis is too old for this test")
|
|
||||||
}
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
parent := &Dummy{LinkAttrs{Name: "foo"}}
|
parent := &Dummy{LinkAttrs{Name: "foo"}}
|
||||||
@@ -806,9 +799,7 @@ func TestLinkAddDelIPVlanL2(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkAddDelIPVlanL3(t *testing.T) {
|
func TestLinkAddDelIPVlanL3(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 4, 2)
|
||||||
t.Skipf("Kernel in travis is too old for this test")
|
|
||||||
}
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
parent := &Dummy{LinkAttrs{Name: "foo"}}
|
parent := &Dummy{LinkAttrs{Name: "foo"}}
|
||||||
@@ -1218,6 +1209,7 @@ func TestLinkXdp(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestLinkAddDelIptun(t *testing.T) {
|
func TestLinkAddDelIptun(t *testing.T) {
|
||||||
|
minKernelRequired(t, 4, 9)
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
|
||||||
@@ -1252,9 +1244,7 @@ func TestLinkAddDelVti(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBridgeCreationWithMulticastSnooping(t *testing.T) {
|
func TestBridgeCreationWithMulticastSnooping(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 4, 4)
|
||||||
t.Skipf("Travis CI worker Linux kernel version (3.13) is too old for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -1293,9 +1283,7 @@ func TestBridgeCreationWithMulticastSnooping(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBridgeSetMcastSnoop(t *testing.T) {
|
func TestBridgeSetMcastSnoop(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 4, 4)
|
||||||
t.Skipf("Travis CI worker Linux kernel version (3.13) is too old for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
@@ -1334,9 +1322,7 @@ func expectMcastSnooping(t *testing.T, linkName string, expected bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestBridgeCreationWithHelloTime(t *testing.T) {
|
func TestBridgeCreationWithHelloTime(t *testing.T) {
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
minKernelRequired(t, 3, 18)
|
||||||
t.Skipf("Travis CI worker Linux kernel version (3.13) is too old for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
tearDown := setUpNetlinkTest(t)
|
tearDown := setUpNetlinkTest(t)
|
||||||
defer tearDown()
|
defer tearDown()
|
||||||
|
@@ -92,3 +92,34 @@ func remountSysfs() error {
|
|||||||
}
|
}
|
||||||
return unix.Mount("", "/sys", "sysfs", 0, "")
|
return unix.Mount("", "/sys", "sysfs", 0, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func minKernelRequired(t *testing.T, kernel, major int) {
|
||||||
|
k, m, err := KernelVersion()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if k < kernel || k == kernel && m < major {
|
||||||
|
t.Skipf("Host Kernel (%d.%d) does not meet test's minimum required version: (%d.%d)",
|
||||||
|
k, m, kernel, major)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func KernelVersion() (kernel, major int, err error) {
|
||||||
|
uts := unix.Utsname{}
|
||||||
|
if err = unix.Uname(&uts); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
ba := make([]byte, 0, len(uts.Release))
|
||||||
|
for _, b := range uts.Release {
|
||||||
|
if b == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
ba = append(ba, byte(b))
|
||||||
|
}
|
||||||
|
var rest string
|
||||||
|
if n, _ := fmt.Sscanf(string(ba), "%d.%d%s", &kernel, &major, &rest); n < 2 {
|
||||||
|
err = fmt.Errorf("can't parse kernel version in %q", string(ba))
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
@@ -3,7 +3,6 @@
|
|||||||
package netlink
|
package netlink
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -121,9 +120,8 @@ func TestProtinfo(t *testing.T) {
|
|||||||
t.Fatalf("Set protinfo attrs for link without master is not supported, but err: %s", err)
|
t.Fatalf("Set protinfo attrs for link without master is not supported, but err: %s", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if os.Getenv("TRAVIS_BUILD_DIR") != "" {
|
// Setting kernel requirement for next tests which require BR_PROXYARP
|
||||||
t.Skipf("Skipped some tests because travis kernel is to old to support BR_PROXYARP.")
|
minKernelRequired(t, 3, 19)
|
||||||
}
|
|
||||||
|
|
||||||
if err := LinkSetBrProxyArp(iface4, true); err != nil {
|
if err := LinkSetBrProxyArp(iface4, true); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
|
Reference in New Issue
Block a user