Skip to content

Commit

Permalink
cmd/compile: enable ssacheck for tests in ssa_test.go
Browse files Browse the repository at this point in the history
I thought SSA check was enabled for those tests, but in fact it
was not. Enable it. So we have SSA check on for at least some
tests on all architectures.

Updates golang#22499.

Change-Id: I51fcdda3af7faab5aeb33bf46c6db309285ce42c
Reviewed-on: https://go-review.googlesource.com/76024
Reviewed-by: Keith Randall <[email protected]>
  • Loading branch information
cherrymui committed Nov 6, 2017
1 parent 6e8894d commit da109c6
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions src/cmd/compile/internal/gc/ssa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"bytes"
"internal/testenv"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
Expand All @@ -27,11 +28,38 @@ func buildTest(t *testing.T, filename string) {
}
func doTest(t *testing.T, filename string, kind string) {
testenv.MustHaveGoBuild(t)
gotool := testenv.GoToolPath(t)
tmpdir, ok := ioutil.TempDir("", "ssatest")
if ok != nil {
t.Fatalf("Failed to create temporary directory")
}
defer os.RemoveAll(tmpdir)

// Execute compile+link+run instead of "go run" to avoid applying -gcflags=-d=ssa/check/on
// to the runtime (especially over and over and over).
// compile
var stdout, stderr bytes.Buffer
cmd := exec.Command(testenv.GoToolPath(t), kind, filepath.Join("testdata", filename))
cmd := exec.Command(gotool, "tool", "compile", "-d=ssa/check/on", "-o", filepath.Join(tmpdir, "run.a"), filepath.Join("testdata", filename))
cmd.Stdout = &stdout
cmd.Stderr = &stderr
if err := cmd.Run(); err != nil {
err := cmd.Run()
if kind == "run" {
if err == nil {
// link
cmd = exec.Command(gotool, "tool", "link", "-o", filepath.Join(tmpdir, "run.exe"), filepath.Join(tmpdir, "run.a"))
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err = cmd.Run()
}
if err == nil {
// run
cmd = exec.Command(filepath.Join(tmpdir, "run.exe"))
cmd.Stdout = &stdout
cmd.Stderr = &stderr
err = cmd.Run()
}
}
if err != nil {
t.Fatalf("Failed: %v:\nOut: %s\nStderr: %s\n", err, &stdout, &stderr)
}
if s := stdout.String(); s != "" {
Expand Down

0 comments on commit da109c6

Please sign in to comment.