1
2
3
4
5 package ssa_test
6
7 import (
8 "internal/testenv"
9 "path/filepath"
10 "regexp"
11 "runtime"
12 "testing"
13 )
14
15
16
17
18
19 func TestFmaHash(t *testing.T) {
20 switch runtime.GOOS {
21 case "linux", "darwin":
22 default:
23 t.Skipf("Slow test, usually avoid it, os=%s not linux or darwin", runtime.GOOS)
24 }
25 switch runtime.GOARCH {
26 case "amd64", "arm64":
27 default:
28 t.Skipf("Slow test, usually avoid it, arch=%s not amd64 or arm64", runtime.GOARCH)
29 }
30
31 testenv.MustHaveGoBuild(t)
32 gocmd := testenv.GoToolPath(t)
33 tmpdir := t.TempDir()
34 source := filepath.Join("testdata", "fma.go")
35 output := filepath.Join(tmpdir, "fma.exe")
36 cmd := testenv.Command(t, gocmd, "build", "-o", output, source)
37
38
39 cmd.Env = append(cmd.Env, "GOCOMPILEDEBUG=fmahash=1/0", "GOOS=linux", "GOARCH=arm64", "HOME="+tmpdir)
40 t.Logf("%v", cmd)
41 t.Logf("%v", cmd.Env)
42 b, e := cmd.CombinedOutput()
43 if e != nil {
44 t.Errorf("build failed: %v\n%s", e, b)
45 }
46 s := string(b)
47 re := "fmahash(0?) triggered .*fma.go:29:..;.*fma.go:18:.."
48 match := regexp.MustCompile(re)
49 if !match.MatchString(s) {
50 t.Errorf("Expected to match '%s' with \n-----\n%s-----", re, s)
51 }
52 }
53
View as plain text