Skip to content

Commit 07b2fee

Browse files
committed
cmd/link: fix TestLargeText
This test is not run in short mode so it was getting failures that didn't happen with default testing. See the issue for details on the failures. Fixes #45406 Change-Id: I51d97cc4c910fe3ba2bc0a12742023a57d101f44 Reviewed-on: https://go-review.googlesource.com/c/go/+/308935 Run-TryBot: Lynn Boger <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Paul Murphy <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> Trust: Lynn Boger <[email protected]>
1 parent 849dba0 commit 07b2fee

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/cmd/link/linkbig_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
"fmt"
1515
"internal/testenv"
1616
"io/ioutil"
17-
"os"
1817
"os/exec"
1918
"testing"
2019
)
@@ -29,6 +28,10 @@ func TestLargeText(t *testing.T) {
2928
const FN = 4
3029
tmpdir := t.TempDir()
3130

31+
if err := ioutil.WriteFile(tmpdir+"/go.mod", []byte("module big_test\n"), 0666); err != nil {
32+
t.Fatal(err)
33+
}
34+
3235
// Generate the scenario where the total amount of text exceeds the
3336
// limit for the jmp/call instruction, on RISC architectures like ppc64le,
3437
// which is 2^26. When that happens the call requires special trampolines or
@@ -80,26 +83,28 @@ func TestLargeText(t *testing.T) {
8083
}
8184

8285
// Build and run with internal linking.
83-
os.Chdir(tmpdir)
8486
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext")
87+
cmd.Dir = tmpdir
8588
out, err := cmd.CombinedOutput()
8689
if err != nil {
8790
t.Fatalf("Build failed for big text program with internal linking: %v, output: %s", err, out)
8891
}
89-
cmd = exec.Command(tmpdir + "/bigtext")
92+
cmd = exec.Command("./bigtext")
93+
cmd.Dir = tmpdir
9094
out, err = cmd.CombinedOutput()
9195
if err != nil {
9296
t.Fatalf("Program built with internal linking failed to run with err %v, output: %s", err, out)
9397
}
9498

9599
// Build and run with external linking
96-
os.Chdir(tmpdir)
97100
cmd = exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext", "-ldflags", "'-linkmode=external'")
101+
cmd.Dir = tmpdir
98102
out, err = cmd.CombinedOutput()
99103
if err != nil {
100104
t.Fatalf("Build failed for big text program with external linking: %v, output: %s", err, out)
101105
}
102-
cmd = exec.Command(tmpdir + "/bigtext")
106+
cmd = exec.Command("./bigtext")
107+
cmd.Dir = tmpdir
103108
out, err = cmd.CombinedOutput()
104109
if err != nil {
105110
t.Fatalf("Program built with external linking failed to run with err %v, output: %s", err, out)

0 commit comments

Comments
 (0)