(t *testing.T)
| 19 | ) |
| 20 | |
| 21 | func 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. |
nothing calls this directly
no test coverage detected