diff options
Diffstat (limited to 'libgo/go/path/path_test.go')
-rw-r--r-- | libgo/go/path/path_test.go | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/libgo/go/path/path_test.go b/libgo/go/path/path_test.go index 926b573..6297440 100644 --- a/libgo/go/path/path_test.go +++ b/libgo/go/path/path_test.go @@ -64,7 +64,6 @@ var cleantests = []PathTest{ } func TestClean(t *testing.T) { - defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(1)) for _, test := range cleantests { if s := Clean(test.path); s != test.result { t.Errorf("Clean(%q) = %q, want %q", test.path, s, test.result) @@ -74,22 +73,20 @@ func TestClean(t *testing.T) { } } - var ms runtime.MemStats - runtime.ReadMemStats(&ms) - allocs := -ms.Mallocs - const rounds = 100 - for i := 0; i < rounds; i++ { - for _, test := range cleantests { - Clean(test.result) - } + if runtime.GOMAXPROCS(0) > 1 { + t.Log("skipping AllocsPerRun checks; GOMAXPROCS>1") + return } - runtime.ReadMemStats(&ms) - allocs += ms.Mallocs - /* Fails with gccgo, which has no escape analysis. - if allocs >= rounds { - t.Errorf("Clean cleaned paths: %d allocations per test round, want zero", allocs/rounds) + + t.Log("Skipping AllocsPerRun for gccgo") + return + + for _, test := range cleantests { + allocs := testing.AllocsPerRun(100, func() { Clean(test.result) }) + if allocs > 0 { + t.Errorf("Clean(%q): %v allocs, want zero", test.result, allocs) + } } - */ } type SplitTest struct { |