github.com/comwrg/go/src@v0.0.0-20220319063731-c238d0440370/runtime/norace_linux_test.go (about) 1 // Copyright 2015 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 // The file contains tests that cannot run under race detector for some reason. 6 //go:build !race 7 // +build !race 8 9 package runtime_test 10 11 import ( 12 "runtime" 13 "testing" 14 "time" 15 "unsafe" 16 ) 17 18 var newOSProcDone bool 19 20 //go:nosplit 21 func newOSProcCreated() { 22 newOSProcDone = true 23 } 24 25 // Can't be run with -race because it inserts calls into newOSProcCreated() 26 // that require a valid G/M. 27 func TestNewOSProc0(t *testing.T) { 28 runtime.NewOSProc0(0x800000, unsafe.Pointer(runtime.FuncPC(newOSProcCreated))) 29 check := time.NewTicker(100 * time.Millisecond) 30 defer check.Stop() 31 end := time.After(5 * time.Second) 32 for { 33 select { 34 case <-check.C: 35 if newOSProcDone { 36 return 37 } 38 case <-end: 39 t.Fatalf("couldn't create new OS process") 40 } 41 } 42 }