@@ -171,3 +171,158 @@ target_link_libraries(evp_setpeer PRIVATE perf)
171171
172172add_executable (writeread writeread.c)
173173target_link_libraries (writeread PRIVATE  perf)
174+ 
175+ ## Running tests 
176+ # Options 
177+ set (run_tests evp_fetch
178+               evp_setpeer
179+               handshake
180+               newrawkey
181+               pkeyread
182+               providerdoall
183+               randbytes
184+               rsasign
185+               rwlocks
186+               sslnew
187+               #ssl_poll_perf 
188+               writeread
189+               x509storeissuer
190+               CACHE  STRING  "List of tests to run" )
191+ 
192+ # Per-test options, the format: test option values 
193+ set (run_evp_fetch_pqs
194+     evp_fetch ""  ""  "-q" 
195+     CACHE  STRING  "Post-quantum option for evp_fetch" )
196+ set (run_evp_setpeer_keys
197+     evp_setpeer "-k"  dh ec256 ec521 x25519 all 
198+     CACHE  STRING  "Key types for evp_setpeer" )
199+ set (run_newrawkey_algos
200+     newrawkey "-a"  x25519 ml-kem-512 ml-kem-768 ml-kem-1024
201+     CACHE  STRING  "Algorithms for newrawkey" )
202+ set (run_pkeyread_keys
203+     pkeyread "-k"  dh dhx dsa ec rsa x25519 all 
204+     CACHE  STRING  "Key types for pkeyread" )
205+ set (run_pkeyread_fmts
206+     pkeyread "-f"  pem der all 
207+     CACHE  STRING  "Key formats for pkeyread" )
208+ set (run_handshake_pools
209+     handshake ""  "-p"  "-P"  "-l" 
210+     CACHE  STRING  "Pool types for handshake" )
211+ set (run_handshake_ctx_sharing
212+     handshake ""  ""  "-s" 
213+     CACHE  STRING  "Context sharing option for handshake" )
214+ set (run_handshake_pool_size
215+     handshake ""  ""  "-o 4"  "-o 256" 
216+     CACHE  STRING  "Pool size for handshake" )
217+ set (run_handshake_secure_memory
218+     handshake ""  "-S 1048576" 
219+     CACHE  STRING  "Secure memory usage for handshake" )
220+ set (run_writeread_ctx_sharing
221+     writeread ""  ""  "-s" 
222+     CACHE  STRING  "Context sharing for writeread" )
223+ set (run_writeread_dtls
224+     writeread ""  ""  "-d" 
225+     CACHE  STRING  "DTLS mode for writeread" )
226+ set (run_writeread_buffers
227+     writeread ""  ""  "-b 256"  "-b 4096" 
228+     CACHE  STRING  "Buffer size for writeread" )
229+ 
230+ # The list of per-tet options 
231+ set (run_opts run_evp_fetch_pqs
232+              run_evp_setpeer_keys
233+              run_newrawkey_algos
234+              run_pkeyread_keys
235+              run_pkeyread_fmts
236+              run_handshake_pools
237+              run_handshake_ctx_sharing
238+              run_handshake_pool_size
239+              run_handshake_secure_memory
240+              run_writeread_ctx_sharing
241+              run_writeread_dtls
242+              run_writeread_buffers
243+              CACHE  STRING  "List of per-text options" )
244+ 
245+ # Used across multiple tests 
246+ set (run_certdir_tests handshake writeread x509storeissuer
247+     CACHE  STRING  "List of tests that require certdir parameter" )
248+ file (TO_NATIVE_PATH "${OPENSSL_ROOT_DIR} /test/certs/"  run_certdir_def_path)
249+ set (run_certdir "${run_certdir_def_path} " 
250+     CACHE  PATH  "Path to certificates directory for tests that need it" )
251+ 
252+ # Common options 
253+ set (run_terse ""  "-t" 
254+     CACHE  STRING  "List of terse output options" )
255+ set (run_threads 1 4
256+     CACHE  STRING  "List of thread counts" )
257+ 
258+ add_custom_target (run
259+                   COMMENT  "Run perf tests" 
260+                   WORKING_DIRECTORY  "${CMAKE_CURRENT_BINARY_DIR} " )
261+ 
262+ foreach (test  IN LISTS run_tests)
263+     set (cmds "${test} " )
264+ 
265+     # test-specific options 
266+     foreach (opt_name IN LISTS run_opts)
267+         set (opt "${${opt_name} }" )
268+         list (GET  opt 0 test_name)
269+         list (GET  opt 1 test_opt)
270+         list (REMOVE_AT  opt 0 1)
271+ 
272+         if (test  IN_LIST  test_name)
273+             set (new_cmds)
274+             foreach (cmd IN LISTS cmds)
275+                 foreach (val IN LISTS opt)
276+                     list (APPEND  new_cmds "${cmd}  ${test_opt}  ${val} " )
277+                 endforeach ()
278+             endforeach ()
279+             set (cmds ${new_cmds} )
280+         endif ()
281+     endforeach ()
282+ 
283+     # terse 
284+     set (new_cmds)
285+     foreach (cmd IN LISTS cmds)
286+         foreach (val IN LISTS run_terse)
287+             list (APPEND  new_cmds "${cmd}  ${val} " )
288+         endforeach ()
289+     endforeach ()
290+     set (cmds ${new_cmds} )
291+ 
292+     # certdir 
293+     if (test  IN_LIST  run_certdir_tests)
294+         set (new_cmds)
295+         foreach (cmd IN LISTS cmds)
296+             list (APPEND  new_cmds "${cmd}  ${run_certdir} " )
297+         endforeach ()
298+         set (cmds ${new_cmds} )
299+     endif ()
300+ 
301+     # threads 
302+     set (new_cmds)
303+     foreach (cmd IN LISTS cmds)
304+         foreach (val IN LISTS run_threads)
305+             list (APPEND  new_cmds "${cmd}  ${val} " )
306+         endforeach ()
307+     endforeach ()
308+     set (cmds ${new_cmds} )
309+ 
310+     foreach (cmd IN LISTS cmds)
311+         string (REGEX  REPLACE "  *"  ";"  cmd "${cmd} " )
312+         string (REGEX  REPLACE "[^0-9A-Za-z]"  "-"  cmd_target_name "${cmd} " )
313+         # A hack for lesser OSes that cannot normally distinguish lower- 
314+         # and uppercase letters. 
315+         if  (WIN32  OR  APPLE )
316+             string (REGEX  REPLACE "[A-Z]"  "\\ 0_"  cmd_target_name
317+                    "${cmd_target_name} " )
318+         endif ()
319+         string (REPLACE ";"  " "  cmd_desc "${cmd} " )
320+         add_custom_target ("run-${cmd_target_name} " 
321+                           COMMAND  ${cmd} 
322+                           DEPENDS  "${test} " 
323+                           COMMENT  "Run ${cmd_desc} " 
324+                           WORKING_DIRECTORY  "${CMAKE_CURRENT_BINARY_DIR} " 
325+                           USES_TERMINAL )
326+         add_dependencies (run "run-${cmd_target_name} " )
327+     endforeach ()
328+ endforeach ()
0 commit comments