diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5b8ca3c..b8b6725 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,13 +9,37 @@ jobs: strategy: fail-fast: false matrix: - openssl-branch: - - "openssl-3.0" - - "openssl-3.2" - - "openssl-3.3" - - "openssl-3.4" - - "openssl-3.5" - - "master" + release: [ + { + openssl-branch: "openssl-3.0", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-tests', + }, { + openssl-branch: "openssl-3.2", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.3", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.4", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.5", + cmakeopts: '', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.6", + cmakeopts: '', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "master", + cmakeopts: '', + configopts: 'no-apps no-tests', + } + ] runs-on: "ubuntu-latest" container: "docker.io/library/debian:11" steps: @@ -27,13 +51,13 @@ jobs: uses: "actions/checkout@v5" with: repository: "openssl/openssl" - ref: ${{ matrix.openssl-branch }} + ref: ${{ matrix.release.openssl-branch }} fetch-depth: 1 path: "openssl" - name: "Config openssl build" working-directory: "./openssl" run: | - ./config --prefix="$PWD/dist" + ./config ${{ matrix.release.configopts }} --prefix="$PWD/dist" - name: "Build openssl" working-directory: "./openssl" run: | @@ -49,23 +73,55 @@ jobs: - name: "Config perftools build" working-directory: "./perftools/source" run: | - cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" + cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" -Drun_add_version_dep:BOOL=OFF ${{ matrix.release.cmakeopts }} - name: "Build perftools" working-directory: "./perftools/source" run: | cmake --build build --config Release + - name: "Print perftools version information" + working-directory: "./perftools/source" + run: | + cmake --build build --config Release --target run-version -j 4 + - name: "Run perftools" + working-directory: "./perftools/source" + run: | + cmake --build build --config Release --target run -j 4 ubuntu-20-04: strategy: fail-fast: false matrix: - openssl-branch: - - "openssl-3.0" - - "openssl-3.2" - - "openssl-3.3" - - "openssl-3.4" - - "openssl-3.5" - - "master" + release: [ + { + openssl-branch: "openssl-3.0", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D OPENSSL_VERSION=3.0', + configopts: 'no-tests', + }, { + openssl-branch: "openssl-3.2", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D OPENSSL_VERSION=3.2', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.3", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D OPENSSL_VERSION=3.3', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.4", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D OPENSSL_VERSION=3.4', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.5", + cmakeopts: '-D OPENSSL_VERSION=3.5', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.6", + cmakeopts: '-D OPENSSL_VERSION=3.6', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "master", + cmakeopts: '-D OPENSSL_VERSION=4.0', + configopts: 'no-apps no-tests', + } + ] runs-on: "ubuntu-latest" container: "docker.io/library/ubuntu:20.04" steps: @@ -79,13 +135,13 @@ jobs: uses: "actions/checkout@v5" with: repository: "openssl/openssl" - ref: ${{ matrix.openssl-branch }} + ref: ${{ matrix.release.openssl-branch }} fetch-depth: 1 path: "openssl" - name: "Config openssl build" working-directory: "./openssl" run: | - ./config --prefix="$PWD/dist" + ./config ${{ matrix.release.configopts }} --prefix="$PWD/dist" - name: "Build openssl" working-directory: "./openssl" run: | @@ -101,23 +157,55 @@ jobs: - name: "Config perftools build" working-directory: "./perftools/source" run: | - cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" + cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" -Drun_add_version_dep:BOOL=OFF ${{ matrix.release.cmakeopts }} - name: "Build perftools" working-directory: "./perftools/source" run: | cmake --build build --config Release + - name: "Print perftools version information" + working-directory: "./perftools/source" + run: | + cmake --build build --config Release --target run-version -j 4 + - name: "Run perftools" + working-directory: "./perftools/source" + run: | + cmake --build build --config Release --target run -j 4 freebsd-13: strategy: fail-fast: false matrix: - openssl-branch: - - "openssl-3.0" - - "openssl-3.2" - - "openssl-3.3" - - "openssl-3.4" - - "openssl-3.5" - - "master" + release: [ + { + openssl-branch: "openssl-3.0", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-tests', + }, { + openssl-branch: "openssl-3.2", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.3", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.4", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.5", + cmakeopts: '-D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.6", + cmakeopts: '-D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "master", + cmakeopts: '', + configopts: 'no-apps no-tests', + } + ] runs-on: "ubuntu-latest" steps: - name: "Install prerequisites" @@ -132,7 +220,7 @@ jobs: uses: "actions/checkout@v5" with: repository: "openssl/openssl" - ref: ${{ matrix.openssl-branch }} + ref: ${{ matrix.release.openssl-branch }} fetch-depth: 1 path: "openssl" - name: "Config openssl build" @@ -143,7 +231,7 @@ jobs: shutdown_vm: false run: | cd openssl - ./config --prefix="$PWD/dist" + ./config ${{ matrix.release.configopts }} --prefix="$PWD/dist" - name: "Build openssl" uses: "cross-platform-actions/action@fe0167d8082ac584754ef3ffb567fded22642c7d" #v0.27.0 with: @@ -174,7 +262,7 @@ jobs: shutdown_vm: false run: | cd perftools/source - cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" + cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" -Drun_add_version_dep:BOOL=OFF ${{ matrix.release.cmakeopts }} - name: "Build perftools" uses: "cross-platform-actions/action@fe0167d8082ac584754ef3ffb567fded22642c7d" #v0.27.0 with: @@ -184,18 +272,60 @@ jobs: run: | cd perftools/source cmake --build build --config Release + - name: "Print perftools version information" + uses: "cross-platform-actions/action@fe0167d8082ac584754ef3ffb567fded22642c7d" #v0.27.0 + with: + operating_system: "freebsd" + version: "13.4" + shutdown_vm: false + run: | + cd perftools/source + cmake --build build --config Release --target run-version -j 4 + - name: "Run perftools" + uses: "cross-platform-actions/action@fe0167d8082ac584754ef3ffb567fded22642c7d" #v0.27.0 + with: + operating_system: "freebsd" + version: "13.4" + shutdown_vm: false + run: | + cd perftools/source + cmake --build build --config Release --target run -j 4 windows: strategy: fail-fast: false matrix: - openssl-branch: - - "openssl-3.0" - - "openssl-3.2" - - "openssl-3.3" - - "openssl-3.4" - - "openssl-3.5" - - "master" + release: [ + { + openssl-branch: "openssl-3.0", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-tests', + }, { + openssl-branch: "openssl-3.2", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.3", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.4", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.5", + cmakeopts: '', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.6", + cmakeopts: '', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "master", + cmakeopts: '', + configopts: 'no-apps no-tests', + } + ] runs-on: "windows-latest" steps: - name: "Install prerequisites" @@ -206,7 +336,7 @@ jobs: uses: "actions/checkout@v5" with: repository: "openssl/openssl" - ref: ${{ matrix.openssl-branch }} + ref: ${{ matrix.release.openssl-branch }} fetch-depth: 1 path: "openssl" - name: "Config openssl build" @@ -214,7 +344,7 @@ jobs: shell: cmd run: | call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" - perl Configure no-makedepend + perl Configure no-makedepend ${{ matrix.release.configopts }} - name: "Build openssl" working-directory: ".\\openssl" shell: cmd @@ -228,36 +358,68 @@ jobs: - name: "Config perftools build" working-directory: ".\\perftools\\source" run: | - cmake -S . -B .\build -DOPENSSL_ROOT_DIR="$env:GITHUB_WORKSPACE\openssl" + cmake -S . -B .\build -DOPENSSL_ROOT_DIR="$env:GITHUB_WORKSPACE\openssl" -Drun_add_version_dep:BOOL=OFF ${{ matrix.release.cmakeopts }} - name: "Build perftools" working-directory: ".\\perftools\\source" run: | cmake --build .\build --config Release + - name: "Print perftools version information" + working-directory: ".\\perftools\\source" + run: | + cmake --build .\build --config Release --target run-version -j 4 + - name: "Run perftools" + working-directory: ".\\perftools\\source" + run: | + cmake --build .\build --config Release --target run -j 4 macos: strategy: fail-fast: false matrix: - openssl-branch: - - "openssl-3.0" - - "openssl-3.2" - - "openssl-3.3" - - "openssl-3.4" - - "openssl-3.5" - - "master" + release: [ + { + openssl-branch: "openssl-3.0", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-tests', + }, { + openssl-branch: "openssl-3.2", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.3", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.4", + cmakeopts: '-D "run_newrawkey_algos=newrawkey;-a;x25519" -D "run_evp_fetch_pqs=evp_fetch;;" -D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.5", + cmakeopts: '-D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "openssl-3.6", + cmakeopts: '-D "run_handshake_pool_size=handshake;;;-o 4"', + configopts: 'no-apps no-tests', + }, { + openssl-branch: "master", + cmakeopts: '', + configopts: 'no-apps no-tests', + } + ] runs-on: "macos-latest" steps: - name: "Checkout openssl" uses: "actions/checkout@v5" with: repository: "openssl/openssl" - ref: ${{ matrix.openssl-branch }} + ref: ${{ matrix.release.openssl-branch }} fetch-depth: 1 path: "openssl" - name: "Config openssl build" working-directory: "./openssl" run: | - ./config --prefix="$PWD/dist" + ./config ${{ matrix.release.configopts }} --prefix="$PWD/dist" - name: "Build openssl" working-directory: "./openssl" run: | @@ -273,8 +435,16 @@ jobs: - name: "Config perftools build" working-directory: "./perftools/source" run: | - cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" + cmake -S . -B build -DOPENSSL_ROOT_DIR="$GITHUB_WORKSPACE/openssl" -Drun_add_version_dep:BOOL=OFF ${{ matrix.release.cmakeopts }} - name: "Build perftools" working-directory: "./perftools/source" run: | cmake --build build --config Release + - name: "Print perftools version information" + working-directory: "./perftools/source" + run: | + cmake --build build --config Release --target run-version -j 4 + - name: "Run perftools" + working-directory: "./perftools/source" + run: | + cmake --build build --config Release --target run -j 4 diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 980d6be..aa383bd 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -87,6 +87,11 @@ # # ./build/randbytes 10 # +# cmake also generates a run target. The run target serves as a +# unit test which runs all commands. Use 'cmake --build build -t run' command +# to run it. Note that if the build was configured without explicit +# OPENSSL_ROOT_DIR set, one might wants to properly set run_certdir cache +# variable beforehand. # # 32-bit builds # ============= @@ -128,6 +133,13 @@ add_library(perf perflib/perfhelper.c perflib/perfsslhelper.c perflib/threads.c if(WIN32) target_sources(perf PRIVATE perflib/getopt.c perflib/basename.c perflib/err.c) + # + # windows release build on github workflow places places .exe files under + # build\Release. This tweak hopes to place or .exe files under \build + # for both build types. + # + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}") endif() target_include_directories(perf PUBLIC "${PROJECT_SOURCE_DIR}") @@ -187,3 +199,258 @@ target_link_libraries(writeread PRIVATE perf) add_executable(evp_hash evp_hash.c) target_link_libraries(evp_hash PRIVATE perf) + +## Running tests +# Options +set(run_tests evp_fetch + evp_hash + evp_setpeer + handshake + newrawkey + pkeyread + providerdoall + randbytes + rsasign + rwlocks + sslnew + #ssl_poll_perf + writeread + x509storeissuer + CACHE STRING "List of tests to run") + +set(run_add_version_dep ON + CACHE BOOL "Whether to print version information on run " + + "(call all the tests with -V option before the main run)") + +# Per-test options, the format: test option values +set(run_evp_fetch_pqs + evp_fetch "" "" "-q" + CACHE STRING "Post-quantum option for evp_fetch") +set(run_evp_hash_operations + evp_hash "" "" "-o deprecated" "-o evp_isolated" "-o evp_shared" + CACHE STRING "Modes of operation for evp_hash") +set(run_evp_hash_update_times + evp_hash "" "" "-u 1" "-u 5" + CACHE STRING "Digest update times for evp_hash") +set(run_evp_hash_algorithms + evp_hash "" "" "-a SHA1" "-a SHA224" "-a SHA256" "-a SHA384" "-a SHA512" + CACHE STRING "Digest hash algorithms for evp_hash") +set(run_evp_setpeer_keys + evp_setpeer "-k" dh ec256 ec521 x25519 all + CACHE STRING "Key types for evp_setpeer") +set(run_newrawkey_algos + newrawkey "-a" x25519 ml-kem-512 ml-kem-768 ml-kem-1024 + CACHE STRING "Algorithms for newrawkey") +set(run_pkeyread_keys + pkeyread "-k" dh dhx dsa ec rsa x25519 all + CACHE STRING "Key types for pkeyread") +set(run_pkeyread_fmts + pkeyread "-f" pem der all + CACHE STRING "Key formats for pkeyread") +set(run_handshake_pools + handshake "" "-p" "-P" "-l" + CACHE STRING "Pool types for handshake") +set(run_handshake_ctx_sharing + handshake "" "" "-s" + CACHE STRING "Context sharing option for handshake") +set(run_handshake_pool_size + handshake "" "" "-o 4" "-o 256" + CACHE STRING "Pool size for handshake") +set(run_handshake_secure_memory + handshake "" "-S 1048576" + CACHE STRING "Secure memory usage for handshake") +set(run_writeread_ctx_sharing + writeread "" "" "-s" + CACHE STRING "Context sharing for writeread") +set(run_writeread_dtls + writeread "" "" "-d" + CACHE STRING "DTLS mode for writeread") +set(run_writeread_buffers + writeread "" "" "-b 256" "-b 4096" + CACHE STRING "Buffer size for writeread") + +# The list of per-tet options +set(run_opts run_evp_fetch_pqs + run_evp_hash_operations + run_evp_hash_update_times + run_evp_hash_algorithms + run_evp_setpeer_keys + run_newrawkey_algos + run_pkeyread_keys + run_pkeyread_fmts + run_handshake_pools + run_handshake_ctx_sharing + run_handshake_pool_size + run_handshake_secure_memory + run_writeread_ctx_sharing + run_writeread_dtls + run_writeread_buffers + CACHE STRING "List of per-text options") + +# Used across multiple tests +set(run_certdir_tests handshake writeread x509storeissuer + CACHE STRING "List of tests that require certdir parameter") +file(TO_NATIVE_PATH "${OPENSSL_ROOT_DIR}/test/certs/" run_certdir_def_path) +set(run_certdir "${run_certdir_def_path}" + CACHE PATH "Path to certificates directory for tests that need it") + +# Common options +set(run_terse "" "-t" + CACHE STRING "List of terse output options") +set(run_threads 1 4 + CACHE STRING "List of thread counts") + +add_custom_target(run + COMMENT "Run perf tests" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + +# Version target +add_custom_target(run-version + COMMENT "Get version information for perf tests" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") +if (run_add_version_dep) + add_dependencies(run run-version) +endif() + +# +# On Windows, we can't have nice things, and the easiest way to use +# specifically the libraries we've built against is to copy them +# in the directory where executable reside. +# +if (WIN32) + # + # An intermediate target to ensure that any DLLs touching happens strictly + # before their usage. + # + add_custom_target(run-copy-dlls + COMMENT "Copy dependent DLLs into the build directory") + + # Generate search path for later DLL copying + set(dll_search_dirs) + foreach (f IN LISTS OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES) + get_filename_component(f_dir "${f}" DIRECTORY) + list(APPEND dll_search_dirs "${f_dir}") + endforeach() +endif() + +# +# gen_run_target( [VAR ] [NAME ]) +# +# Generates a target that runs and depends on target and sets +# to the target's name. +# +function(gen_run_taget _CMD _TEST) + include(CMakeParseArguments) + + set(_Options "") + set(_OneValueArgs VAR NAME) + set(_MultiValueArgs "") + cmake_parse_arguments(GEN_RUN_TARGET + "${_Options}" + "${_OneValueArgs}" + "${_MultiValueArgs}" + ${ARGN} + ) + + string(REGEX REPLACE " *" ";" cmd "${_CMD}") + string(REGEX REPLACE "[^0-9A-Za-z]" "-" cmd_target_name "${cmd}") + # A hack for lesser OSes that cannot normally distinguish lower- + # and uppercase letters. + if (WIN32 OR APPLE) + string(REGEX REPLACE "[A-Z]" "\\0_" cmd_target_name + "${cmd_target_name}") + endif() + if (NOT GEN_RUN_TARGET_NAME) + set(GEN_RUN_TARGET_NAME "run-${cmd_target_name}") + endif() + string(REPLACE ";" " " cmd_desc "${cmd}") + + + add_custom_target("${GEN_RUN_TARGET_NAME}" + COMMAND ${cmd} + DEPENDS "${_TEST}" + COMMENT "Run ${cmd_desc}" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + USES_TERMINAL) + + # A dirty hack to copy the dependent DLLs into the build directory so they + # get picked up before the ones in the system directory or wherever. + if(WIN32) + if (NOT TARGET "${_TEST}-copy-dlls") + add_custom_target("${_TEST}-copy-dlls" + COMMAND ${CMAKE_COMMAND} + -D TARGET_FILE=$ + -D TARGET_DIR=$ + -D "SEARCH_PATHS=${dll_search_dirs}" + -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/copy_reqs.cmake" + COMMENT "Copying DLLs for ${_TEST}") + endif() + # Avoid executing any run targets before the DLL copying + add_dependencies(run-copy-dlls "${_TEST}-copy-dlls") + add_dependencies("${GEN_RUN_TARGET_NAME}" run-copy-dlls) + endif() + + if (GEN_RUN_TARGET_VAR) + set("${GEN_RUN_TARGET_VAR}" "${GEN_RUN_TARGET_NAME}" PARENT_SCOPE) + endif() +endfunction() + +# run targets generation +foreach(test IN LISTS run_tests) + set(cmds "${test}") + + # test-specific options + foreach(opt_name IN LISTS run_opts) + set(opt "${${opt_name}}") + list(GET opt 0 test_name) + list(GET opt 1 test_opt) + list(REMOVE_AT opt 0 1) + + if(test IN_LIST test_name) + set(new_cmds) + foreach(cmd IN LISTS cmds) + foreach(val IN LISTS opt) + list(APPEND new_cmds "${cmd} ${test_opt} ${val}") + endforeach() + endforeach() + set(cmds ${new_cmds}) + endif() + endforeach() + + # terse + set(new_cmds) + foreach(cmd IN LISTS cmds) + foreach(val IN LISTS run_terse) + list(APPEND new_cmds "${cmd} ${val}") + endforeach() + endforeach() + set(cmds ${new_cmds}) + + # certdir + if(test IN_LIST run_certdir_tests) + set(new_cmds) + foreach(cmd IN LISTS cmds) + list(APPEND new_cmds "${cmd} ${run_certdir}") + endforeach() + set(cmds ${new_cmds}) + endif() + + # threads + set(new_cmds) + foreach(cmd IN LISTS cmds) + foreach(val IN LISTS run_threads) + list(APPEND new_cmds "${cmd} ${val}") + endforeach() + endforeach() + set(cmds ${new_cmds}) + + # Run targets + foreach(cmd IN LISTS cmds) + gen_run_taget("${cmd}" "${test}" VAR run_target_name) + add_dependencies(run "${run_target_name}") + endforeach() + + # Per-test version target + gen_run_taget("${test} -V" "${test}" NAME "run-version-${test}") + add_dependencies(run-version "run-version-${test}") +endforeach() diff --git a/source/cmake/copy_reqs.cmake b/source/cmake/copy_reqs.cmake new file mode 100644 index 0000000..7633aac --- /dev/null +++ b/source/cmake/copy_reqs.cmake @@ -0,0 +1,18 @@ +include(GetPrerequisites) + +get_prerequisites(${TARGET_FILE} prereqs 1 1 "" "${SEARCH_PATHS}" "") + +foreach(prereq ${prereqs}) + # Skipping already copied prerequisites + if(EXISTS "${TARGET_DIR}/${prereq}") + continue() + endif() + + gp_resolve_item("" ${prereq} "" "${SEARCH_PATHS}" prereq_path) + + if(prereq_path) + # A hack: we abuse configure_file()'s method of atomically updating + # the destination to minimise possible race conditions + configure_file("${prereq_path}" "${TARGET_DIR}/${prereq}" COPYONLY) + endif() +endforeach() diff --git a/source/evp_fetch.c b/source/evp_fetch.c index ab8ed78..3ec6408 100644 --- a/source/evp_fetch.c +++ b/source/evp_fetch.c @@ -183,12 +183,13 @@ void do_fetch(size_t num) * to be a multiple of the number of fetch entries therefore at the last * iteration we may not check all the algorithms. */ + i = 0; do { /* * If we set a fetch type, always use that */ if (exclusive_fetch_type == FETCH_END) { - j = i % array_size; + j = i++ % array_size; fetch_alg = fetch_entries[j].alg; j = fetch_entries[j].ftype; } else { @@ -289,10 +290,12 @@ void do_fetch(size_t num) static void usage(const char *progname) { - printf("Usage: %s [-t] [-f TYPE:ALGORITHM]" PQ_USAGE_OPT " threadcount\n" + printf("Usage: %s [-t] [-f TYPE:ALGORITHM]" PQ_USAGE_OPT " [-V]" + " threadcount\n" "-t - terse output\n" "-f - fetch only the specified algorithm\n" PQ_USAGE_DESC + "-V - print version information and exit\n" "\nEnvironment variables:\n" " EVP_FETCH_TYPE - if no -f option is provided, fetch only\n" " the specified TYPE:ALGORITHM\n", @@ -319,7 +322,7 @@ int main(int argc, char *argv[]) char *fetch_type = getenv("EVP_FETCH_TYPE"); int opt; - while ((opt = getopt(argc, argv, "tf:" PQ_GETOPT)) != -1) { + while ((opt = getopt(argc, argv, "tf:" PQ_GETOPT "V")) != -1) { switch (opt) { case 't': terse = 1; @@ -332,6 +335,9 @@ int main(int argc, char *argv[]) pq = 1; break; #endif + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: usage(basename(argv[0])); return EXIT_FAILURE; diff --git a/source/evp_hash.c b/source/evp_hash.c index 6bd3539..80d6ee5 100644 --- a/source/evp_hash.c +++ b/source/evp_hash.c @@ -18,8 +18,10 @@ #include #include #ifndef _WIN32 +# include # include #else +# include "perflib/basename.h" # include "perflib/getopt.h" #endif /* _WIN32 */ @@ -246,12 +248,13 @@ static void do_hash_evp_shared(size_t num) static void print_help() { - printf("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] thread-count\n"); + printf("Usage: evp_hash [-h] [-t] [-o operation] [-u update-times] [-a algorithm] [-V] thread-count\n"); printf("-h - print this help output\n"); printf("-t - terse output\n"); printf("-o operation - mode of operation. One of [deprecated, evp_isolated, evp_shared] (default: evp_shared)\n"); printf("-u update-times - times to update digest. 1 for one-shot (default: 1)\n"); printf("-a algorithm - One of: [SHA1, SHA224, SHA256, SHA384, SHA512] (default: SHA1)\n"); + printf("-V - print version information and exit\n"); printf("thread-count - number of threads\n"); } @@ -263,7 +266,7 @@ int main(int argc, char *argv[]) int terse = 0, operation = EVP_SHARED, hash_algorithm = SHA1_ALG; int j, opt, rc = EXIT_FAILURE; - while ((opt = getopt(argc, argv, "hto:u:a:")) != -1) { + while ((opt = getopt(argc, argv, "hto:u:a:V")) != -1) { switch (opt) { case 't': terse = 1; @@ -305,7 +308,13 @@ int main(int argc, char *argv[]) goto out; } break; + case 'V': + perflib_print_version(basename(argv[0])); + rc = EXIT_SUCCESS; + goto out; case 'h': + rc = EXIT_SUCCESS; + /* Fallthrough */ default: print_help(); goto out; diff --git a/source/evp_setpeer.c b/source/evp_setpeer.c index 302db5d..58fcf6b 100644 --- a/source/evp_setpeer.c +++ b/source/evp_setpeer.c @@ -11,9 +11,11 @@ #include #include #ifndef _WIN32 +# include # include #else # include +# include "perflib/basename.h" # include "perflib/getopt.h" #endif /* _WIN32 */ #include @@ -114,7 +116,7 @@ static void usage(char * const argv[]) { const char **key_name = sample_names; - fprintf(stderr, "%s -k key_name [-t] threadcount\n", argv[0]); + fprintf(stderr, "%s -k key_name [-t] [-V] threadcount\n", argv[0]); fprintf(stderr, "-t - terse output\n"); fprintf(stderr, "-k - one of these options: %s", *key_name); @@ -125,6 +127,8 @@ static void usage(char * const argv[]) else fprintf(stderr, ", %s", *key_name); } while (*key_name != NULL); + + fprintf(stderr, "-V - print version information and exit\n"); } int main(int argc, char *argv[]) @@ -138,7 +142,7 @@ int main(int argc, char *argv[]) char *key = NULL; int key_id, key_id_min, key_id_max, k; - while ((opt = getopt(argc, argv, "k:t")) != -1) { + while ((opt = getopt(argc, argv, "k:tV")) != -1) { switch (opt) { case 't': terse = 1; @@ -146,6 +150,9 @@ int main(int argc, char *argv[]) case 'k': key = optarg; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: usage(argv); return EXIT_FAILURE; diff --git a/source/handshake.c b/source/handshake.c index cb19b48..8768595 100644 --- a/source/handshake.c +++ b/source/handshake.c @@ -338,6 +338,7 @@ void usage(const char *progname) printf("-o - set ossl_lib_ctx pool size\n"); #endif printf("-S [n] - use secure memory\n"); + printf("-V - print version information and exit\n"); } int main(int argc, char * const argv[]) @@ -355,9 +356,9 @@ int main(int argc, char * const argv[]) while ((opt = getopt(argc, argv, #if OPENSSL_VERSION_NUMBER >= 0x30000000L - "tspPo:lS:" + "tspPo:lS:V" #else - "tsS:" + "tsS:V" #endif )) != -1) { switch (opt) { @@ -421,6 +422,9 @@ int main(int argc, char * const argv[]) } break; } + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: usage(basename(argv[0])); return EXIT_FAILURE; diff --git a/source/newrawkey.c b/source/newrawkey.c index 3b380a9..176c5bb 100644 --- a/source/newrawkey.c +++ b/source/newrawkey.c @@ -395,7 +395,7 @@ int main(int argc, char *argv[]) int rc = EXIT_FAILURE; int opt; - while ((opt = getopt(argc, argv, "ta:")) != -1) { + while ((opt = getopt(argc, argv, "ta:V")) != -1) { switch (opt) { case 't': terse = 1; @@ -420,11 +420,15 @@ int main(int argc, char *argv[]) return EXIT_FAILURE; } break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - printf("Usage: %s [-t] [-a algorithm] threadcount\n", basename(argv[0])); + printf("Usage: %s [-t] [-a algorithm] [-V] threadcount\n", basename(argv[0])); printf("-t - terse output\n"); printf("-a algorithm - specify the algorithm to test (default: x25519)\n"); printf(" Supported algorithms: x25519, ml-kem-512, ml-kem-768, ml-kem-1024\n"); + printf("-V - print version information and exit\n"); return EXIT_FAILURE; } } diff --git a/source/perflib/perfhelper.c b/source/perflib/perfhelper.c index e3e3284..f0ce2ac 100644 --- a/source/perflib/perfhelper.c +++ b/source/perflib/perfhelper.c @@ -7,6 +7,7 @@ * https://www.openssl.org/source/license.html */ +#include #include #include #include @@ -31,3 +32,13 @@ char *perflib_mk_file_path(const char *dir, const char *file) return full_file; } + +void perflib_print_version(const char * const progname) +{ + fprintf(stderr, + "%s version information:\n" + " OpenSSL library: %s (%s)\n", + progname, + OpenSSL_version(OPENSSL_VERSION), + OpenSSL_version(OPENSSL_BUILT_ON)); +} diff --git a/source/perflib/perflib.h b/source/perflib/perflib.h index ce4251e..64dfeff 100644 --- a/source/perflib/perflib.h +++ b/source/perflib/perflib.h @@ -61,3 +61,11 @@ int perflib_create_ssl_connection(SSL *serverssl, SSL *clientssl, int want); void perflib_shutdown_ssl_connection(SSL *serverssl, SSL *clientssl); #endif + +/** + * Print relevant version information. So far only prints OpenSSL library + * version and build date. + * + * @param progname The name of the program. + */ +void perflib_print_version(const char *progname); diff --git a/source/pkeyread.c b/source/pkeyread.c index e04c131..262734d 100644 --- a/source/pkeyread.c +++ b/source/pkeyread.c @@ -12,6 +12,7 @@ #include #include #ifndef _WIN32 +# include # include #else # include @@ -272,10 +273,11 @@ static void usage(char * const argv[]) const char **key_name = sample_names; const char **format_name = format_names; - fprintf(stderr, "%s -k key_name -f format_name [-t] [-v] [-T time] threadcount\n" + fprintf(stderr, "%s -k key_name -f format_name [-t] [-v] [-T time] [-V] threadcount\n" "\t-t terse output\n" "\t-v verbose output, includes min, max, stddev, and median times\n" - "\t-T timeout for each test run in seconds, can be fractional" + "\t-T timeout for each test run in seconds, can be fractional\n" + "\t-V print version information and exit\n" "\twhere key_name is one of these: ", argv[0]); fprintf(stderr, "%s", *key_name); do { @@ -313,7 +315,7 @@ int main(int argc, char * const argv[]) key_id = SAMPLE_INVALID; format_id = FORMAT_INVALID; - while ((ch = getopt(argc, argv, "T:k:f:tv")) != -1) { + while ((ch = getopt(argc, argv, "T:k:f:tviV")) != -1) { switch (ch) { case 'T': { double timeout_s; @@ -342,6 +344,9 @@ int main(int argc, char * const argv[]) case 'v': verbosity = VERBOSITY_VERBOSE; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; } } diff --git a/source/providerdoall.c b/source/providerdoall.c index b9f7e04..dbdbb0d 100644 --- a/source/providerdoall.c +++ b/source/providerdoall.c @@ -68,14 +68,18 @@ int main(int argc, char *argv[]) int ret = EXIT_FAILURE; int opt; - while ((opt = getopt(argc, argv, "t")) != -1) { + while ((opt = getopt(argc, argv, "tV")) != -1) { switch (opt) { case 't': terse = 1; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - printf("Usage: %s [-t] threadcount\n", basename(argv[0])); + printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0])); printf("-t - terse output\n"); + printf("-V - print version information and exit\n"); return EXIT_FAILURE; } } diff --git a/source/randbytes.c b/source/randbytes.c index a72881a..e923ecd 100644 --- a/source/randbytes.c +++ b/source/randbytes.c @@ -58,14 +58,18 @@ int main(int argc, char *argv[]) size_t i; int opt; - while ((opt = getopt(argc, argv, "t")) != -1) { + while ((opt = getopt(argc, argv, "tV")) != -1) { switch (opt) { case 't': terse = 1; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - printf("Usage: %s [-t] threadcount\n", basename(argv[0])); + printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0])); printf("-t - terse output\n"); + printf("-V - print version information and exit\n"); return EXIT_FAILURE; } } diff --git a/source/rsasign.c b/source/rsasign.c index b683c54..b777501 100644 --- a/source/rsasign.c +++ b/source/rsasign.c @@ -82,14 +82,18 @@ int main(int argc, char *argv[]) int i; int opt; - while ((opt = getopt(argc, argv, "t")) != -1) { + while ((opt = getopt(argc, argv, "tV")) != -1) { switch (opt) { case 't': terse = 1; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - printf("Usage: %s [-t] threadcount\n", basename(argv[0])); + printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0])); printf("-t - terse output\n"); + printf("-V - print version information and exit\n"); return EXIT_FAILURE; } } diff --git a/source/rwlocks.c b/source/rwlocks.c index 176c4d9..0807a1c 100644 --- a/source/rwlocks.c +++ b/source/rwlocks.c @@ -110,14 +110,18 @@ int main(int argc, char *argv[]) int opt; int writer_threads; - while ((opt = getopt(argc, argv, "t")) != -1) { + while ((opt = getopt(argc, argv, "tV")) != -1) { switch (opt) { case 't': terse = 1; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - printf("Usage: %s [-t] threadcount\n", basename(argv[0])); + printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0])); printf("-t - terse output\n"); + printf("-V - print version information and exit\n"); return EXIT_FAILURE; } } diff --git a/source/ssl_poll_perf.c b/source/ssl_poll_perf.c index 378058d..1982d64 100644 --- a/source/ssl_poll_perf.c +++ b/source/ssl_poll_perf.c @@ -3104,7 +3104,7 @@ client_thread(void) static void usage(const char *progname) { fprintf(stderr, "%s -p portnum -c connections -b bidi_stream_count " - "-u uni_stream_count -s base_size " + "-u uni_stream_count -s base_size [-V]" "path/to/cert path/to/certkey\n" "\t-p port number to use (<1, 65535>), default 8000\n" "\t-c number of connections to establish, default 10\n" @@ -3112,6 +3112,7 @@ static void usage(const char *progname) "\t-u number of unidirectional streams to use, default 10\n" "\t-s data size to request, default 64\n" "\t-w request body size, default 64\n" + "\t-V print version information and exit\n" "program creates server and client thread.\n" "client establishes `c` connections to server\n" "Each connection carries `b` `and `u` streams to request data\n" @@ -3144,7 +3145,7 @@ main(int argc, char *argv[]) #ifdef _WIN32 progname = argv[0]; #endif - while ((ch = getopt(argc, argv, "p:c:b:u:s:w:t")) != -1) { + while ((ch = getopt(argc, argv, "p:c:b:u:s:w:tV")) != -1) { switch (ch) { case 'p': portstr = optarg; @@ -3167,6 +3168,9 @@ main(int argc, char *argv[]) case 't': terse = 1; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: usage(argv[0]); } diff --git a/source/sslnew.c b/source/sslnew.c index 4dd815c..4efa89a 100644 --- a/source/sslnew.c +++ b/source/sslnew.c @@ -70,14 +70,18 @@ int main(int argc, char *argv[]) int i; int opt; - while ((opt = getopt(argc, argv, "t")) != -1) { + while ((opt = getopt(argc, argv, "tV")) != -1) { switch (opt) { case 't': terse = 1; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - printf("Usage: %s [-t] threadcount\n", basename(argv[0])); + printf("Usage: %s [-t] [-V] threadcount\n", basename(argv[0])); printf("-t - terse output\n"); + printf("-V - print version information and exit\n"); return EXIT_FAILURE; } } diff --git a/source/writeread.c b/source/writeread.c index ff9ecaa..6055066 100644 --- a/source/writeread.c +++ b/source/writeread.c @@ -117,7 +117,7 @@ int main(int argc, char * const argv[]) smethod = TLS_server_method(); cmethod = TLS_client_method(); - while ((opt = getopt(argc, argv, "tsdb:")) != -1) { + while ((opt = getopt(argc, argv, "tsdb:V")) != -1) { switch (opt) { case 't': terse = 1; @@ -136,13 +136,17 @@ int main(int argc, char * const argv[]) return EXIT_FAILURE; } break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - fprintf(stderr, "Usage: %s [-t] [-s] [-d] [-b size] certsdir threadcount\n", + fprintf(stderr, "Usage: %s [-t] [-s] [-d] [-b size] [-V] certsdir threadcount\n", basename(argv[0])); fprintf(stderr, "-t - terse output\n"); fprintf(stderr, "-s - disable context sharing\n"); fprintf(stderr, "-d - use DTLS as connection method\n"); fprintf(stderr, "-b - size of buffer to write and read (Default: 1024)\n"); + fprintf(stderr, "-V - print version information and exit\n"); return EXIT_FAILURE; } } diff --git a/source/x509storeissuer.c b/source/x509storeissuer.c index 941d432..bd927d0 100644 --- a/source/x509storeissuer.c +++ b/source/x509storeissuer.c @@ -80,14 +80,18 @@ int main(int argc, char *argv[]) BIO *bio = NULL; int opt; - while ((opt = getopt(argc, argv, "t")) != -1) { + while ((opt = getopt(argc, argv, "tV")) != -1) { switch (opt) { case 't': terse = 1; break; + case 'V': + perflib_print_version(basename(argv[0])); + return EXIT_SUCCESS; default: - printf("Usage: %s [-t] certsdir threadcount\n", basename(argv[0])); + printf("Usage: %s [-t] [-V] certsdir threadcount\n", basename(argv[0])); printf("-t - terse output\n"); + printf("-V - print version information and exit\n"); return EXIT_FAILURE; } }