-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathdriver_test.go
58 lines (55 loc) · 999 Bytes
/
driver_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
54
55
56
57
58
package openflow
import (
"testing"
"github.com/kandoo/beehive-netctrl/nom"
)
func TestOF10Match(t *testing.T) {
driver := of10Driver{}
matches := []nom.Match{
{
Fields: []nom.Field{
nom.EthSrc{
Addr: nom.MACAddr{1, 2, 3, 4, 5, 6},
Mask: nom.MaskNoneMAC,
},
},
},
{
Fields: []nom.Field{
nom.EthDst{
Addr: nom.MACAddr{1, 2, 3, 4, 5, 6},
Mask: nom.MaskNoneMAC,
},
},
},
{
Fields: []nom.Field{
nom.IPv4Src{
Addr: nom.IPv4Addr{1, 2, 3, 4},
Mask: nom.IPv4Addr{255, 255, 255, 0},
},
},
},
{
Fields: []nom.Field{
nom.IPv4Dst{
Addr: nom.IPv4Addr{127, 0, 0, 1},
Mask: nom.IPv4Addr{255, 255, 255, 128},
},
},
},
}
for _, m := range matches {
ofm, err := driver.ofMatch(m)
if err != nil {
t.Error(err)
}
nm, err := driver.nomMatch(ofm)
if err != nil {
t.Error(err)
}
if !nm.Equals(m) {
t.Errorf("invalid match conversion:\n\tactual=%#v\n\twant=%#v", nm, m)
}
}
}