-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathprocess_status_test.go
68 lines (60 loc) · 1.81 KB
/
process_status_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package linux
import (
"reflect"
"testing"
)
func TestReadProcessStatus(t *testing.T) {
status, err := ReadProcessStatus("proc/3323/status")
if err != nil {
t.Fatal("process io read fail", err)
}
expected := &ProcessStatus{
Name: "proftpd",
State: "S (sleeping)",
Tgid: 3323,
Pid: 3323,
PPid: 1,
TracerPid: 0,
RealUid: 0,
EffectiveUid: 111,
SavedSetUid: 0,
FilesystemUid: 111,
RealGid: 65534,
EffectiveGid: 65534,
SavedSetGid: 65534,
FilesystemGid: 65534,
FDSize: 32,
Groups: []int64{2001, 65534},
VmPeak: 16216,
VmSize: 16212,
VmLck: 0,
VmHWM: 2092,
VmRSS: 2088,
VmData: 872,
VmStk: 272,
VmExe: 696,
VmLib: 9416,
VmPTE: 36,
VmSwap: 0,
Threads: 1,
SigQLength: 0,
SigQLimit: 12091,
SigPnd: 0,
ShdPnd: 0,
SigBlk: 0,
SigIgn: 272633856,
SigCgt: 6450965743,
CapInh: 0,
CapPrm: 18446744073709551615,
CapEff: 0,
CapBnd: 18446744073709551615,
Seccomp: 0,
CpusAllowed: []uint32{255},
VoluntaryCtxtSwitches: 5899,
NonvoluntaryCtxtSwitches: 26,
}
if !reflect.DeepEqual(status, expected) {
t.Error("not equal to expected", expected)
}
t.Logf("%+v", status)
}