From 006040b29c83104403621e950ada0c8956c56b3d Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Mon, 20 May 2024 16:55:00 +0300 Subject: [PATCH] CMake: Prepare to support the test_*.sh tests This is a bit hacky since the scripts grep config.h to know which features were built but the CMake build doesn't create config.h. So instead those test scripts will be run only when all relevant features have been enabled. --- tests/tests.cmake | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/tests.cmake b/tests/tests.cmake index 388a427e..2e9e80a3 100644 --- a/tests/tests.cmake +++ b/tests/tests.cmake @@ -16,6 +16,10 @@ include(CTest) if(BUILD_TESTING) + ################# + # liblzma tests # + ################# + set(LIBLZMA_TESTS test_bcj_exact_size test_block_header @@ -72,6 +76,51 @@ if(BUILD_TESTING) ) endforeach() + + ########################### + # Command line tool tests # + ########################### + + # Since the CMake-based build doesn't use config.h, the test scripts + # cannot grep the contents of config.h to know which features have + # been disabled. When config.h is missing, they assume that all + # features are enabled. Thus, check if certain groups of features have + # been disabled and then possibly skip some of the tests entirely instead + # of letting them fail. + set(SUPPORTED_FILTERS_SORTED "${SUPPORTED_FILTERS}") + list(SORT SUPPORTED_FILTERS_SORTED) + + set(ENCODERS_SORTED "${ENCODERS}") + list(SORT ENCODERS_SORTED) + + if("${ENCODERS_SORTED}" STREQUAL "${SUPPORTED_FILTERS_SORTED}") + set(HAVE_ALL_ENCODERS ON) + else() + set(HAVE_ALL_ENCODERS OFF) + endif() + + set(DECODERS_SORTED "${DECODERS}") + list(SORT DECODERS_SORTED) + + if("${DECODERS_SORTED}" STREQUAL "${SUPPORTED_FILTERS_SORTED}") + set(HAVE_ALL_DECODERS ON) + else() + set(HAVE_ALL_DECODERS OFF) + endif() + + set(ADDITIONAL_SUPPORTED_CHECKS_SORTED "${ADDITIONAL_SUPPORTED_CHECKS}") + list(SORT ADDITIONAL_SUPPORTED_CHECKS_SORTED) + + set(ADDITIONAL_CHECK_TYPES_SORTED "${ADDITIONAL_CHECK_TYPES}") + list(SORT ADDITIONAL_CHECK_TYPES_SORTED) + + if("${ADDITIONAL_SUPPORTED_CHECKS_SORTED}" STREQUAL + "${ADDITIONAL_CHECK_TYPES_SORTED}") + set(HAVE_ALL_CHECK_TYPES ON) + else() + set(HAVE_ALL_CHECK_TYPES OFF) + endif() + if(UNIX AND HAVE_DECODERS) file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_scripts")