]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/link: fix TestLargeText
authorLynn Boger <laboger@linux.vnet.ibm.com>
Fri, 9 Apr 2021 15:41:27 +0000 (10:41 -0500)
committerLynn Boger <laboger@linux.vnet.ibm.com>
Mon, 12 Apr 2021 18:32:27 +0000 (18:32 +0000)
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>

src/cmd/link/linkbig_test.go

index d5d77d6c721d33c96c26e31f91cf42f20074c158..917bd9e8a3c140f575dde9b5aae6151cfc28eeef 100644 (file)
@@ -14,7 +14,6 @@ import (
        "fmt"
        "internal/testenv"
        "io/ioutil"
-       "os"
        "os/exec"
        "testing"
 )
@@ -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
@@ -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)