add parsing of real data from testdata with the splitProcStat function
This commit is contained in:
parent
b3a9d75932
commit
716cf26984
|
@ -4,6 +4,7 @@ package process
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -52,3 +53,22 @@ func Test_Process_splitProcStat(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func Test_Process_splitProcStat_fromFile(t *testing.T) {
|
||||
pid := "68927"
|
||||
ppid := "68044"
|
||||
statFile := "testdata/linux/proc/" + pid + "/stat"
|
||||
contents, err := ioutil.ReadFile(statFile)
|
||||
assert.NoError(t, err)
|
||||
fields := splitProcStat(contents)
|
||||
assert.Equal(t, fields[1], pid)
|
||||
assert.Equal(t, fields[2], "test(cmd).sh")
|
||||
assert.Equal(t, fields[3], "S")
|
||||
assert.Equal(t, fields[4], ppid)
|
||||
assert.Equal(t, fields[5], pid) // pgrp
|
||||
assert.Equal(t, fields[6], ppid) // session
|
||||
assert.Equal(t, fields[8], pid) // tpgrp
|
||||
assert.Equal(t, fields[18], "20") // priority
|
||||
assert.Equal(t, fields[20], "1") // num threads
|
||||
assert.Equal(t, fields[52], "0") // exit code
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
68927 (test(cmd).sh) S 68044 68927 68044 34818 68927 4194304 165 0 0 0 0 0 0 0 20 0 1 0 114413973 9961472 868 18446744073709551615 94388826710016 94388827626021 140725039102800 0 0 0 2 4 65536 1 0 0 17 1 0 0 0 0 0 94388827875984 94388827924080 94388835627008 140725039105503 140725039105528 140725039105528 140725039108073 0
|
Loading…
Reference in New Issue