Source file
src/crypto/fips140/enforcement_test.go
1
2
3
4
5 package fips140_test
6
7 import (
8 "crypto/internal/cryptotest"
9 "internal/testenv"
10 "path/filepath"
11 "strings"
12 "testing"
13 )
14
15 func TestWithoutEnforcement(t *testing.T) {
16 testenv.MustHaveExec(t)
17 testenv.MustHaveGoBuild(t)
18 cryptotest.MustSupportFIPS140(t)
19
20 tool, _ := testenv.GoTool()
21 tmpdir := t.TempDir()
22 binFile := filepath.Join(tmpdir, "fips140.test")
23 cmd := testenv.Command(t, tool, "test", "-c", "-o", binFile, "./testdata")
24 out, err := cmd.CombinedOutput()
25 if err != nil {
26 t.Log(string(out))
27 t.Errorf("Could not build enforcement tests")
28 }
29 cmd = testenv.Command(t, binFile, "-test.list", ".")
30 list, err := cmd.CombinedOutput()
31 if err != nil {
32 t.Log(string(out))
33 t.Errorf("Could not get enforcement test list")
34 }
35 for test := range strings.Lines(string(list)) {
36 test = strings.TrimSpace(test)
37 t.Run(test, func(t *testing.T) {
38 cmd = testenv.Command(t, binFile, "-test.run", "^"+test+"$")
39 cmd.Env = append(cmd.Env, "GODEBUG=fips140=only")
40 out, err := cmd.CombinedOutput()
41 if err != nil {
42 t.Error(string(out))
43 }
44 })
45 }
46 }
47
View as plain text