Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix data types for ignored stat fields #401 #402

Merged
merged 1 commit into from Jul 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 17 additions & 16 deletions proc_stat.go
Expand Up @@ -128,7 +128,8 @@ func (p Proc) Stat() (ProcStat, error) {
}

var (
ignore int
ignoreInt64 int64
ignoreUint64 uint64

s = ProcStat{PID: p.PID, proc: p.fs}
l = bytes.Index(data, []byte("("))
Expand Down Expand Up @@ -160,25 +161,25 @@ func (p Proc) Stat() (ProcStat, error) {
&s.Priority,
&s.Nice,
&s.NumThreads,
&ignore,
&ignoreInt64,
&s.Starttime,
&s.VSize,
&s.RSS,
&s.RSSLimit,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignore,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreUint64,
&ignoreInt64,
&ignoreInt64,
&s.RTPriority,
&s.Policy,
&s.DelayAcctBlkIOTicks,
Expand Down
12 changes: 12 additions & 0 deletions proc_stat_test.go
Expand Up @@ -76,6 +76,18 @@ func TestProcStat(t *testing.T) {
}
}

func TestProcStatIgnored(t *testing.T) {
p, err := getProcFixtures(t).Proc(26232)
if err != nil {
t.Fatal(err)
}

_, err = p.Stat()
if err != nil {
t.Errorf("want not error, have %s", err)
}
}

func TestProcStatComm(t *testing.T) {
s1, err := testProcStat(26231)
if err != nil {
Expand Down