summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2023-03-08 06:12:52 +0000
committerjsing <>2023-03-08 06:12:52 +0000
commit6edb0a56e6aa12c3ee96cf27ee601fb464869235 (patch)
treeac0d5ef7e1a2df77ebbc908f5a218c54c99eaeee /src
parentf59a5e932baaa204327818534b8c93267c20bed0 (diff)
downloadopenbsd-6edb0a56e6aa12c3ee96cf27ee601fb464869235.tar.gz
openbsd-6edb0a56e6aa12c3ee96cf27ee601fb464869235.tar.bz2
openbsd-6edb0a56e6aa12c3ee96cf27ee601fb464869235.zip
Process up to four test vector files concurrently.
This avoids having a slow down when processing test vector files that only have a single group. Note that the processing of test vector files is in turn going to be rate limited by the number of concurrent test groups, which means we do not need variable limits for vectors. Reduces a Wycheproof regress run down to ~8 seconds on an Apple M1.
Diffstat (limited to 'src')
-rw-r--r--src/regress/lib/libcrypto/wycheproof/wycheproof.go34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/regress/lib/libcrypto/wycheproof/wycheproof.go b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
index accd9ab9cb..f98d4b13e8 100644
--- a/src/regress/lib/libcrypto/wycheproof/wycheproof.go
+++ b/src/regress/lib/libcrypto/wycheproof/wycheproof.go
@@ -1,4 +1,4 @@
1/* $OpenBSD: wycheproof.go,v 1.137 2023/03/08 05:41:08 jsing Exp $ */ 1/* $OpenBSD: wycheproof.go,v 1.138 2023/03/08 06:12:52 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2018 Joel Sing <jsing@openbsd.org>
4 * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org> 4 * Copyright (c) 2018,2019,2022 Theo Buehler <tb@openbsd.org>
@@ -90,6 +90,7 @@ import (
90 "regexp" 90 "regexp"
91 "runtime" 91 "runtime"
92 "strings" 92 "strings"
93 "sync"
93 "unsafe" 94 "unsafe"
94) 95)
95 96
@@ -2973,6 +2974,14 @@ func main() {
2973 2974
2974 success := true 2975 success := true
2975 2976
2977 var wg sync.WaitGroup
2978
2979 vectorsRateLimitCh := make(chan bool, 4)
2980 for i := 0; i < cap(vectorsRateLimitCh); i++ {
2981 vectorsRateLimitCh <- true
2982 }
2983 resultCh := make(chan bool, 1024)
2984
2976 testc = newTestCoordinator() 2985 testc = newTestCoordinator()
2977 2986
2978 skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sha3|sha512_(224|256))_`) 2987 skipNormal := regexp.MustCompile(`_(ecpoint|p1363|sha3|sha512_(224|256))_`)
@@ -2990,9 +2999,26 @@ func main() {
2990 fmt.Printf("INFO: Skipping tests from \"%s\"\n", strings.TrimPrefix(tv, testVectorPath+"/")) 2999 fmt.Printf("INFO: Skipping tests from \"%s\"\n", strings.TrimPrefix(tv, testVectorPath+"/"))
2991 continue 3000 continue
2992 } 3001 }
2993 if !runTestVectors(tv, test.variant) { 3002 wg.Add(1)
2994 success = false 3003 <-vectorsRateLimitCh
2995 } 3004 go func(tv string, variant testVariant) {
3005 select {
3006 case resultCh <- runTestVectors(tv, variant):
3007 default:
3008 log.Fatal("result channel is full")
3009 }
3010 vectorsRateLimitCh <- true
3011 wg.Done()
3012 }(tv, test.variant)
3013 }
3014 }
3015
3016 wg.Wait()
3017 close(resultCh)
3018
3019 for result := range resultCh {
3020 if !result {
3021 success = false
2996 } 3022 }
2997 } 3023 }
2998 3024