diff --git a/proc_limits.go b/proc_limits.go index 9530b14b..7dc6c43f 100644 --- a/proc_limits.go +++ b/proc_limits.go @@ -19,6 +19,7 @@ import ( "os" "regexp" "strconv" + "strings" ) // ProcLimits represents the soft limits for each of the process's resource @@ -106,7 +107,7 @@ func (p Proc) Limits() (ProcLimits, error) { return ProcLimits{}, fmt.Errorf("%w: couldn't parse %q line %q", ErrFileParse, f.Name(), s.Text()) } - switch fields[1] { + switch strings.TrimSpace(fields[1]) { case "Max cpu time": l.CPUTime, err = parseUint(fields[2]) case "Max file size": diff --git a/proc_limits_test.go b/proc_limits_test.go index bb8ae61b..ba41a267 100644 --- a/proc_limits_test.go +++ b/proc_limits_test.go @@ -32,10 +32,21 @@ func TestLimits(t *testing.T) { have uint64 }{ {name: "cpu time", want: 18446744073709551615, have: l.CPUTime}, + {name: "file size", want: 18446744073709551615, have: l.FileSize}, + {name: "data size", want: 18446744073709551615, have: l.DataSize}, + {name: "stack size", want: 8388608, have: l.StackSize}, + {name: "core file size", want: 0, have: l.CoreFileSize}, + {name: "resident set", want: 18446744073709551615, have: l.ResidentSet}, + {name: "processes", want: 62898, have: l.Processes}, {name: "open files", want: 2048, have: l.OpenFiles}, + {name: "locked memory", want: 18446744073708503040, have: l.LockedMemory}, + {name: "address space", want: 8589934592, have: l.AddressSpace}, + {name: "file locks", want: 18446744073709551615, have: l.FileLocks}, + {name: "pending signals", want: 62898, have: l.PendingSignals}, {name: "msgqueue size", want: 819200, have: l.MsqqueueSize}, {name: "nice priority", want: 0, have: l.NicePriority}, - {name: "address space", want: 8589934592, have: l.AddressSpace}, + {name: "realtime priority", want: 0, have: l.RealtimePriority}, + {name: "realtime timeout", want: 18446744073709551615, have: l.RealtimeTimeout}, } { if test.want != test.have { t.Errorf("want %s %d, have %d", test.name, test.want, test.have)