mirror of
https://github.com/golang/go.git
synced 2025-05-28 10:51:22 +00:00
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/76024 Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
parent
6e8894d5ff
commit
da109c6075
@ -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 != "" {
|
||||
|
Loading…
x
Reference in New Issue
Block a user