Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 2.28: CMake: generate the list of test suites automatically #5465

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 9 additions & 95 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
39 changes: 9 additions & 30 deletions tests/scripts/all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -846,17 +846,13 @@ component_test_default_out_of_box () {
msg "build: make, default config (out-of-box)" # ~1min
make
# Disable fancy stuff
SAVE_MBEDTLS_TEST_OUTCOME_FILE="$MBEDTLS_TEST_OUTCOME_FILE"
unset MBEDTLS_TEST_OUTCOME_FILE

msg "test: main suites make, default config (out-of-box)" # ~10s
make test

msg "selftest: make, default config (out-of-box)" # ~10s
programs/test/selftest

export MBEDTLS_TEST_OUTCOME_FILE="$SAVE_MBEDTLS_TEST_OUTCOME_FILE"
unset SAVE_MBEDTLS_TEST_OUTCOME_FILE
}

component_test_default_cmake_gcc_asan () {
Expand Down Expand Up @@ -1619,10 +1615,7 @@ component_test_psa_crypto_config_accel_ecdsa () {
loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
make CFLAGS="$ASAN_CFLAGS -O -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"

unset loc_accel_flags
unset loc_accel_list

if_build_succeeded not grep mbedtls_ecdsa_ library/ecdsa.o
not grep mbedtls_ecdsa_ library/ecdsa.o

msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated ECDSA"
make test
Expand Down Expand Up @@ -1705,11 +1698,8 @@ component_test_psa_crypto_config_accel_rsa_signature () {
loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"

unset loc_accel_flags
unset loc_accel_list

if_build_succeeded not grep mbedtls_rsa_rsassa_pkcs1_v15_sign library/rsa.o
if_build_succeeded not grep mbedtls_rsa_rsassa_pss_sign_ext library/rsa.o
not grep mbedtls_rsa_rsassa_pkcs1_v15_sign library/rsa.o
not grep mbedtls_rsa_rsassa_pss_sign_ext library/rsa.o

msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated RSA signature"
make test
Expand Down Expand Up @@ -1745,11 +1735,8 @@ component_test_psa_crypto_config_accel_hash () {
loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"

unset loc_accel_flags
unset loc_accel_list

if_build_succeeded not grep mbedtls_sha512_init library/sha512.o
if_build_succeeded not grep mbedtls_sha1_init library/sha1.o
not grep mbedtls_sha512_init library/sha512.o
not grep mbedtls_sha1_init library/sha1.o

msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
make test
Expand Down Expand Up @@ -1785,10 +1772,7 @@ component_test_psa_crypto_config_accel_cipher () {
loc_accel_flags="$loc_accel_flags $( echo "$loc_accel_list" | sed 's/[^ ]* */-DMBEDTLS_PSA_ACCEL_&/g' )"
make CFLAGS="$ASAN_CFLAGS -Werror -I../tests/include -I../tests -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_TEST_LIBTESTDRIVER1 $loc_accel_flags" LDFLAGS="-ltestdriver1 $ASAN_CFLAGS"

unset loc_accel_flags
unset loc_accel_list

if_build_succeeded not grep mbedtls_des* library/des.o
not grep mbedtls_des* library/des.o

msg "test: MBEDTLS_PSA_CRYPTO_CONFIG with accelerated hash"
make test
Expand Down Expand Up @@ -2576,7 +2560,6 @@ component_test_psa_crypto_drivers () {
loc_cflags="${loc_cflags} -I../tests/include -O2"

make CC=gcc CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"
unset loc_cflags

msg "test: full + MBEDTLS_PSA_CRYPTO_DRIVERS"
make test
Expand Down Expand Up @@ -2996,15 +2979,13 @@ component_test_cmake_out_of_source () {

component_test_cmake_as_subdirectory () {
msg "build: cmake 'as-subdirectory' build"
MBEDTLS_ROOT_DIR="$PWD"

cd programs/test/cmake_subproject
cmake .
make
./cmake_subproject

cd "$MBEDTLS_ROOT_DIR"
unset MBEDTLS_ROOT_DIR
}
support_test_cmake_as_subdirectory () {
support_test_cmake_out_of_source
}

component_test_zeroize () {
Expand Down Expand Up @@ -3033,8 +3014,6 @@ component_test_zeroize () {
make clean
done
done

unset gdb_disable_aslr
}

component_test_psa_compliance () {
Expand Down