Debian Codegraph @

libgo/go/runtime/crash_cgo_test.go

raw
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.
4
5 //go:build cgo
6
7 package runtime_test
8
9 import (
10 "fmt"
11 "internal/testenv"
12 "os"
13 "os/exec"
14 "runtime"
15 "strconv"
16 "strings"
17 "testing"
18 "time"
19 )
20
21 func TestCgoCrashHandler(t *testing.T) {
22 t.Parallel()
23 testCrashHandler(t, true)
24 }
25
26 func TestCgoSignalDeadlock(t *testing.T) {
27 // Don't call t.Parallel, since too much work going on at the
28 // same time can cause the testprogcgo code to overrun its
29 // timeouts (issue #18598).
30
31 if testing.Short() && runtime.GOOS == "windows" {
32 t.Skip("Skipping in short mode") // takes up to 64 seconds
33 }
34 got := runTestProg(t, "testprogcgo", "CgoSignalDeadlock")
35 want := "OK\n"
36 if got != want {
37 t.Fatalf("expected %q, but got:\n%s", want, got)
38 }
39 }
40
41 func TestCgoTraceback(t *testing.T) {
42 t.Parallel()
43 got := runTestProg(t, "testprogcgo", "CgoTraceback")
44 want := "OK\n"
45 if got != want {
46 t.Fatalf("expected %q, but got:\n%s", want, got)
47 }
48 }
49
50 func TestCgoCallbackGC(t *testing.T) {
51 t.Parallel()
52 switch runtime.GOOS {
53 case "plan9", "windows":
54 t.Skipf("no pthreads on %s", runtime.GOOS)
55 }
56 if testing.Short() {
57 switch {
58 case runtime.GOOS == "dragonfly":
59 t.Skip("see golang.org/issue/11990")
60 case runtime.GOOS == "linux" && runtime.GOARCH == "arm":
61 t.Skip("too slow for arm builders")
62 case runtime.GOOS == "linux" && (runtime.GOARCH == "mips64" || runtime.GOARCH == "mips64le"):
63 t.Skip("too slow for mips64x builders")
64 }
65 }
66 if testenv.Builder() == "darwin-amd64-10_14" {
67 // TODO(#23011): When the 10.14 builders are gone, remove this skip.
68 t.Skip("skipping due to platform bug on macOS 10.14; see https://golang.org/issue/43926")
69 }
70 got := runTestProg(t, "testprogcgo", "CgoCallbackGC")
71 want := "OK\n"
72 if got != want {
73 t.Fatalf("expected %q, but got:\n%s", want, got)
74 }
75 }
76
77 func TestCgoExternalThreadPanic(t *testing.T) {
78 t.Parallel()
79 if runtime.GOOS == "plan9" {
80 t.Skipf("no pthreads on %s", runtime.GOOS)
81 }
82 got := runTestProg(t, "testprogcgo", "CgoExternalThreadPanic")
83 want := "panic: BOOM"
84 if !strings.Contains(got, want) {
85 t.Fatalf("want failure containing %q. output:\n%s\n", want, got)
86 }
87 }
88
89 func TestCgoExternalThreadSIGPROF(t *testing.T) {
90 t.Parallel()
91 // issue 9456.
92 switch runtime.GOOS {
93 case "plan9", "windows":
94 t.Skipf("no pthreads on %s", runtime.GOOS)
95 }
96
97 got := runTestProg(t, "testprogcgo", "CgoExternalThreadSIGPROF", "GO_START_SIGPROF_THREAD=1")
98 if want := "OK\n"; got != want {
99 t.Fatalf("expected %q, but got:\n%s", want, got)
100 }
101 }
102
103 func TestCgoExternalThreadSignal(t *testing.T) {
104 t.Parallel()
105 // issue 10139
106 switch runtime.GOOS {
107 case "plan9", "windows":
108 t.Skipf("no pthreads on %s", runtime.GOOS)
109 }
110
111 got := runTestProg(t, "testprogcgo", "CgoExternalThreadSignal")
112 if want := "OK\n"; got != want {
113 t.Fatalf("expected %q, but got:\n%s", want, got)
114 }
115 }
116
117 func TestCgoDLLImports(t *testing.T) {
118 // test issue 9356
119 if runtime.GOOS != "windows" {
120 t.Skip("skipping windows specific test")
121 }
122 got := runTestProg(t, "testprogcgo", "CgoDLLImportsMain")
123 want := "OK\n"
124 if got != want {
125 t.Fatalf("expected %q, but got %v", want, got)
126 }
127 }
128
129 func TestCgoExecSignalMask(t *testing.T) {
130 t.Parallel()
131 // Test issue 13164.
132 switch runtime.GOOS {
133 case "windows", "plan9":
134 t.Skipf("skipping signal mask test on %s", runtime.GOOS)
135 }
136 got := runTestProg(t, "testprogcgo", "CgoExecSignalMask", "GOTRACEBACK=system")
137 want := "OK\n"
138 if got != want {
139 t.Errorf("expected %q, got %v", want, got)
140 }
141 }
142
143 func TestEnsureDropM(t *testing.T) {
144 t.Parallel()
145 // Test for issue 13881.
146 switch runtime.GOOS {
147 case "windows", "plan9":
148 t.Skipf("skipping dropm test on %s", runtime.GOOS)
149 }
150 got := runTestProg(t, "testprogcgo", "EnsureDropM")
151 want := "OK\n"
152 if got != want {
153 t.Errorf("expected %q, got %v", want, got)
154 }
155 }
156
157 // Test for issue 14387.
158 // Test that the program that doesn't need any cgo pointer checking
159 // takes about the same amount of time with it as without it.
160 func TestCgoCheckBytes(t *testing.T) {
161 t.Parallel()
162 // Make sure we don't count the build time as part of the run time.
163 testenv.MustHaveGoBuild(t)
164 exe, err := buildTestProg(t, "testprogcgo")
165 if err != nil {
166 t.Fatal(err)
167 }
168
169 // Try it 10 times to avoid flakiness.
170 const tries = 10
171 var tot1, tot2 time.Duration
172 for i := 0; i < tries; i++ {
173 cmd := testenv.CleanCmdEnv(exec.Command(exe, "CgoCheckBytes"))
174 cmd.Env = append(cmd.Env, "GODEBUG=cgocheck=0", fmt.Sprintf("GO_CGOCHECKBYTES_TRY=%d", i))
175
176 start := time.Now()
177 cmd.Run()
178 d1 := time.Since(start)
179
180 cmd = testenv.CleanCmdEnv(exec.Command(exe, "CgoCheckBytes"))
181 cmd.Env = append(cmd.Env, fmt.Sprintf("GO_CGOCHECKBYTES_TRY=%d", i))
182
183 start = time.Now()
184 cmd.Run()
185 d2 := time.Since(start)
186
187 if d1*20 > d2 {
188 // The slow version (d2) was less than 20 times
189 // slower than the fast version (d1), so OK.
190 return
191 }
192
193 tot1 += d1
194 tot2 += d2
195 }
196
197 t.Errorf("cgo check too slow: got %v, expected at most %v", tot2/tries, (tot1/tries)*20)
198 }
199
200 func TestCgoPanicDeadlock(t *testing.T) {
201 t.Parallel()
202 // test issue 14432
203 got := runTestProg(t, "testprogcgo", "CgoPanicDeadlock")
204 want := "panic: cgo error\n\n"
205 if !strings.HasPrefix(got, want) {
206 t.Fatalf("output does not start with %q:\n%s", want, got)
207 }
208 }
209
210 func TestCgoCCodeSIGPROF(t *testing.T) {
211 t.Parallel()
212 got := runTestProg(t, "testprogcgo", "CgoCCodeSIGPROF")
213 want := "OK\n"
214 if got != want {
215 t.Errorf("expected %q got %v", want, got)
216 }
217 }
218
219 func TestCgoPprofCallback(t *testing.T) {
220 t.Parallel()
221 switch runtime.GOOS {
222 case "windows", "plan9":
223 t.Skipf("skipping cgo pprof callback test on %s", runtime.GOOS)
224 }
225 got := runTestProg(t, "testprogcgo", "CgoPprofCallback")
226 want := "OK\n"
227 if got != want {
228 t.Errorf("expected %q got %v", want, got)
229 }
230 }
231
232 func TestCgoCrashTraceback(t *testing.T) {
233 t.Parallel()
234 switch platform := runtime.GOOS + "/" + runtime.GOARCH; platform {
235 case "darwin/amd64":
236 case "linux/amd64":
237 case "linux/ppc64le":
238 default:
239 t.Skipf("not yet supported on %s", platform)
240 }
241 if runtime.Compiler == "gccgo" {
242 t.Skip("gccgo does not have SetCgoTraceback")
243 }
244 got := runTestProg(t, "testprogcgo", "CrashTraceback")
245 for i := 1; i <= 3; i++ {
246 if !strings.Contains(got, fmt.Sprintf("cgo symbolizer:%d", i)) {
247 t.Errorf("missing cgo symbolizer:%d", i)
248 }
249 }
250 }
251
252 func TestCgoCrashTracebackGo(t *testing.T) {
253 t.Parallel()
254 switch platform := runtime.GOOS + "/" + runtime.GOARCH; platform {
255 case "darwin/amd64":
256 case "linux/amd64":
257 case "linux/ppc64le":
258 default:
259 t.Skipf("not yet supported on %s", platform)
260 }
261 if runtime.Compiler == "gccgo" {
262 t.Skip("gccgo does not have SetCgoTraceback")
263 }
264 got := runTestProg(t, "testprogcgo", "CrashTracebackGo")
265 for i := 1; i <= 3; i++ {
266 want := fmt.Sprintf("main.h%d", i)
267 if !strings.Contains(got, want) {
268 t.Errorf("missing %s", want)
269 }
270 }
271 }
272
273 func TestCgoTracebackContext(t *testing.T) {
274 t.Parallel()
275 if runtime.Compiler == "gccgo" {
276 t.Skip("gccgo does not have SetCgoTraceback")
277 }
278 got := runTestProg(t, "testprogcgo", "TracebackContext")
279 want := "OK\n"
280 if got != want {
281 t.Errorf("expected %q got %v", want, got)
282 }
283 }
284
285 func TestCgoTracebackContextPreemption(t *testing.T) {
286 t.Parallel()
287 if runtime.Compiler == "gccgo" {
288 t.Skip("gccgo does not have SetCgoTraceback")
289 }
290 got := runTestProg(t, "testprogcgo", "TracebackContextPreemption")
291 want := "OK\n"
292 if got != want {
293 t.Errorf("expected %q got %v", want, got)
294 }
295 }
296
297 func testCgoPprof(t *testing.T, buildArg, runArg, top, bottom string) {
298 t.Parallel()
299 if runtime.GOOS != "linux" || (runtime.GOARCH != "amd64" && runtime.GOARCH != "ppc64le") {
300 t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
301 }
302 if runtime.Compiler == "gccgo" {
303 t.Skip("gccgo does not have SetCgoTraceback")
304 }
305 testenv.MustHaveGoRun(t)
306
307 exe, err := buildTestProg(t, "testprogcgo", buildArg)
308 if err != nil {
309 t.Fatal(err)
310 }
311
312 cmd := testenv.CleanCmdEnv(exec.Command(exe, runArg))
313 got, err := cmd.CombinedOutput()
314 if err != nil {
315 if testenv.Builder() == "linux-amd64-alpine" {
316 // See Issue 18243 and Issue 19938.
317 t.Skipf("Skipping failing test on Alpine (golang.org/issue/18243). Ignoring error: %v", err)
318 }
319 t.Fatalf("%s\n\n%v", got, err)
320 }
321 fn := strings.TrimSpace(string(got))
322 defer os.Remove(fn)
323
324 for try := 0; try < 2; try++ {
325 cmd := testenv.CleanCmdEnv(exec.Command(testenv.GoToolPath(t), "tool", "pprof", "-tagignore=ignore", "-traces"))
326 // Check that pprof works both with and without explicit executable on command line.
327 if try == 0 {
328 cmd.Args = append(cmd.Args, exe, fn)
329 } else {
330 cmd.Args = append(cmd.Args, fn)
331 }
332
333 found := false
334 for i, e := range cmd.Env {
335 if strings.HasPrefix(e, "PPROF_TMPDIR=") {
336 cmd.Env[i] = "PPROF_TMPDIR=" + os.TempDir()
337 found = true
338 break
339 }
340 }
341 if !found {
342 cmd.Env = append(cmd.Env, "PPROF_TMPDIR="+os.TempDir())
343 }
344
345 out, err := cmd.CombinedOutput()
346 t.Logf("%s:\n%s", cmd.Args, out)
347 if err != nil {
348 t.Error(err)
349 continue
350 }
351
352 trace := findTrace(string(out), top)
353 if len(trace) == 0 {
354 t.Errorf("%s traceback missing.", top)
355 continue
356 }
357 if trace[len(trace)-1] != bottom {
358 t.Errorf("invalid traceback origin: got=%v; want=[%s ... %s]", trace, top, bottom)
359 }
360 }
361 }
362
363 func TestCgoPprof(t *testing.T) {
364 testCgoPprof(t, "", "CgoPprof", "cpuHog", "runtime.main")
365 }
366
367 func TestCgoPprofPIE(t *testing.T) {
368 testCgoPprof(t, "-buildmode=pie", "CgoPprof", "cpuHog", "runtime.main")
369 }
370
371 func TestCgoPprofThread(t *testing.T) {
372 testCgoPprof(t, "", "CgoPprofThread", "cpuHogThread", "cpuHogThread2")
373 }
374
375 func TestCgoPprofThreadNoTraceback(t *testing.T) {
376 testCgoPprof(t, "", "CgoPprofThreadNoTraceback", "cpuHogThread", "runtime._ExternalCode")
377 }
378
379 func TestRaceProf(t *testing.T) {
380 if (runtime.GOOS != "linux" && runtime.GOOS != "freebsd") || runtime.GOARCH != "amd64" {
381 t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
382 }
383 if runtime.Compiler == "gccgo" {
384 t.Skip("gccgo does not have SetCgoTraceback")
385 }
386
387 testenv.MustHaveGoRun(t)
388
389 // This test requires building various packages with -race, so
390 // it's somewhat slow.
391 if testing.Short() {
392 t.Skip("skipping test in -short mode")
393 }
394
395 exe, err := buildTestProg(t, "testprogcgo", "-race")
396 if err != nil {
397 t.Fatal(err)
398 }
399
400 got, err := testenv.CleanCmdEnv(exec.Command(exe, "CgoRaceprof")).CombinedOutput()
401 if err != nil {
402 t.Fatal(err)
403 }
404 want := "OK\n"
405 if string(got) != want {
406 t.Errorf("expected %q got %s", want, got)
407 }
408 }
409
410 func TestRaceSignal(t *testing.T) {
411 t.Parallel()
412 if (runtime.GOOS != "linux" && runtime.GOOS != "freebsd") || runtime.GOARCH != "amd64" {
413 t.Skipf("not yet supported on %s/%s", runtime.GOOS, runtime.GOARCH)
414 }
415
416 testenv.MustHaveGoRun(t)
417
418 // This test requires building various packages with -race, so
419 // it's somewhat slow.
420 if testing.Short() {
421 t.Skip("skipping test in -short mode")
422 }
423
424 exe, err := buildTestProg(t, "testprogcgo", "-race")
425 if err != nil {
426 t.Fatal(err)
427 }
428
429 got, err := testenv.CleanCmdEnv(exec.Command(exe, "CgoRaceSignal")).CombinedOutput()
430 if err != nil {
431 t.Logf("%s\n", got)
432 t.Fatal(err)
433 }
434 want := "OK\n"
435 if string(got) != want {
436 t.Errorf("expected %q got %s", want, got)
437 }
438 }
439
440 func TestCgoNumGoroutine(t *testing.T) {
441 switch runtime.GOOS {
442 case "windows", "plan9":
443 t.Skipf("skipping numgoroutine test on %s", runtime.GOOS)
444 }
445 t.Parallel()
446 got := runTestProg(t, "testprogcgo", "NumGoroutine")
447 want := "OK\n"
448 if got != want {
449 t.Errorf("expected %q got %v", want, got)
450 }
451 }
452
453 func TestCatchPanic(t *testing.T) {
454 t.Parallel()
455 switch runtime.GOOS {
456 case "plan9", "windows":
457 t.Skipf("no signals on %s", runtime.GOOS)
458 case "darwin":
459 if runtime.GOARCH == "amd64" {
460 t.Skipf("crash() on darwin/amd64 doesn't raise SIGABRT")
461 }
462 }
463
464 testenv.MustHaveGoRun(t)
465
466 exe, err := buildTestProg(t, "testprogcgo")
467 if err != nil {
468 t.Fatal(err)
469 }
470
471 for _, early := range []bool{true, false} {
472 cmd := testenv.CleanCmdEnv(exec.Command(exe, "CgoCatchPanic"))
473 // Make sure a panic results in a crash.
474 cmd.Env = append(cmd.Env, "GOTRACEBACK=crash")
475 if early {
476 // Tell testprogcgo to install an early signal handler for SIGABRT
477 cmd.Env = append(cmd.Env, "CGOCATCHPANIC_EARLY_HANDLER=1")
478 }
479 if out, err := cmd.CombinedOutput(); err != nil {
480 t.Errorf("testprogcgo CgoCatchPanic failed: %v\n%s", err, out)
481 }
482 }
483 }
484
485 func TestCgoLockOSThreadExit(t *testing.T) {
486 switch runtime.GOOS {
487 case "plan9", "windows":
488 t.Skipf("no pthreads on %s", runtime.GOOS)
489 }
490 t.Parallel()
491 testLockOSThreadExit(t, "testprogcgo")
492 }
493
494 func TestWindowsStackMemoryCgo(t *testing.T) {
495 if runtime.GOOS != "windows" {
496 t.Skip("skipping windows specific test")
497 }
498 testenv.SkipFlaky(t, 22575)
499 o := runTestProg(t, "testprogcgo", "StackMemory")
500 stackUsage, err := strconv.Atoi(o)
501 if err != nil {
502 t.Fatalf("Failed to read stack usage: %v", err)
503 }
504 if expected, got := 100<<10, stackUsage; got > expected {
505 t.Fatalf("expected < %d bytes of memory per thread, got %d", expected, got)
506 }
507 }
508
509 func TestSigStackSwapping(t *testing.T) {
510 switch runtime.GOOS {
511 case "plan9", "windows":
512 t.Skipf("no sigaltstack on %s", runtime.GOOS)
513 }
514 t.Parallel()
515 got := runTestProg(t, "testprogcgo", "SigStack")
516 want := "OK\n"
517 if got != want {
518 t.Errorf("expected %q got %v", want, got)
519 }
520 }
521
522 func TestCgoTracebackSigpanic(t *testing.T) {
523 // Test unwinding over a sigpanic in C code without a C
524 // symbolizer. See issue #23576.
525 if runtime.GOOS == "windows" {
526 // On Windows if we get an exception in C code, we let
527 // the Windows exception handler unwind it, rather
528 // than injecting a sigpanic.
529 t.Skip("no sigpanic in C on windows")
530 }
531 t.Parallel()
532 got := runTestProg(t, "testprogcgo", "TracebackSigpanic")
533 t.Log(got)
534 want := "runtime.sigpanic"
535 if !strings.Contains(got, want) {
536 t.Errorf("did not see %q in output", want)
537 }
538 // No runtime errors like "runtime: unexpected return pc".
539 nowant := "runtime: "
540 if strings.Contains(got, nowant) {
541 t.Errorf("unexpectedly saw %q in output", nowant)
542 }
543 }
544
545 func TestCgoPanicCallback(t *testing.T) {
546 t.Parallel()
547 got := runTestProg(t, "testprogcgo", "PanicCallback")
548 t.Log(got)
549 want := "panic: runtime error: invalid memory address or nil pointer dereference"
550 if !strings.Contains(got, want) {
551 t.Errorf("did not see %q in output", want)
552 }
553 want = "panic_callback"
554 if !strings.Contains(got, want) {
555 t.Errorf("did not see %q in output", want)
556 }
557 want = "PanicCallback"
558 if !strings.Contains(got, want) {
559 t.Errorf("did not see %q in output", want)
560 }
561 // No runtime errors like "runtime: unexpected return pc".
562 nowant := "runtime: "
563 if strings.Contains(got, nowant) {
564 t.Errorf("did not see %q in output", want)
565 }
566 }
567
568 // Test that C code called via cgo can use large Windows thread stacks
569 // and call back in to Go without crashing. See issue #20975.
570 //
571 // See also TestBigStackCallbackSyscall.
572 func TestBigStackCallbackCgo(t *testing.T) {
573 if runtime.GOOS != "windows" {
574 t.Skip("skipping windows specific test")
575 }
576 t.Parallel()
577 got := runTestProg(t, "testprogcgo", "BigStack")
578 want := "OK\n"
579 if got != want {
580 t.Errorf("expected %q got %v", want, got)
581 }
582 }
583
584 func nextTrace(lines []string) ([]string, []string) {
585 var trace []string
586 for n, line := range lines {
587 if strings.HasPrefix(line, "---") {
588 return trace, lines[n+1:]
589 }
590 fields := strings.Fields(strings.TrimSpace(line))
591 if len(fields) == 0 {
592 continue
593 }
594 // Last field contains the function name.
595 trace = append(trace, fields[len(fields)-1])
596 }
597 return nil, nil
598 }
599
600 func findTrace(text, top string) []string {
601 lines := strings.Split(text, "\n")
602 _, lines = nextTrace(lines) // Skip the header.
603 for len(lines) > 0 {
604 var t []string
605 t, lines = nextTrace(lines)
606 if len(t) == 0 {
607 continue
608 }
609 if t[0] == top {
610 return t
611 }
612 }
613 return nil
614 }
615
616 func TestSegv(t *testing.T) {
617 switch runtime.GOOS {
618 case "plan9", "windows":
619 t.Skipf("no signals on %s", runtime.GOOS)
620 }
621
622 for _, test := range []string{"Segv", "SegvInCgo"} {
623 test := test
624 t.Run(test, func(t *testing.T) {
625 t.Parallel()
626 got := runTestProg(t, "testprogcgo", test)
627 t.Log(got)
628 want := "SIGSEGV"
629 if !strings.Contains(got, want) {
630 if runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" && strings.Contains(got, "fatal: morestack on g0") {
631 testenv.SkipFlaky(t, 39457)
632 }
633 t.Errorf("did not see %q in output", want)
634 }
635
636 // No runtime errors like "runtime: unknown pc".
637 switch runtime.GOOS {
638 case "darwin", "illumos", "solaris":
639 // Runtime sometimes throws when generating the traceback.
640 testenv.SkipFlaky(t, 49182)
641 case "linux":
642 if runtime.GOARCH == "386" {
643 // Runtime throws when generating a traceback from
644 // a VDSO call via asmcgocall.
645 testenv.SkipFlaky(t, 50504)
646 }
647 }
648 if test == "SegvInCgo" && strings.Contains(got, "runtime: unknown pc") {
649 testenv.SkipFlaky(t, 50979)
650 }
651
652 nowant := "runtime: "
653 if strings.Contains(got, nowant) {
654 t.Errorf("unexpectedly saw %q in output", nowant)
655 }
656 })
657 }
658 }
659
660 func TestAbortInCgo(t *testing.T) {
661 switch runtime.GOOS {
662 case "plan9", "windows":
663 // N.B. On Windows, C abort() causes the program to exit
664 // without going through the runtime at all.
665 t.Skipf("no signals on %s", runtime.GOOS)
666 }
667
668 t.Parallel()
669 got := runTestProg(t, "testprogcgo", "Abort")
670 t.Log(got)
671 want := "SIGABRT"
672 if !strings.Contains(got, want) {
673 t.Errorf("did not see %q in output", want)
674 }
675 // No runtime errors like "runtime: unknown pc".
676 nowant := "runtime: "
677 if strings.Contains(got, nowant) {
678 t.Errorf("did not see %q in output", want)
679 }
680 }
681
682 // TestEINTR tests that we handle EINTR correctly.
683 // See issue #20400 and friends.
684 func TestEINTR(t *testing.T) {
685 switch runtime.GOOS {
686 case "plan9", "windows":
687 t.Skipf("no EINTR on %s", runtime.GOOS)
688 case "linux":
689 if runtime.GOARCH == "386" {
690 // On linux-386 the Go signal handler sets
691 // a restorer function that is not preserved
692 // by the C sigaction call in the test,
693 // causing the signal handler to crash when
694 // returning the normal code. The test is not
695 // architecture-specific, so just skip on 386
696 // rather than doing a complicated workaround.
697 t.Skip("skipping on linux-386; C sigaction does not preserve Go restorer")
698 }
699 }
700
701 t.Parallel()
702 output := runTestProg(t, "testprogcgo", "EINTR")
703 want := "OK\n"
704 if output != want {
705 t.Fatalf("want %s, got %s\n", want, output)
706 }
707 }
708
709 // Issue #42207.
710 func TestNeedmDeadlock(t *testing.T) {
711 switch runtime.GOOS {
712 case "plan9", "windows":
713 t.Skipf("no signals on %s", runtime.GOOS)
714 }
715 output := runTestProg(t, "testprogcgo", "NeedmDeadlock")
716 want := "OK\n"
717 if output != want {
718 t.Fatalf("want %s, got %s\n", want, output)
719 }
720 }
721
722 func TestCgoTracebackGoroutineProfile(t *testing.T) {
723 if runtime.Compiler == "gccgo" {
724 t.Skip("gccgo does not have SetCgoTraceback")
725 }
726 output := runTestProg(t, "testprogcgo", "GoroutineProfile")
727 want := "OK\n"
728 if output != want {
729 t.Fatalf("want %s, got %s\n", want, output)
730 }
731 }