diff options
Diffstat (limited to 'collector/netstat_linux_test.go')
-rw-r--r-- | collector/netstat_linux_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/collector/netstat_linux_test.go b/collector/netstat_linux_test.go index fde77a0..a27382b 100644 --- a/collector/netstat_linux_test.go +++ b/collector/netstat_linux_test.go | |||
@@ -20,6 +20,7 @@ import ( | |||
20 | 20 | ||
21 | func TestNetStats(t *testing.T) { | 21 | func TestNetStats(t *testing.T) { |
22 | testNetStats(t, "fixtures/proc/net/netstat") | 22 | testNetStats(t, "fixtures/proc/net/netstat") |
23 | testSNMPStats(t, "fixtures/proc/net/snmp") | ||
23 | testSNMP6Stats(t, "fixtures/proc/net/snmp6") | 24 | testSNMP6Stats(t, "fixtures/proc/net/snmp6") |
24 | } | 25 | } |
25 | 26 | ||
@@ -44,6 +45,27 @@ func testNetStats(t *testing.T, fileName string) { | |||
44 | } | 45 | } |
45 | } | 46 | } |
46 | 47 | ||
48 | func testSNMPStats(t *testing.T, fileName string) { | ||
49 | file, err := os.Open(fileName) | ||
50 | if err != nil { | ||
51 | t.Fatal(err) | ||
52 | } | ||
53 | defer file.Close() | ||
54 | |||
55 | snmpStats, err := parseNetStats(file, fileName) | ||
56 | if err != nil { | ||
57 | t.Fatal(err) | ||
58 | } | ||
59 | |||
60 | if want, got := "9", snmpStats["Udp"]["RcvbufErrors"]; want != got { | ||
61 | t.Errorf("want netstat Udp RcvbufErrors %s, got %s", want, got) | ||
62 | } | ||
63 | |||
64 | if want, got := "8", snmpStats["Udp"]["SndbufErrors"]; want != got { | ||
65 | t.Errorf("want netstat Udp SndbufErrors %s, got %s", want, got) | ||
66 | } | ||
67 | } | ||
68 | |||
47 | func testSNMP6Stats(t *testing.T, fileName string) { | 69 | func testSNMP6Stats(t *testing.T, fileName string) { |
48 | file, err := os.Open(fileName) | 70 | file, err := os.Open(fileName) |
49 | if err != nil { | 71 | if err != nil { |
@@ -63,4 +85,12 @@ func testSNMP6Stats(t *testing.T, fileName string) { | |||
63 | if want, got := "8", snmp6Stats["Icmp6"]["OutMsgs"]; want != got { | 85 | if want, got := "8", snmp6Stats["Icmp6"]["OutMsgs"]; want != got { |
64 | t.Errorf("want netstat ICPM6 OutMsgs %s, got %s", want, got) | 86 | t.Errorf("want netstat ICPM6 OutMsgs %s, got %s", want, got) |
65 | } | 87 | } |
88 | |||
89 | if want, got := "9", snmp6Stats["Udp6"]["RcvbufErrors"]; want != got { | ||
90 | t.Errorf("want netstat Udp6 RcvbufErrors %s, got %s", want, got) | ||
91 | } | ||
92 | |||
93 | if want, got := "8", snmp6Stats["Udp6"]["SndbufErrors"]; want != got { | ||
94 | t.Errorf("want netstat Udp6 SndbufErrors %s, got %s", want, got) | ||
95 | } | ||
66 | } | 96 | } |