]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/addr2line: use testenv.Command instead of exec.Command in tests
authorBryan C. Mills <bcmills@google.com>
Tue, 15 Nov 2022 14:48:39 +0000 (09:48 -0500)
committerGopher Robot <gobot@golang.org>
Tue, 15 Nov 2022 20:25:35 +0000 (20:25 +0000)
testenv.Command sets a default based on the test\'s deadline
and sends SIGQUIT (where supported) in case of a hang.

Change-Id: I6710d9866c16610310347d50be1c0916c2976e87
Reviewed-on: https://go-review.googlesource.com/c/go/+/450712
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

src/cmd/addr2line/addr2line_test.go

index 992d7ac11e43934dde4e9b14121cd1c4c4944d90..ae51fe55bc98c2c88525de1086985e8efd334686 100644 (file)
@@ -9,7 +9,6 @@ import (
        "bytes"
        "internal/testenv"
        "os"
-       "os/exec"
        "path/filepath"
        "runtime"
        "strings"
@@ -17,7 +16,7 @@ import (
 )
 
 func loadSyms(t *testing.T) map[string]string {
-       cmd := exec.Command(testenv.GoToolPath(t), "tool", "nm", os.Args[0])
+       cmd := testenv.Command(t, testenv.GoToolPath(t), "tool", "nm", os.Args[0])
        out, err := cmd.CombinedOutput()
        if err != nil {
                t.Fatalf("go tool nm %v: %v\n%s", os.Args[0], err, string(out))
@@ -38,7 +37,7 @@ func loadSyms(t *testing.T) map[string]string {
 }
 
 func runAddr2Line(t *testing.T, exepath, addr string) (funcname, path, lineno string) {
-       cmd := exec.Command(exepath, os.Args[0])
+       cmd := testenv.Command(t, exepath, os.Args[0])
        cmd.Stdin = strings.NewReader(addr)
        out, err := cmd.CombinedOutput()
        if err != nil {
@@ -97,12 +96,12 @@ func testAddr2Line(t *testing.T, exepath, addr string) {
        if !os.SameFile(fi1, fi2) {
                t.Fatalf("addr2line_test.go and %s are not same file", srcPath)
        }
-       if srcLineNo != "106" {
-               t.Fatalf("line number = %v; want 106", srcLineNo)
+       if srcLineNo != "105" {
+               t.Fatalf("line number = %v; want 105", srcLineNo)
        }
 }
 
-// This is line 106. The test depends on that.
+// This is line 104. The test depends on that.
 func TestAddr2Line(t *testing.T) {
        testenv.MustHaveGoBuild(t)
 
@@ -115,7 +114,7 @@ func TestAddr2Line(t *testing.T) {
        // Build copy of test binary with debug symbols,
        // since the one running now may not have them.
        exepath := filepath.Join(tmpDir, "testaddr2line_test.exe")
-       out, err := exec.Command(testenv.GoToolPath(t), "test", "-c", "-o", exepath, "cmd/addr2line").CombinedOutput()
+       out, err := testenv.Command(t, testenv.GoToolPath(t), "test", "-c", "-o", exepath, "cmd/addr2line").CombinedOutput()
        if err != nil {
                t.Fatalf("go test -c -o %v cmd/addr2line: %v\n%s", exepath, err, string(out))
        }
@@ -124,7 +123,7 @@ func TestAddr2Line(t *testing.T) {
        syms := loadSyms(t)
 
        exepath = filepath.Join(tmpDir, "testaddr2line.exe")
-       out, err = exec.Command(testenv.GoToolPath(t), "build", "-o", exepath, "cmd/addr2line").CombinedOutput()
+       out, err = testenv.Command(t, testenv.GoToolPath(t), "build", "-o", exepath, "cmd/addr2line").CombinedOutput()
        if err != nil {
                t.Fatalf("go build -o %v cmd/addr2line: %v\n%s", exepath, err, string(out))
        }