forked from vishvananda/netlink
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrdma_link_test.go
53 lines (47 loc) · 979 Bytes
/
rdma_link_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// +build linux
package netlink
import (
"io/ioutil"
"strings"
"testing"
)
func setupRdmaKModule(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 TestRdmaGetRdmaLink(t *testing.T) {
minKernelRequired(t, 4, 16)
setupRdmaKModule(t, "ib_core")
_, err := RdmaLinkByName("foo")
if err != nil {
t.Fatal(err)
}
}
func TestRdmaSetRdmaLinkName(t *testing.T) {
minKernelRequired(t, 4, 19)
setupRdmaKModule(t, "ib_core")
link, err := RdmaLinkByName("foo")
if err != nil {
t.Fatal(err)
}
// Set new name
err = RdmaLinkSetName(link, "bar")
if err != nil {
t.Fatal(err)
}
// Revert back to old name
err = RdmaLinkSetName(link, "foo")
if err != nil {
t.Fatal(err)
}
}