Skip to content

Commit 570e01a

Browse files
esyrSashan
authored andcommitted
source/CMakeLists.txt: add run target
Add "run" target that runs all the tests with various options. Signed-off-by: Eugene Syromiatnikov <[email protected]>
1 parent 578f383 commit 570e01a

File tree

1 file changed

+155
-0
lines changed

1 file changed

+155
-0
lines changed

source/CMakeLists.txt

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,158 @@ target_link_libraries(evp_setpeer PRIVATE perf)
184184

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

0 commit comments

Comments
 (0)