LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // +build cgo | 5 // +build cgo |
6 | 6 |
7 package runtime_test | 7 package runtime_test |
8 | 8 |
9 import ( | 9 import ( |
10 "runtime" | 10 "runtime" |
11 "testing" | 11 "testing" |
12 ) | 12 ) |
13 | 13 |
14 func TestCgoCrashHandler(t *testing.T) { | 14 func TestCgoCrashHandler(t *testing.T) { |
15 testCrashHandler(t, true) | 15 testCrashHandler(t, true) |
16 } | 16 } |
17 | 17 |
18 func TestCgoSignalDeadlock(t *testing.T) { | 18 func TestCgoSignalDeadlock(t *testing.T) { |
19 if testing.Short() && runtime.GOOS == "windows" { | 19 if testing.Short() && runtime.GOOS == "windows" { |
20 t.Skip("Skipping in short mode") // takes up to 64 seconds | 20 t.Skip("Skipping in short mode") // takes up to 64 seconds |
21 } | 21 } |
22 got := executeTest(t, cgoSignalDeadlockSource, nil) | 22 got := executeTest(t, cgoSignalDeadlockSource, nil) |
| 23 want := "OK\n" |
| 24 if got != want { |
| 25 t.Fatalf("expected %q, but got %q", want, got) |
| 26 } |
| 27 } |
| 28 |
| 29 func TestCgoTraceback(t *testing.T) { |
| 30 got := executeTest(t, cgoTracebackSource, nil) |
23 want := "OK\n" | 31 want := "OK\n" |
24 if got != want { | 32 if got != want { |
25 t.Fatalf("expected %q, but got %q", want, got) | 33 t.Fatalf("expected %q, but got %q", want, got) |
26 } | 34 } |
27 } | 35 } |
28 | 36 |
29 const cgoSignalDeadlockSource = ` | 37 const cgoSignalDeadlockSource = ` |
30 package main | 38 package main |
31 | 39 |
32 import "C" | 40 import "C" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ping <- true | 91 ping <- true |
84 select { | 92 select { |
85 case <-ping: | 93 case <-ping: |
86 case <-time.After(time.Second): | 94 case <-time.After(time.Second): |
87 fmt.Printf("HANG\n") | 95 fmt.Printf("HANG\n") |
88 return | 96 return |
89 } | 97 } |
90 fmt.Printf("OK\n") | 98 fmt.Printf("OK\n") |
91 } | 99 } |
92 ` | 100 ` |
| 101 |
| 102 const cgoTracebackSource = ` |
| 103 package main |
| 104 |
| 105 /* void foo(void) {} */ |
| 106 import "C" |
| 107 |
| 108 import ( |
| 109 "fmt" |
| 110 "runtime" |
| 111 ) |
| 112 |
| 113 func main() { |
| 114 C.foo() |
| 115 buf := make([]byte, 1) |
| 116 runtime.Stack(buf, true) |
| 117 fmt.Printf("OK\n") |
| 118 } |
| 119 ` |
LEFT | RIGHT |