"fmt"
"internal/testenv"
"io/ioutil"
- "os"
"os/exec"
"testing"
)
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
}
// 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)