aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/crash_test.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2016-07-06 15:02:49 -0700
committerKeith Randall <khr@golang.org>2016-08-16 21:52:44 +0000
commite492d9f01890cf61cb009b3b3617238a8947ebbe (patch)
treebaef3dbdfd26c39b9261b967d0f7e7636c989452 /src/runtime/crash_test.go
parenta16a189fb96f824d1eaa53db9c0047c7ce334bd1 (diff)
downloadgo-e492d9f01890cf61cb009b3b3617238a8947ebbe.tar.gz
go-e492d9f01890cf61cb009b3b3617238a8947ebbe.zip
runtime: fix map iterator concurrent map check
We should check whether there is a concurrent writer at the start of every mapiternext, not just in mapaccessK (which is only called during certain map growth situations). Tests turned off by default because they are inherently flaky. Fixes #16278 Change-Id: I8b72cab1b8c59d1923bec6fa3eabc932e4e91542 Reviewed-on: https://go-review.googlesource.com/24749 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Diffstat (limited to 'src/runtime/crash_test.go')
-rw-r--r--src/runtime/crash_test.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/runtime/crash_test.go b/src/runtime/crash_test.go
index a2f7ff7dec..2f6afb60f6 100644
--- a/src/runtime/crash_test.go
+++ b/src/runtime/crash_test.go
@@ -6,6 +6,7 @@ package runtime_test
import (
"bytes"
+ "flag"
"fmt"
"internal/testenv"
"io/ioutil"
@@ -482,3 +483,39 @@ func TestMemPprof(t *testing.T) {
t.Error("missing MemProf in pprof output")
}
}
+
+var concurrentMapTest = flag.Bool("run_concurrent_map_tests", false, "also run flaky concurrent map tests")
+
+func TestConcurrentMapWrites(t *testing.T) {
+ if !*concurrentMapTest {
+ t.Skip("skipping without -run_concurrent_map_tests")
+ }
+ testenv.MustHaveGoRun(t)
+ output := runTestProg(t, "testprog", "concurrentMapWrites")
+ want := "fatal error: concurrent map writes"
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
+}
+func TestConcurrentMapReadWrite(t *testing.T) {
+ if !*concurrentMapTest {
+ t.Skip("skipping without -run_concurrent_map_tests")
+ }
+ testenv.MustHaveGoRun(t)
+ output := runTestProg(t, "testprog", "concurrentMapReadWrite")
+ want := "fatal error: concurrent map read and map write"
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
+}
+func TestConcurrentMapIterateWrite(t *testing.T) {
+ if !*concurrentMapTest {
+ t.Skip("skipping without -run_concurrent_map_tests")
+ }
+ testenv.MustHaveGoRun(t)
+ output := runTestProg(t, "testprog", "concurrentMapIterateWrite")
+ want := "fatal error: concurrent map iteration and map write"
+ if !strings.HasPrefix(output, want) {
+ t.Fatalf("output does not start with %q:\n%s", want, output)
+ }
+}