aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/objdump/objdump_test.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2022-11-15 10:38:07 -0500
committerGopher Robot <gobot@golang.org>2022-11-15 20:23:48 +0000
commit10661bd95225cc9d4e85bffe0de63e797ff4f2ac (patch)
tree712f99192491d3c444736c6501e479a7e448de45 /src/cmd/objdump/objdump_test.go
parenta3d545933fcc8bdd2edad56cc3f8c2aa6140814d (diff)
downloadgo-10661bd95225cc9d4e85bffe0de63e797ff4f2ac.tar.xz
cmd/objdump: use testenv.Command instead of exec.Command in tests
testenv.Command sets a default timeout based on the test's deadline and sends SIGQUIT (where supported) in case of a hang. Change-Id: I1965ea453af6aa9eeae9669065deb0b372dc6caf Reviewed-on: https://go-review.googlesource.com/c/go/+/450705 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/cmd/objdump/objdump_test.go')
-rw-r--r--src/cmd/objdump/objdump_test.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/cmd/objdump/objdump_test.go b/src/cmd/objdump/objdump_test.go
index 23b299a42b..69b4cf4e21 100644
--- a/src/cmd/objdump/objdump_test.go
+++ b/src/cmd/objdump/objdump_test.go
@@ -12,7 +12,6 @@ import (
"internal/platform"
"internal/testenv"
"os"
- "os/exec"
"path/filepath"
"runtime"
"strings"
@@ -151,7 +150,7 @@ func testDisasm(t *testing.T, srcfname string, printCode bool, printGnuAsm bool,
args := []string{"build", "-o", hello}
args = append(args, flags...)
args = append(args, srcfname)
- cmd := exec.Command(testenv.GoToolPath(t), args...)
+ cmd := testenv.Command(t, testenv.GoToolPath(t), args...)
// "Bad line" bug #36683 is sensitive to being run in the source directory.
cmd.Dir = "testdata"
// Ensure that the source file location embedded in the binary matches our
@@ -221,7 +220,7 @@ func testDisasm(t *testing.T, srcfname string, printCode bool, printGnuAsm bool,
if printGnuAsm {
args = append([]string{"-gnu"}, args...)
}
- cmd = exec.Command(objdumpPath(t), args...)
+ cmd = testenv.Command(t, objdumpPath(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)
@@ -305,7 +304,7 @@ func TestDisasmGoobj(t *testing.T) {
hello := filepath.Join(tmp, "hello.o")
args := []string{"tool", "compile", "-p=main", "-importcfg=" + importcfgfile, "-o", hello}
args = append(args, "testdata/fmthello.go")
- out, err := exec.Command(testenv.GoToolPath(t), args...).CombinedOutput()
+ out, err := testenv.Command(t, testenv.GoToolPath(t), args...).CombinedOutput()
if err != nil {
t.Fatalf("go tool compile fmthello.go: %v\n%s", err, out)
}
@@ -319,7 +318,7 @@ func TestDisasmGoobj(t *testing.T) {
hello,
}
- out, err = exec.Command(objdumpPath(t), args...).CombinedOutput()
+ out, err = testenv.Command(t, objdumpPath(t), args...).CombinedOutput()
if err != nil {
t.Fatalf("objdump fmthello.o: %v\n%s", err, out)
}
@@ -353,14 +352,14 @@ func TestGoobjFileNumber(t *testing.T) {
tmp := t.TempDir()
obj := filepath.Join(tmp, "p.a")
- cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", obj)
+ cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", obj)
cmd.Dir = filepath.Join("testdata/testfilenum")
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("build failed: %v\n%s", err, out)
}
- cmd = exec.Command(objdumpPath(t), obj)
+ cmd = testenv.Command(t, objdumpPath(t), obj)
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("objdump failed: %v\n%s", err, out)
@@ -383,7 +382,7 @@ func TestGoObjOtherVersion(t *testing.T) {
t.Parallel()
obj := filepath.Join("testdata", "go116.o")
- cmd := exec.Command(objdumpPath(t), obj)
+ cmd := testenv.Command(t, objdumpPath(t), obj)
out, err := cmd.CombinedOutput()
if err == nil {
t.Fatalf("objdump go116.o succeeded unexpectedly")