From 3df1dae6c0afd25acb9d9c7f1262daf957747d3b Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 25 Jan 2022 22:30:25 +0100 Subject: [PATCH] CMake: generate the list of test suites automatically We keep forgetting to register new test suites in tests/CMakeLists.txt. To fix this problem once and for all, remove the need for manual registration. The following test suites were missing: test_suite_cipher.aria test_suite_psa_crypto_driver_wrappers Signed-off-by: Gilles Peskine --- tests/CMakeLists.txt | 104 ++++--------------------------------------- 1 file changed, 9 insertions(+), 95 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f86127245..5dfddb717 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -77,101 +77,15 @@ if(MSVC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX-") endif(MSVC) -add_test_suite(aes aes.cbc) -add_test_suite(aes aes.cfb) -add_test_suite(aes aes.ecb) -add_test_suite(aes aes.ofb) -add_test_suite(aes aes.rest) -add_test_suite(aes aes.xts) -add_test_suite(arc4) -add_test_suite(aria) -add_test_suite(asn1parse) -add_test_suite(asn1write) -add_test_suite(base64) -add_test_suite(blowfish) -add_test_suite(camellia) -add_test_suite(ccm) -add_test_suite(chacha20) -add_test_suite(chachapoly) -add_test_suite(cipher cipher.aes) -add_test_suite(cipher cipher.arc4) -add_test_suite(cipher cipher.blowfish) -add_test_suite(cipher cipher.camellia) -add_test_suite(cipher cipher.ccm) -add_test_suite(cipher cipher.chacha20) -add_test_suite(cipher cipher.chachapoly) -add_test_suite(cipher cipher.des) -add_test_suite(cipher cipher.gcm) -add_test_suite(cipher cipher.misc) -add_test_suite(cipher cipher.nist_kw) -add_test_suite(cipher cipher.null) -add_test_suite(cipher cipher.padding) -add_test_suite(cmac) -add_test_suite(ctr_drbg) -add_test_suite(debug) -add_test_suite(des) -add_test_suite(dhm) -add_test_suite(ecdh) -add_test_suite(ecdsa) -add_test_suite(ecjpake) -add_test_suite(ecp) -add_test_suite(entropy) -add_test_suite(error) -add_test_suite(gcm gcm.aes128_de) -add_test_suite(gcm gcm.aes128_en) -add_test_suite(gcm gcm.aes192_de) -add_test_suite(gcm gcm.aes192_en) -add_test_suite(gcm gcm.aes256_de) -add_test_suite(gcm gcm.aes256_en) -add_test_suite(gcm gcm.camellia) -add_test_suite(gcm gcm.misc) -add_test_suite(hkdf) -add_test_suite(hmac_drbg hmac_drbg.misc) -add_test_suite(hmac_drbg hmac_drbg.no_reseed) -add_test_suite(hmac_drbg hmac_drbg.nopr) -add_test_suite(hmac_drbg hmac_drbg.pr) -add_test_suite(md) -add_test_suite(mdx) -add_test_suite(memory_buffer_alloc) -add_test_suite(mpi) -add_test_suite(mps) -add_test_suite(net) -add_test_suite(nist_kw) -add_test_suite(oid) -add_test_suite(pem) -add_test_suite(pk) -add_test_suite(pkcs1_v15) -add_test_suite(pkcs1_v21) -add_test_suite(pkcs5) -add_test_suite(pkcs12) -add_test_suite(pkparse) -add_test_suite(pkwrite) -add_test_suite(poly1305) -add_test_suite(psa_crypto) -add_test_suite(psa_crypto_attributes) -add_test_suite(psa_crypto_entropy) -add_test_suite(psa_crypto_hash) -add_test_suite(psa_crypto_init) -add_test_suite(psa_crypto_metadata) -add_test_suite(psa_crypto_not_supported psa_crypto_not_supported.generated) -add_test_suite(psa_crypto_not_supported psa_crypto_not_supported.misc) -add_test_suite(psa_crypto_persistent_key) -add_test_suite(psa_crypto_se_driver_hal) -add_test_suite(psa_crypto_se_driver_hal_mocks) -add_test_suite(psa_crypto_slot_management) -add_test_suite(psa_crypto_storage_format psa_crypto_storage_format.misc) -add_test_suite(psa_crypto_storage_format psa_crypto_storage_format.current) -add_test_suite(psa_crypto_storage_format psa_crypto_storage_format.v0) -add_test_suite(psa_its) -add_test_suite(random) -add_test_suite(rsa) -add_test_suite(shax) -add_test_suite(ssl) -add_test_suite(timing) -add_test_suite(version) -add_test_suite(x509parse) -add_test_suite(x509write) -add_test_suite(xtea) +file(GLOB test_suites RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" suites/*.data) +list(SORT test_suites) +foreach(test_suite ${test_suites}) + get_filename_component(data_name ${test_suite} NAME) + string(REGEX REPLACE "\\.data\$" "" data_name "${data_name}") + string(REPLACE "test_suite_" "" data_name "${data_name}") + string(REGEX MATCH "[^.]*" function_name "${data_name}") + add_test_suite(${function_name} ${data_name}) +endforeach(test_suite) # Make scripts and data files needed for testing available in an # out-of-source build.