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

proc_stat_test.go: architecture dependent MinInt and MaxInt constants #437

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 8 additions & 3 deletions proc_stat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package procfs

import (
"math"
"math/bits"
"os"
"testing"
)
Expand Down Expand Up @@ -88,14 +88,19 @@ func TestProcStatLimits(t *testing.T) {
t.Errorf("want not error, have %s", err)
}

// architecture dependent MinInt and MaxInt constants
const (
MinInt int = ((1 << bits.UintSize) / -2) // math.MinInt
MaxInt int = (((1 << bits.UintSize) / 2) - 1) // math.MaxInt
)
// max values of stat int fields
for _, test := range []struct {
name string
want int
have int
}{
{name: "waited for children user time", want: math.MinInt64, have: s.CUTime},
{name: "waited for children system time", want: math.MaxInt64, have: s.CSTime},
{name: "waited for children user time", want: MinInt, have: s.CUTime},
{name: "waited for children system time", want: MaxInt, have: s.CSTime},
} {
if test.want != test.have {
t.Errorf("want %s %d, have %d", test.name, test.want, test.have)
Expand Down