@@ -190,15 +190,13 @@ func findGOROOT() (string, error) {
190190 // If runtime.GOROOT() is non-empty, assume that it is valid.
191191 //
192192 // (It might not be: for example, the user may have explicitly set GOROOT
193- // to the wrong directory, or explicitly set GOROOT_FINAL but not GOROOT
194- // and hasn't moved the tree to GOROOT_FINAL yet. But those cases are
193+ // to the wrong directory. But this case is
195194 // rare, and if that happens the user can fix what they broke.)
196195 return
197196 }
198197
199198 // runtime.GOROOT doesn't know where GOROOT is (perhaps because the test
200- // binary was built with -trimpath, or perhaps because GOROOT_FINAL was set
201- // without GOROOT and the tree hasn't been moved there yet).
199+ // binary was built with -trimpath).
202200 //
203201 // Since this is internal/testenv, we can cheat and assume that the caller
204202 // is a test of some package in a subdirectory of GOROOT/src. ('go test'
@@ -372,6 +370,15 @@ func MustInternalLink(t testing.TB, withCgo bool) {
372370 }
373371}
374372
373+ // MustInternalLinkPIE checks whether the current system can link PIE binary using
374+ // internal linking.
375+ // If not, MustInternalLinkPIE calls t.Skip with an explanation.
376+ func MustInternalLinkPIE (t testing.TB ) {
377+ if ! platform .InternalLinkPIESupported (runtime .GOOS , runtime .GOARCH ) {
378+ t .Skipf ("skipping test: internal linking for buildmode=pie on %s/%s is not supported" , runtime .GOOS , runtime .GOARCH )
379+ }
380+ }
381+
375382// MustHaveBuildMode reports whether the current system can build programs in
376383// the given build mode.
377384// If not, MustHaveBuildMode calls t.Skip with an explanation.
@@ -505,3 +512,36 @@ func WriteImportcfg(t testing.TB, dstPath string, packageFiles map[string]string
505512func SyscallIsNotSupported (err error ) bool {
506513 return syscallIsNotSupported (err )
507514}
515+
516+ // ParallelOn64Bit calls t.Parallel() unless there is a case that cannot be parallel.
517+ // This function should be used when it is necessary to avoid t.Parallel on
518+ // 32-bit machines, typically because the test uses lots of memory.
519+ func ParallelOn64Bit (t * testing.T ) {
520+ if goarch .PtrSize == 4 {
521+ return
522+ }
523+ t .Parallel ()
524+ }
525+
526+ // CPUProfilingBroken returns true if CPU profiling has known issues on this
527+ // platform.
528+ func CPUProfilingBroken () bool {
529+ switch runtime .GOOS {
530+ case "plan9" :
531+ // Profiling unimplemented.
532+ return true
533+ case "aix" :
534+ // See https://golang.org/issue/45170.
535+ return true
536+ case "ios" , "dragonfly" , "netbsd" , "illumos" , "solaris" :
537+ // See https://golang.org/issue/13841.
538+ return true
539+ case "openbsd" :
540+ if runtime .GOARCH == "arm" || runtime .GOARCH == "arm64" {
541+ // See https://golang.org/issue/13841.
542+ return true
543+ }
544+ }
545+
546+ return false
547+ }
0 commit comments