Commit da109c60 authored by Cherry Zhang's avatar Cherry Zhang

cmd/compile: enable ssacheck for tests in ssa_test.go

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 #22499.

Change-Id: I51fcdda3af7faab5aeb33bf46c6db309285ce42c
Reviewed-on: https://go-review.googlesource.com/76024Reviewed-by: 's avatarKeith Randall <khr@golang.org>
parent 6e8894d5
......@@ -8,6 +8,7 @@ import (
"bytes"
"internal/testenv"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
......@@ -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 != "" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment