Source file
src/runtime/metrics_cgo_test.go
1
2
3
4
5
6
7 package runtime_test
8
9 import (
10 "internal/race"
11 "runtime"
12 "testing"
13 )
14
15 func TestNotInGoMetric(t *testing.T) {
16 switch runtime.GOOS {
17 case "windows", "plan9":
18 t.Skip("unsupported on Windows and Plan9")
19 case "freebsd":
20 if race.Enabled {
21 t.Skipf("race + cgo freebsd not supported. See https://go.dev/issue/73788.")
22 }
23 }
24
25 run := func(t *testing.T, name string) {
26
27
28 output := runTestProg(t, "testprogcgo", name)
29 want := "OK\n"
30 if output != want {
31 t.Fatalf("output:\n%s\n\nwanted:\n%s", output, want)
32 }
33 }
34 t.Run("CgoCall", func(t *testing.T) {
35 run(t, "NotInGoMetricCgoCall")
36 })
37 t.Run("CgoCallback", func(t *testing.T) {
38 run(t, "NotInGoMetricCgoCallback")
39 })
40 t.Run("CgoCallAndCallback", func(t *testing.T) {
41 run(t, "NotInGoMetricCgoCallAndCallback")
42 })
43 }
44
View as plain text