1
2
3
4
5 package cryptotest
6
7 import (
8 "crypto/internal/boring"
9 "crypto/internal/impl"
10 "internal/goarch"
11 "internal/goos"
12 "internal/testenv"
13 "testing"
14 )
15
16
17
18
19 func TestAllImplementations(t *testing.T, pkg string, f func(t *testing.T)) {
20
21 if boring.Enabled {
22 f(t)
23 return
24 }
25
26 impls := impl.List(pkg)
27 if len(impls) == 0 {
28 f(t)
29 return
30 }
31
32 t.Cleanup(func() { impl.Reset(pkg) })
33
34 for _, name := range impls {
35 if available := impl.Select(pkg, name); available {
36 t.Run(name, f)
37 } else {
38 t.Run(name, func(t *testing.T) {
39
40
41 flagship := goos.GOOS == "linux" && goarch.GOARCH != "arm64" ||
42 goos.GOOS == "darwin" && goarch.GOARCH == "arm64"
43 if testenv.Builder() != "" && flagship {
44 if name == "SHA-NI" {
45 t.Skip("known issue, see golang.org/issue/69592")
46 }
47 t.Error("builder doesn't support CPU features needed to test this implementation")
48 } else {
49 t.Skip("implementation not supported")
50 }
51 })
52 }
53
54 }
55
56
57 impl.Select(pkg, "")
58 t.Run("Base", f)
59 }
60
View as plain text