aboutsummaryrefslogtreecommitdiff
path: root/src/crypto/internal
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2024-11-20 09:51:27 -0500
committerRuss Cox <rsc@golang.org>2024-11-21 10:40:09 +0000
commit28f4e14ebe281d8e46cba430bfd123ce21fcd0cc (patch)
treea79c67c38e21f3254fe149502d4385713d58a257 /src/crypto/internal
parenta2a4f00783701272e4804b7488adef673ef46666 (diff)
downloadgo-28f4e14ebe281d8e46cba430bfd123ce21fcd0cc.tar.xz
crypto/internal/fips140deps: fix test for running in FIPS snapshot
In a FIPS snapshot, the import paths have a snapshot version number. Remove that version in the test before proceeding with the usual checks. Change-Id: I15c9d11dcac6d33330b334b8e5056c215bffa75c Reviewed-on: https://go-review.googlesource.com/c/go/+/629977 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Filippo Valsorda <filippo@golang.org>
Diffstat (limited to 'src/crypto/internal')
-rw-r--r--src/crypto/internal/fips140deps/fipsdeps_test.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/crypto/internal/fips140deps/fipsdeps_test.go b/src/crypto/internal/fips140deps/fipsdeps_test.go
index 488cc1caa5..2c3bc8184e 100644
--- a/src/crypto/internal/fips140deps/fipsdeps_test.go
+++ b/src/crypto/internal/fips140deps/fipsdeps_test.go
@@ -40,9 +40,19 @@ func TestImports(t *testing.T) {
{{range .XTestImports -}}
{{$path}} {{.}}
{{end -}}`, "crypto/internal/fips140/...")
- out, err := cmd.CombinedOutput()
+ bout, err := cmd.CombinedOutput()
if err != nil {
- t.Fatalf("go list: %v\n%s", err, out)
+ t.Fatalf("go list: %v\n%s", err, bout)
+ }
+ out := string(bout)
+
+ // In a snapshot, all the paths are crypto/internal/fips140/v1.2.3/...
+ // Determine the version number and remove it for the test.
+ _, v, _ := strings.Cut(out, "crypto/internal/fips140/")
+ v, _, _ = strings.Cut(v, "/")
+ v, _, _ = strings.Cut(v, " ")
+ if strings.HasPrefix(v, "v") && strings.Count(v, ".") == 2 {
+ out = strings.ReplaceAll(out, "crypto/internal/fips140/"+v, "crypto/internal/fips140")
}
allPackages := make(map[string]bool)
@@ -50,7 +60,7 @@ func TestImports(t *testing.T) {
// importCheck is the set of packages that import crypto/internal/fips140/check.
importCheck := make(map[string]bool)
- for _, line := range strings.Split(string(out), "\n") {
+ for _, line := range strings.Split(out, "\n") {
if line == "" {
continue
}