aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/nm
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2024-08-29 19:00:00 -0700
committerDamien Neil <dneil@google.com>2024-09-03 18:03:19 +0000
commitf26c29723f372284ff7dc0dbf30bae5561a3e618 (patch)
tree86f66102d429a195e74e58c85f5cdf70a9645fef /src/cmd/nm
parentb4d4744059c0c9632c034af145deb161995f2f32 (diff)
downloadgo-f26c29723f372284ff7dc0dbf30bae5561a3e618.tar.xz
cmd: use testenv.Executable helper
Change-Id: I25ac0e8d25d760bfde3bb7700f0feaa23f3e8ab1 Reviewed-on: https://go-review.googlesource.com/c/go/+/609302 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/cmd/nm')
-rw-r--r--src/cmd/nm/nm_test.go27
1 files changed, 3 insertions, 24 deletions
diff --git a/src/cmd/nm/nm_test.go b/src/cmd/nm/nm_test.go
index 530a720f2b..4ee4217c59 100644
--- a/src/cmd/nm/nm_test.go
+++ b/src/cmd/nm/nm_test.go
@@ -12,7 +12,6 @@ import (
"path/filepath"
"runtime"
"strings"
- "sync"
"testing"
"text/template"
)
@@ -29,26 +28,6 @@ func TestMain(m *testing.M) {
os.Exit(m.Run())
}
-// nmPath returns the path to the "nm" binary to run.
-func nmPath(t testing.TB) string {
- t.Helper()
- testenv.MustHaveExec(t)
-
- nmPathOnce.Do(func() {
- nmExePath, nmPathErr = os.Executable()
- })
- if nmPathErr != nil {
- t.Fatal(nmPathErr)
- }
- return nmExePath
-}
-
-var (
- nmPathOnce sync.Once
- nmExePath string
- nmPathErr error
-)
-
func TestNonGoExecs(t *testing.T) {
t.Parallel()
testfiles := []string{
@@ -74,7 +53,7 @@ func TestNonGoExecs(t *testing.T) {
exepath = tf
}
- cmd := testenv.Command(t, nmPath(t), exepath)
+ cmd := testenv.Command(t, testenv.Executable(t), exepath)
out, err := cmd.CombinedOutput()
if err != nil {
t.Errorf("go tool nm %v: %v\n%s", exepath, err, string(out))
@@ -148,7 +127,7 @@ func testGoExec(t *testing.T, iscgo, isexternallinker bool) {
runtimeSyms["runtime.epclntab"] = "D"
}
- out, err = testenv.Command(t, nmPath(t), exe).CombinedOutput()
+ out, err = testenv.Command(t, testenv.Executable(t), exe).CombinedOutput()
if err != nil {
t.Fatalf("go tool nm: %v\n%s", err, string(out))
}
@@ -259,7 +238,7 @@ func testGoLib(t *testing.T, iscgo bool) {
}
mylib := filepath.Join(libpath, "mylib.a")
- out, err = testenv.Command(t, nmPath(t), mylib).CombinedOutput()
+ out, err = testenv.Command(t, testenv.Executable(t), mylib).CombinedOutput()
if err != nil {
t.Fatalf("go tool nm: %v\n%s", err, string(out))
}