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 // Calls test functions from C runtime (the tests are specified in export_test.g
o). |
| 6 |
5 package runtime_test | 7 package runtime_test |
6 | 8 |
7 import ( | 9 import ( |
| 10 "fmt" |
8 "io" | 11 "io" |
| 12 "runtime" |
9 "testing" | 13 "testing" |
10 ) | 14 ) |
11 | 15 |
12 var errf error | 16 var errf error |
13 | 17 |
14 func errfn() error { | 18 func errfn() error { |
15 return errf | 19 return errf |
16 } | 20 } |
17 | 21 |
18 func errfn1() error { | 22 func errfn1() error { |
(...skipping 12 matching lines...) Expand all Loading... |
31 | 35 |
32 func BenchmarkIfaceCmpNil100(b *testing.B) { | 36 func BenchmarkIfaceCmpNil100(b *testing.B) { |
33 for i := 0; i < b.N; i++ { | 37 for i := 0; i < b.N; i++ { |
34 for j := 0; j < 100; j++ { | 38 for j := 0; j < 100; j++ { |
35 if errfn1() == nil { | 39 if errfn1() == nil { |
36 b.Fatal("bad comparison") | 40 b.Fatal("bad comparison") |
37 } | 41 } |
38 } | 42 } |
39 } | 43 } |
40 } | 44 } |
| 45 |
| 46 func TestAtomic64(t *testing.T) { |
| 47 testCRuntime(t, runtime.CTestAtomic64) |
| 48 } |
| 49 |
| 50 func TestLockFreeStack(t *testing.T) { |
| 51 testCRuntime(t, runtime.CTestLockFreeStack) |
| 52 } |
| 53 |
| 54 func TestLockFreeStackStress(t *testing.T) { |
| 55 testCRuntime(t, runtime.CTestLockFreeStackStress) |
| 56 } |
| 57 |
| 58 func TestParfor(t *testing.T) { |
| 59 testCRuntime(t, runtime.CTestParfor) |
| 60 } |
| 61 |
| 62 func TestParforSetup(t *testing.T) { |
| 63 testCRuntime(t, runtime.CTestParforSetup) |
| 64 } |
| 65 |
| 66 func TestParforNonblock(t *testing.T) { |
| 67 testCRuntime(t, runtime.CTestParforNonblock) |
| 68 } |
| 69 |
| 70 func TestParforParallel(t *testing.T) { |
| 71 testCRuntime(t, runtime.CTestParforParallel) |
| 72 } |
| 73 |
| 74 func TestGcprocs(t *testing.T) { |
| 75 testCRuntime(t, runtime.CTestGcprocs) |
| 76 } |
| 77 |
| 78 func testCRuntime(t *testing.T, body func(bool)) { |
| 79 // The tests report errors via panic. |
| 80 defer func() { |
| 81 if msg := recover(); msg != nil { |
| 82 where := "???" |
| 83 // skip panic() and panicstring() |
| 84 _, file, line, ok := runtime.Caller(3) |
| 85 if ok { |
| 86 where = fmt.Sprintf("%s:%d", file, line) |
| 87 } |
| 88 t.Fatalf("%s\nat %s", msg, where) |
| 89 } |
| 90 }() |
| 91 body(testing.Short()) |
| 92 } |
LEFT | RIGHT |