forked from milosgajdos/tenus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacvlan_linux_test.go
More file actions
66 lines (54 loc) · 1.44 KB
/
macvlan_linux_test.go
File metadata and controls
66 lines (54 loc) · 1.44 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
package tenus
import (
"net"
"testing"
"time"
)
type macvlnTest struct {
masterDev string
}
var macvlnTests = []macvlnTest{
{"master01"},
}
func Test_NewMacVlanLink(t *testing.T) {
for _, tt := range macvlnTests {
tl := &testLink{}
if err := tl.prepTestLink(tt.masterDev, "dummy"); err != nil {
t.Skipf("NewMacVlanLink test requries external command: %v", err)
}
if err := tl.create(); err != nil {
t.Fatalf("testLink.create failed: %v", err)
} else {
time.Sleep(10 * time.Millisecond)
}
mvln, err := NewMacVlanLink(tt.masterDev)
if err != nil {
t.Fatalf("NewMacVlanLink(%s) failed to run: %s", tt.masterDev, err)
}
mvlnName := mvln.NetInterface().Name
if _, err := net.InterfaceByName(mvlnName); err != nil {
tl.teardown()
t.Fatalf("Could not find %s on the host: %s", mvlnName, err)
}
testRes, err := linkInfo(mvlnName, "macvlan")
if err != nil {
tl.teardown()
t.Fatalf("Failed to list %s operation mode: %s", mvlnName, err)
}
if testRes.linkType != "macvlan" {
tl.teardown()
t.Fatalf("NewMacVlanLink(%s) failed: expected macvlan, returned %s",
tt.masterDev, testRes.linkType)
}
if testRes.linkData != "bridge" {
tl.teardown()
t.Fatalf("NewMacVlanLink(%s) failed: expected bridge, returned %s",
tt.masterDev, testRes.linkData)
}
if err := tl.teardown(); err != nil {
t.Fatalf("testLink.teardown failed: %v", err)
} else {
time.Sleep(10 * time.Millisecond)
}
}
}