Source file src/runtime/metrics_cgo_test.go

     1  // Copyright 2025 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  	"internal/race"
    11  	"runtime"
    12  	"testing"
    13  )
    14  
    15  func TestNotInGoMetricCallback(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  	// This test is run in a subprocess to prevent other tests from polluting the metrics
    26  	// and because we need to make some cgo callbacks.
    27  	output := runTestProg(t, "testprogcgo", "NotInGoMetricCallback")
    28  	want := "OK\n"
    29  	if output != want {
    30  		t.Fatalf("output:\n%s\n\nwanted:\n%s", output, want)
    31  	}
    32  }
    33  

View as plain text