diff options
author | Ian Lance Taylor <iant@golang.org> | 2016-10-05 07:31:11 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2016-10-06 01:23:09 +0000 |
commit | e5421e21effb5b1db4e565babbddffeb4103d40e (patch) | |
tree | 40ba512afd94405ac10a6dc8d78fe52333f4c93d /src/runtime/crash_cgo_test.go | |
parent | 5fd6bb4c14b395bc413f281987225b57ae5fe67c (diff) | |
download | go-e5421e21effb5b1db4e565babbddffeb4103d40e.tar.gz go-e5421e21effb5b1db4e565babbddffeb4103d40e.zip |
runtime: add threadprof tag for test that starts busy thread
The CgoExternalThreadSIGPROF test starts a thread at constructor time
that does a busy loop. That can throw off some other tests. So only
build that code if testprogcgo is built with the tag threadprof, and
adjust the tests that use that code to pass that build tag.
This revealed that the CgoPprofThread test was not testing what it
should have, as it never actually started the cpuHog thread. It was
passing because of the busy loop thread. Fix it to start the thread as
intended.
Change-Id: I087a9e4fc734a86be16a287456441afac5676beb
Reviewed-on: https://go-review.googlesource.com/30362
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/runtime/crash_cgo_test.go')
-rw-r--r-- | src/runtime/crash_cgo_test.go | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 2e2f95e5f0..2642c28f0d 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -100,9 +100,18 @@ func TestCgoExternalThreadSIGPROF(t *testing.T) { // ppc64 (issue #8912) t.Skipf("no external linking on ppc64") } - got := runTestProg(t, "testprogcgo", "CgoExternalThreadSIGPROF") - want := "OK\n" - if got != want { + + exe, err := buildTestProg(t, "testprogcgo", "-tags=threadprof") + if err != nil { + t.Fatal(err) + } + + got, err := testEnv(exec.Command(exe, "CgoExternalThreadSIGPROF")).CombinedOutput() + if err != nil { + t.Fatalf("exit status: %v\n%s", err, got) + } + + if want := "OK\n"; string(got) != want { t.Fatalf("expected %q, but got:\n%s", want, got) } } @@ -113,9 +122,19 @@ func TestCgoExternalThreadSignal(t *testing.T) { case "plan9", "windows": t.Skipf("no pthreads on %s", runtime.GOOS) } - got := runTestProg(t, "testprogcgo", "CgoExternalThreadSignal") - want := "OK\n" - if got != want { + + exe, err := buildTestProg(t, "testprogcgo", "-tags=threadprof") + if err != nil { + t.Fatal(err) + } + + got, err := testEnv(exec.Command(exe, "CgoExternalThreadSIGPROF")).CombinedOutput() + if err != nil { + t.Fatalf("exit status: %v\n%s", err, got) + } + + want := []byte("OK\n") + if !bytes.Equal(got, want) { t.Fatalf("expected %q, but got:\n%s", want, got) } } |