diff options
| author | Kir Kolyshkin <kolyshkin@gmail.com> | 2024-08-29 19:00:00 -0700 |
|---|---|---|
| committer | Damien Neil <dneil@google.com> | 2024-09-03 18:03:19 +0000 |
| commit | f26c29723f372284ff7dc0dbf30bae5561a3e618 (patch) | |
| tree | 86f66102d429a195e74e58c85f5cdf70a9645fef /src/cmd/objdump | |
| parent | b4d4744059c0c9632c034af145deb161995f2f32 (diff) | |
| download | go-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/objdump')
| -rw-r--r-- | src/cmd/objdump/objdump_test.go | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/cmd/objdump/objdump_test.go b/src/cmd/objdump/objdump_test.go index ba8c4fbe19..d256e59afe 100644 --- a/src/cmd/objdump/objdump_test.go +++ b/src/cmd/objdump/objdump_test.go @@ -14,7 +14,6 @@ import ( "path/filepath" "runtime" "strings" - "sync" "testing" ) @@ -30,26 +29,6 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -// objdumpPath returns the path to the "objdump" binary to run. -func objdumpPath(t testing.TB) string { - t.Helper() - testenv.MustHaveExec(t) - - objdumpPathOnce.Do(func() { - objdumpExePath, objdumpPathErr = os.Executable() - }) - if objdumpPathErr != nil { - t.Fatal(objdumpPathErr) - } - return objdumpExePath -} - -var ( - objdumpPathOnce sync.Once - objdumpExePath string - objdumpPathErr error -) - var x86Need = []string{ // for both 386 and AMD64 "JMP main.main(SB)", "CALL main.Println(SB)", @@ -222,7 +201,7 @@ func testDisasm(t *testing.T, srcfname string, printCode bool, printGnuAsm bool, if printGnuAsm { args = append([]string{"-gnu"}, args...) } - cmd = testenv.Command(t, objdumpPath(t), args...) + cmd = testenv.Command(t, testenv.Executable(t), args...) cmd.Dir = "testdata" // "Bad line" bug #36683 is sensitive to being run in the source directory out, err = cmd.CombinedOutput() t.Logf("Running %v", cmd.Args) @@ -320,7 +299,7 @@ func TestDisasmGoobj(t *testing.T) { hello, } - out, err = testenv.Command(t, objdumpPath(t), args...).CombinedOutput() + out, err = testenv.Command(t, testenv.Executable(t), args...).CombinedOutput() if err != nil { t.Fatalf("objdump fmthello.o: %v\n%s", err, out) } @@ -361,7 +340,7 @@ func TestGoobjFileNumber(t *testing.T) { t.Fatalf("build failed: %v\n%s", err, out) } - cmd = testenv.Command(t, objdumpPath(t), obj) + cmd = testenv.Command(t, testenv.Executable(t), obj) out, err = cmd.CombinedOutput() if err != nil { t.Fatalf("objdump failed: %v\n%s", err, out) @@ -380,11 +359,10 @@ func TestGoobjFileNumber(t *testing.T) { } func TestGoObjOtherVersion(t *testing.T) { - testenv.MustHaveExec(t) t.Parallel() obj := filepath.Join("testdata", "go116.o") - cmd := testenv.Command(t, objdumpPath(t), obj) + cmd := testenv.Command(t, testenv.Executable(t), obj) out, err := cmd.CombinedOutput() if err == nil { t.Fatalf("objdump go116.o succeeded unexpectedly") |
