aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc_test.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2018-12-20 20:21:45 +0000
committerMichael Knyszek <mknyszek@google.com>2018-12-21 18:42:22 +0000
commit429bae715876c69853bb63db1733f580e293c916 (patch)
tree8221714d4662026f340046c6c3841d4ed9b1a6a0 /src/runtime/proc_test.go
parent90dca98d33055b8365d9e7e40ebb4ca478daf77e (diff)
downloadgo-429bae715876c69853bb63db1733f580e293c916.tar.xz
runtime: skip TestLockOSThreadAvoidsStatePropagation if one can't unshare
This change splits a testprog out of TestLockOSThreadExit and makes it its own test. Then, this change makes the testprog exit prematurely with a special message if unshare fails with EPERM because not all of the builders allow the user to call the unshare syscall. Also, do some minor cleanup on the TestLockOSThread* tests. Fixes #29366. Change-Id: Id8a9f6c4b16e26af92ed2916b90b0249ba226dbe Reviewed-on: https://go-review.googlesource.com/c/155437 Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/proc_test.go')
-rw-r--r--src/runtime/proc_test.go21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/runtime/proc_test.go b/src/runtime/proc_test.go
index e6947d5849..1715324aa0 100644
--- a/src/runtime/proc_test.go
+++ b/src/runtime/proc_test.go
@@ -885,23 +885,28 @@ func TestLockOSThreadNesting(t *testing.T) {
func TestLockOSThreadExit(t *testing.T) {
testLockOSThreadExit(t, "testprog")
-
- want := "OK\n"
- output := runTestProg(t, "testprog", "LockOSThreadAvoidsStatePropagation", "GOMAXPROCS=1")
- if output != want {
- t.Errorf("want %s, got %s\n", want, output)
- }
}
func testLockOSThreadExit(t *testing.T, prog string) {
output := runTestProg(t, prog, "LockOSThreadMain", "GOMAXPROCS=1")
want := "OK\n"
if output != want {
- t.Errorf("want %s, got %s\n", want, output)
+ t.Errorf("want %q, got %q", want, output)
}
output = runTestProg(t, prog, "LockOSThreadAlt")
if output != want {
- t.Errorf("want %s, got %s\n", want, output)
+ t.Errorf("want %q, got %q", want, output)
+ }
+}
+
+func TestLockOSThreadAvoidsStatePropagation(t *testing.T) {
+ want := "OK\n"
+ skip := "unshare not permitted\n"
+ output := runTestProg(t, "testprog", "LockOSThreadAvoidsStatePropagation", "GOMAXPROCS=1")
+ if output == skip {
+ t.Skip("unshare syscall not permitted on this system")
+ } else if output != want {
+ t.Errorf("want %q, got %q", want, output)
}
}