MCPcopy Create free account
hub / github.com/prometheus/procfs / TestProcNetstat

Function TestProcNetstat

proc_netstat_test.go:21–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

19)
20
21func TestProcNetstat(t *testing.T) {
22 p, err := getProcFixtures(t).Proc(26231)
23 if err != nil {
24 t.Fatal(err)
25 }
26
27 procNetstat, err := p.Netstat()
28 if err != nil {
29 t.Fatal(err)
30 }
31
32 for _, test := range []struct {
33 name string
34 want float64
35 have float64
36 }{
37 {name: "pid", want: 26231, have: float64(procNetstat.PID)},
38 {name: "TcpExt:SyncookiesSent", want: 0, have: *procNetstat.SyncookiesSent},
39 {name: "TcpExt:EmbryonicRsts", want: 1, have: *procNetstat.EmbryonicRsts},
40 {name: "TcpExt:TW", want: 83, have: *procNetstat.TW},
41 {name: "TcpExt:PAWSEstab", want: 3640, have: *procNetstat.PAWSEstab},
42
43 {name: "IpExt:InNoRoutes", want: 0, have: *procNetstat.InNoRoutes},
44 {name: "IpExt:InMcastPkts", want: 208, have: *procNetstat.InMcastPkts},
45 {name: "IpExt:OutMcastPkts", want: 214, have: *procNetstat.OutMcastPkts},
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// TestParseProcNetstatLegacyFields covers TcpExt counters that are no longer
54// part of the kernel's TcpExt table but were still printed by older kernels.

Callers

nothing calls this directly

Calls 3

getProcFixturesFunction · 0.85
ProcMethod · 0.80
NetstatMethod · 0.80

Tested by

no test coverage detected