Skip to content

Commit

Permalink
cmd/link: fix TestLargeText
Browse files Browse the repository at this point in the history
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 <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
  • Loading branch information
laboger committed Apr 12, 2021
1 parent 849dba0 commit 07b2fee
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cmd/link/linkbig_test.go
Expand Up @@ -14,7 +14,6 @@ import (
"fmt"
"internal/testenv"
"io/ioutil"
"os"
"os/exec"
"testing"
)
Expand All @@ -29,6 +28,10 @@ func TestLargeText(t *testing.T) {
const FN = 4
tmpdir := t.TempDir()

if err := ioutil.WriteFile(tmpdir+"/go.mod", []byte("module big_test\n"), 0666); err != nil {
t.Fatal(err)
}

// Generate the scenario where the total amount of text exceeds the
// limit for the jmp/call instruction, on RISC architectures like ppc64le,
// which is 2^26. When that happens the call requires special trampolines or
Expand Down Expand Up @@ -80,26 +83,28 @@ func TestLargeText(t *testing.T) {
}

// Build and run with internal linking.
os.Chdir(tmpdir)
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext")
cmd.Dir = tmpdir
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("Build failed for big text program with internal linking: %v, output: %s", err, out)
}
cmd = exec.Command(tmpdir + "/bigtext")
cmd = exec.Command("./bigtext")
cmd.Dir = tmpdir
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("Program built with internal linking failed to run with err %v, output: %s", err, out)
}

// Build and run with external linking
os.Chdir(tmpdir)
cmd = exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext", "-ldflags", "'-linkmode=external'")
cmd.Dir = tmpdir
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("Build failed for big text program with external linking: %v, output: %s", err, out)
}
cmd = exec.Command(tmpdir + "/bigtext")
cmd = exec.Command("./bigtext")
cmd.Dir = tmpdir
out, err = cmd.CombinedOutput()
if err != nil {
t.Fatalf("Program built with external linking failed to run with err %v, output: %s", err, out)
Expand Down

0 comments on commit 07b2fee

Please sign in to comment.