github.com/gidoBOSSftw5731/go/src@v0.0.0-20210226122457-d24b0edbf019/runtime/race/syso_test.go (about)

     1  // Copyright 2020 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 !android && !js && !ppc64le
     6  // +build !android,!js,!ppc64le
     7  
     8  // Note: we don't run on Android or ppc64 because if there is any non-race test
     9  // file in this package, the OS tries to link the .syso file into the
    10  // test (even when we're not in race mode), which fails. I'm not sure
    11  // why, but easiest to just punt - as long as a single builder runs
    12  // this test, we're good.
    13  
    14  package race
    15  
    16  import (
    17  	"bytes"
    18  	"os/exec"
    19  	"path/filepath"
    20  	"runtime"
    21  	"testing"
    22  )
    23  
    24  func TestIssue37485(t *testing.T) {
    25  	files, err := filepath.Glob("./*.syso")
    26  	if err != nil {
    27  		t.Fatalf("can't find syso files: %s", err)
    28  	}
    29  	for _, f := range files {
    30  		cmd := exec.Command(filepath.Join(runtime.GOROOT(), "bin", "go"), "tool", "nm", f)
    31  		res, err := cmd.CombinedOutput()
    32  		if err != nil {
    33  			t.Errorf("nm of %s failed: %s", f, err)
    34  			continue
    35  		}
    36  		if bytes.Contains(res, []byte("getauxval")) {
    37  			t.Errorf("%s contains getauxval", f)
    38  		}
    39  	}
    40  }