* doc/invoke.texi (RS/6000 and PowerPC Options): Document -mhtm and
[official-gcc.git] / libgo / go / runtime / crash_cgo_test.go
blobd7b367f941f4a35e89a8d77828e105e2757dd97a
1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build cgo
7 package runtime_test
9 import (
10 "os/exec"
11 "runtime"
12 "strings"
13 "testing"
16 func TestCgoCrashHandler(t *testing.T) {
17 testCrashHandler(t, true)
20 func TestCgoSignalDeadlock(t *testing.T) {
21 if testing.Short() && runtime.GOOS == "windows" {
22 t.Skip("Skipping in short mode") // takes up to 64 seconds
24 got := runTestProg(t, "testprogcgo", "CgoSignalDeadlock")
25 want := "OK\n"
26 if got != want {
27 t.Fatalf("expected %q, but got:\n%s", want, got)
31 func TestCgoTraceback(t *testing.T) {
32 got := runTestProg(t, "testprogcgo", "CgoTraceback")
33 want := "OK\n"
34 if got != want {
35 t.Fatalf("expected %q, but got:\n%s", want, got)
39 func TestCgoCallbackGC(t *testing.T) {
40 if runtime.GOOS == "plan9" || runtime.GOOS == "windows" {
41 t.Skipf("no pthreads on %s", runtime.GOOS)
43 if testing.Short() {
44 switch {
45 case runtime.GOOS == "dragonfly":
46 t.Skip("see golang.org/issue/11990")
47 case runtime.GOOS == "linux" && runtime.GOARCH == "arm":
48 t.Skip("too slow for arm builders")
51 got := runTestProg(t, "testprogcgo", "CgoCallbackGC")
52 want := "OK\n"
53 if got != want {
54 t.Fatalf("expected %q, but got:\n%s", want, got)
58 func TestCgoExternalThreadPanic(t *testing.T) {
59 if runtime.GOOS == "plan9" {
60 t.Skipf("no pthreads on %s", runtime.GOOS)
62 got := runTestProg(t, "testprogcgo", "CgoExternalThreadPanic")
63 want := "panic: BOOM"
64 if !strings.Contains(got, want) {
65 t.Fatalf("want failure containing %q. output:\n%s\n", want, got)
69 func TestCgoExternalThreadSIGPROF(t *testing.T) {
70 // issue 9456.
71 switch runtime.GOOS {
72 case "plan9", "windows":
73 t.Skipf("no pthreads on %s", runtime.GOOS)
74 case "darwin":
75 if runtime.GOARCH != "arm" && runtime.GOARCH != "arm64" {
76 // static constructor needs external linking, but we don't support
77 // external linking on OS X 10.6.
78 out, err := exec.Command("uname", "-r").Output()
79 if err != nil {
80 t.Fatalf("uname -r failed: %v", err)
82 // OS X 10.6 == Darwin 10.x
83 if strings.HasPrefix(string(out), "10.") {
84 t.Skipf("no external linking on OS X 10.6")
88 if runtime.GOARCH == "ppc64" {
89 // TODO(austin) External linking not implemented on
90 // ppc64 (issue #8912)
91 t.Skipf("no external linking on ppc64")
93 got := runTestProg(t, "testprogcgo", "CgoExternalThreadSIGPROF")
94 want := "OK\n"
95 if got != want {
96 t.Fatalf("expected %q, but got:\n%s", want, got)
100 func TestCgoExternalThreadSignal(t *testing.T) {
101 // issue 10139
102 switch runtime.GOOS {
103 case "plan9", "windows":
104 t.Skipf("no pthreads on %s", runtime.GOOS)
106 got := runTestProg(t, "testprogcgo", "CgoExternalThreadSignal")
107 want := "OK\n"
108 if got != want {
109 t.Fatalf("expected %q, but got:\n%s", want, got)
113 func TestCgoDLLImports(t *testing.T) {
114 // test issue 9356
115 if runtime.GOOS != "windows" {
116 t.Skip("skipping windows specific test")
118 got := runTestProg(t, "testprogcgo", "CgoDLLImportsMain")
119 want := "OK\n"
120 if got != want {
121 t.Fatalf("expected %q, but got %v", want, got)
125 func TestCgoExecSignalMask(t *testing.T) {
126 // Test issue 13164.
127 switch runtime.GOOS {
128 case "windows", "plan9":
129 t.Skipf("skipping signal mask test on %s", runtime.GOOS)
131 got := runTestProg(t, "testprogcgo", "CgoExecSignalMask")
132 want := "OK\n"
133 if got != want {
134 t.Errorf("expected %q, got %v", want, got)
138 func TestEnsureDropM(t *testing.T) {
139 // Test for issue 13881.
140 switch runtime.GOOS {
141 case "windows", "plan9":
142 t.Skipf("skipping dropm test on %s", runtime.GOOS)
144 got := runTestProg(t, "testprogcgo", "EnsureDropM")
145 want := "OK\n"
146 if got != want {
147 t.Errorf("expected %q, got %v", want, got)