mirror of
https://github.com/golang/go
synced 2024-11-22 20:24:47 -07:00
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 <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>
This commit is contained in:
parent
849dba07a5
commit
07b2fee460
@ -14,7 +14,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"internal/testenv"
|
"internal/testenv"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -29,6 +28,10 @@ func TestLargeText(t *testing.T) {
|
|||||||
const FN = 4
|
const FN = 4
|
||||||
tmpdir := t.TempDir()
|
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
|
// Generate the scenario where the total amount of text exceeds the
|
||||||
// limit for the jmp/call instruction, on RISC architectures like ppc64le,
|
// limit for the jmp/call instruction, on RISC architectures like ppc64le,
|
||||||
// which is 2^26. When that happens the call requires special trampolines or
|
// which is 2^26. When that happens the call requires special trampolines or
|
||||||
@ -80,26 +83,28 @@ func TestLargeText(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build and run with internal linking.
|
// Build and run with internal linking.
|
||||||
os.Chdir(tmpdir)
|
|
||||||
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext")
|
cmd := exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext")
|
||||||
|
cmd.Dir = tmpdir
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Build failed for big text program with internal linking: %v, output: %s", err, out)
|
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()
|
out, err = cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Program built with internal linking failed to run with err %v, output: %s", err, out)
|
t.Fatalf("Program built with internal linking failed to run with err %v, output: %s", err, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build and run with external linking
|
// Build and run with external linking
|
||||||
os.Chdir(tmpdir)
|
|
||||||
cmd = exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext", "-ldflags", "'-linkmode=external'")
|
cmd = exec.Command(testenv.GoToolPath(t), "build", "-o", "bigtext", "-ldflags", "'-linkmode=external'")
|
||||||
|
cmd.Dir = tmpdir
|
||||||
out, err = cmd.CombinedOutput()
|
out, err = cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Build failed for big text program with external linking: %v, output: %s", err, out)
|
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()
|
out, err = cmd.CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Program built with external linking failed to run with err %v, output: %s", err, out)
|
t.Fatalf("Program built with external linking failed to run with err %v, output: %s", err, out)
|
||||||
|
Loading…
Reference in New Issue
Block a user