...
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package procfs
15
16 import (
17 "net"
18 "testing"
19 )
20
21 func TestARP(t *testing.T) {
22 fs, err := NewFS(procTestFixtures)
23 if err != nil {
24 t.Fatal(err)
25 }
26
27 arpFile, err := fs.GatherARPEntries()
28 if err != nil {
29 t.Fatal(err)
30 }
31
32 if want, got := "192.168.224.1", arpFile[0].IPAddr.String(); want != got {
33 t.Errorf("want 192.168.224.1, got %s", got)
34 }
35
36 if want, got := "00:50:56:c0:00:08", arpFile[0].HWAddr.String(); want != got {
37 t.Errorf("want %s, got %s", want, got)
38 }
39
40 if want, got := "ens33", arpFile[0].Device; want != got {
41 t.Errorf("want ens33, got %s", got)
42 }
43
44 if want, got := true, arpFile[0].IsComplete(); want != got {
45 t.Errorf("want %t, got %t", want, got)
46 }
47
48 if want, got := "192.168.224.2", arpFile[1].IPAddr.String(); want != got {
49 t.Errorf("want 192.168.224.2, got %s", got)
50 }
51
52 if want, got := make(net.HardwareAddr, 6).String(), arpFile[1].HWAddr.String(); want != got {
53 t.Errorf("expected empty MAC, got %s", got)
54 }
55
56 if want, got := "ens33", arpFile[1].Device; want != got {
57 t.Errorf("want %s, got %s", want, got)
58 }
59
60 if want, got := byte(0x0), arpFile[1].Flags; want != got {
61 t.Errorf("want %b, got %b", want, got)
62 }
63
64 if want, got := false, arpFile[1].IsComplete(); want != got {
65 t.Errorf("want %t, got %t", want, got)
66 }
67 }
68
View as plain text