...
1
2
3
4
5
6
7
8
9
10
11
12
13
14 package procfs
15
16 import "testing"
17
18 func TestProcSnmp(t *testing.T) {
19 p, err := getProcFixtures(t).Proc(26231)
20 if err != nil {
21 t.Fatal(err)
22 }
23
24 procSnmp, err := p.Snmp()
25 if err != nil {
26 t.Fatal(err)
27 }
28
29 for _, test := range []struct {
30 name string
31 want float64
32 have float64
33 }{
34 {name: "pid", want: 26231, have: float64(procSnmp.PID)},
35 {name: "IP:Forwarding", want: 2, have: *procSnmp.Ip.Forwarding},
36 {name: "IP:DefaultTTL", want: 64, have: *procSnmp.Ip.DefaultTTL},
37 {name: "Icmp:InMsgs", want: 45, have: *procSnmp.Icmp.InMsgs},
38 {name: "IcmpMsg:InType3", want: 45, have: *procSnmp.IcmpMsg.InType3},
39 {name: "IcmpMsg:OutType3", want: 50, have: *procSnmp.IcmpMsg.OutType3},
40 {name: "TCP:RtoAlgorithm", want: 1, have: *procSnmp.Tcp.RtoAlgorithm},
41 {name: "TCP:RtoMin", want: 200, have: *procSnmp.Tcp.RtoMin},
42 {name: "Udp:InDatagrams", want: 10179, have: *procSnmp.Udp.InDatagrams},
43 {name: "Udp:NoPorts", want: 50, have: *procSnmp.Udp.NoPorts},
44 {name: "UdpLite:InDatagrams", want: 0, have: *procSnmp.UdpLite.NoPorts},
45 {name: "UdpLite:NoPorts", want: 0, have: *procSnmp.UdpLite.NoPorts},
46 } {
47 if test.want != test.have {
48 t.Errorf("want %s %f, have %f", test.name, test.want, test.have)
49 }
50 }
51
52 }
53
View as plain text