netlink/devlink_test.go

55 lines
1.0 KiB
Go
Raw Normal View History

// +build linux
package netlink
import (
"testing"
)
func TestDevLinkGetDeviceList(t *testing.T) {
minKernelRequired(t, 4, 12)
setUpNetlinkTestWithKModule(t, "devlink")
_, err := DevLinkGetDeviceList()
if err != nil {
t.Fatal(err)
}
}
func TestDevLinkGetDeviceByName(t *testing.T) {
minKernelRequired(t, 4, 12)
setUpNetlinkTestWithKModule(t, "devlink")
_, err := DevLinkGetDeviceByName("foo", "bar")
if err != nil {
t.Fatal(err)
}
}
func TestDevLinkSetEswitchMode(t *testing.T) {
minKernelRequired(t, 4, 12)
setUpNetlinkTestWithKModule(t, "devlink")
dev, err := DevLinkGetDeviceByName("foo", "bar")
if err != nil {
t.Fatal(err)
}
err = DevLinkSetEswitchMode(dev, "switchdev")
if err != nil {
t.Fatal(err)
}
err = DevLinkSetEswitchMode(dev, "legacy")
if err != nil {
t.Fatal(err)
}
}
func TestDevLinkGetAllPortList(t *testing.T) {
minKernelRequired(t, 5, 4)
ports, err := DevLinkGetAllPortList()
if err != nil {
t.Fatal(err)
}
t.Log("devlink port count = ", len(ports))
for _, port := range ports {
t.Log(*port)
}
}