@@ -14,7 +14,6 @@ import (
14
14
"fmt"
15
15
"internal/testenv"
16
16
"io/ioutil"
17
- "os"
18
17
"os/exec"
19
18
"testing"
20
19
)
@@ -29,6 +28,10 @@ func TestLargeText(t *testing.T) {
29
28
const FN = 4
30
29
tmpdir := t .TempDir ()
31
30
31
+ if err := ioutil .WriteFile (tmpdir + "/go.mod" , []byte ("module big_test\n " ), 0666 ); err != nil {
32
+ t .Fatal (err )
33
+ }
34
+
32
35
// Generate the scenario where the total amount of text exceeds the
33
36
// limit for the jmp/call instruction, on RISC architectures like ppc64le,
34
37
// which is 2^26. When that happens the call requires special trampolines or
@@ -80,26 +83,28 @@ func TestLargeText(t *testing.T) {
80
83
}
81
84
82
85
// Build and run with internal linking.
83
- os .Chdir (tmpdir )
84
86
cmd := exec .Command (testenv .GoToolPath (t ), "build" , "-o" , "bigtext" )
87
+ cmd .Dir = tmpdir
85
88
out , err := cmd .CombinedOutput ()
86
89
if err != nil {
87
90
t .Fatalf ("Build failed for big text program with internal linking: %v, output: %s" , err , out )
88
91
}
89
- cmd = exec .Command (tmpdir + "/bigtext" )
92
+ cmd = exec .Command ("./bigtext" )
93
+ cmd .Dir = tmpdir
90
94
out , err = cmd .CombinedOutput ()
91
95
if err != nil {
92
96
t .Fatalf ("Program built with internal linking failed to run with err %v, output: %s" , err , out )
93
97
}
94
98
95
99
// Build and run with external linking
96
- os .Chdir (tmpdir )
97
100
cmd = exec .Command (testenv .GoToolPath (t ), "build" , "-o" , "bigtext" , "-ldflags" , "'-linkmode=external'" )
101
+ cmd .Dir = tmpdir
98
102
out , err = cmd .CombinedOutput ()
99
103
if err != nil {
100
104
t .Fatalf ("Build failed for big text program with external linking: %v, output: %s" , err , out )
101
105
}
102
- cmd = exec .Command (tmpdir + "/bigtext" )
106
+ cmd = exec .Command ("./bigtext" )
107
+ cmd .Dir = tmpdir
103
108
out , err = cmd .CombinedOutput ()
104
109
if err != nil {
105
110
t .Fatalf ("Program built with external linking failed to run with err %v, output: %s" , err , out )
0 commit comments