mirror of https://github.com/vishvananda/netlink
35 lines
632 B
Go
35 lines
632 B
Go
|
// +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)
|
||
|
}
|
||
|
}
|