| |
| |
| |
|
|
| package ssa_test |
|
|
| import ( |
| "internal/testenv" |
| "path/filepath" |
| "regexp" |
| "runtime" |
| "testing" |
| ) |
|
|
| |
| |
| |
| |
| func TestFmaHash(t *testing.T) { |
| switch runtime.GOOS { |
| case "linux", "darwin": |
| default: |
| t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS) |
| } |
| switch runtime.GOARCH { |
| case "amd64", "arm64": |
| default: |
| t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH) |
| } |
|
|
| testenv.MustHaveGoBuild(t) |
| gocmd := testenv.GoToolPath(t) |
| tmpdir := t.TempDir() |
| source := filepath.Join("testdata", "fma.go") |
| output := filepath.Join(tmpdir, "fma.exe") |
| cmd := testenv.Command(t, gocmd, "build", "-o", output, source) |
| |
| |
| cmd.Env = append(cmd.Env, "GOCOMPILEDEBUG=fmahash=1/0", "GOOS=linux", "GOARCH=arm64", "HOME="+tmpdir) |
| t.Logf("%v", cmd) |
| t.Logf("%v", cmd.Env) |
| b, e := cmd.CombinedOutput() |
| if e != nil { |
| t.Errorf("build failed: %v\n%s", e, b) |
| } |
| s := string(b) |
| re := "fmahash(0?) triggered .*fma.go:29:..;.*fma.go:18:.." |
| match := regexp.MustCompile(re) |
| if !match.MatchString(s) { |
| t.Errorf("Expected to match '%s' with \n-----\n%s-----", re, s) |
| } |
| } |
|
|