1
2
3
4
5 package cryptotest
6
7 import (
8 "crypto/internal/boring"
9 "crypto/internal/impl"
10 "internal/goos"
11 "internal/testenv"
12 "testing"
13 )
14
15
16
17
18 func TestAllImplementations(t *testing.T, pkg string, f func(t *testing.T)) {
19
20 if boring.Enabled {
21 f(t)
22 return
23 }
24
25 impls := impl.List(pkg)
26 if len(impls) == 0 {
27 f(t)
28 return
29 }
30
31 t.Cleanup(func() { impl.Reset(pkg) })
32
33 for _, name := range impls {
34 if available := impl.Select(pkg, name); available {
35 t.Run(name, f)
36 } else {
37 t.Run(name, func(t *testing.T) {
38
39
40 if testenv.Builder() != "" && goos.GOOS == "linux" {
41 if name == "SHA-NI" {
42 t.Skip("known issue, see golang.org/issue/69592")
43 }
44 if name == "Armv8.2" {
45 t.Skip("known issue, see golang.org/issue/69593")
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