netlink/devlink_test.go

35 lines
632 B
Go
Raw Normal View History

// +build linux
package netlink
import (
"io/ioutil"
"strings"
"testing"
)
func setupDevlinkKModule(t *testing.T, name string) {
skipUnlessRoot(t)
file, err := ioutil.ReadFile("/proc/modules")
if err != nil {
t.Fatal("Failed to open /proc/modules", err)
}
for _, line := range strings.Split(string(file), "\n") {
n := strings.Split(line, " ")[0]
if n == name {
return
}
}
t.Skipf("Test requires kmodule %q.", name)
}
func TestDevLinkGetDeviceList(t *testing.T) {
minKernelRequired(t, 4, 12)
setUpNetlinkTestWithKModule(t, "devlink")
_, err := DevLinkGetDeviceList()
if err != nil {
t.Fatal(err)
}
}