diff options
| author | Hans Kristian Rosbach <hk-git@circlestorm.org> | 2025-11-11 17:24:26 +0100 |
|---|---|---|
| committer | Hans Kristian Rosbach <hk-github@circlestorm.org> | 2025-11-16 12:15:05 +0100 |
| commit | 8d4bd56217ab8f2701bc3f2fa643dcf45d460343 (patch) | |
| tree | c8349bdeabf24044b81bc775e47d8b5f45131d33 /test | |
| parent | 30ff317fb42797a2456f1747476cfc5c0085425c (diff) | |
| download | Project-Tick-8d4bd56217ab8f2701bc3f2fa643dcf45d460343.tar.gz Project-Tick-8d4bd56217ab8f2701bc3f2fa643dcf45d460343.zip | |
Use CTest to simplify testing options
Add CMake variable TEST_STOCK_ZLIB to disable some tests if attempting
to run our testsuite on stock zlib.
PR depends on CMP0077, introduced by CMake 3.13.
Upped minimum compatible CMake version to 3.13, same as we have
actually been telling people was the minumum for years on the wiki.
Upped upper compatible CMake version to 3.31, my current version.
Diffstat (limited to 'test')
| -rw-r--r-- | test/CMakeLists.txt | 11 | ||||
| -rw-r--r-- | test/add-subdirectory-project/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | test/example.c | 4 | ||||
| -rw-r--r-- | test/fuzz/CMakeLists.txt | 8 | ||||
| -rw-r--r-- | test/infcover.c | 4 | ||||
| -rw-r--r-- | test/test_shared_ng.h | 2 |
6 files changed, 15 insertions, 16 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a9eb9f609d..a2304cf02b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,8 +7,8 @@ macro(configure_test_executable target) endif() endmacro() -if(ZLIBNG_ENABLE_TESTS) - add_definitions(-DZLIBNG_ENABLE_TESTS) +if(TEST_STOCK_ZLIB) + add_definitions(-DTEST_STOCK_ZLIB) endif() add_executable(example example.c) @@ -53,10 +53,7 @@ target_link_libraries(infcover zlib-ng) if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) target_sources(infcover PRIVATE ${PROJECT_SOURCE_DIR}/inftrees.c) endif() -# infcover references zng_inflate_table() and struct inflate_state, which are internal to zlib-ng. -if(ZLIBNG_ENABLE_TESTS) - add_test(NAME infcover COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:infcover>) -endif() +add_test(NAME infcover COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:infcover>) add_executable(makefixed ${PROJECT_SOURCE_DIR}/tools/makefixed.c ${PROJECT_SOURCE_DIR}/inftrees.c) configure_test_executable(makefixed) @@ -177,7 +174,7 @@ if(WITH_GTEST) list(APPEND TEST_SRCS test_gzio.cc) endif() - if(ZLIBNG_ENABLE_TESTS) + if(NOT TEST_STOCK_ZLIB) list(APPEND TEST_SRCS test_adler32.cc # adler32_neon(), etc test_compare256.cc # compare256_neon(), etc diff --git a/test/add-subdirectory-project/CMakeLists.txt b/test/add-subdirectory-project/CMakeLists.txt index 2c35218ac8..7a25d1ae72 100644 --- a/test/add-subdirectory-project/CMakeLists.txt +++ b/test/add-subdirectory-project/CMakeLists.txt @@ -5,7 +5,7 @@ project(zlib-ng-add-subdirecory-test C) include(CTest) set(BUILD_SHARED_LIBS OFF) -set(ZLIB_ENABLE_TESTS ON CACHE BOOL "Build test binaries" FORCE) +set(BUILD_TESTING ON CACHE BOOL "Build test binaries" FORCE) add_subdirectory(../.. zlib-ng) diff --git a/test/example.c b/test/example.c index 5393fa5de9..fd62bd5d7f 100644 --- a/test/example.c +++ b/test/example.c @@ -420,7 +420,7 @@ static void test_flush(unsigned char *compr, z_uintmax_t *comprLen) { *comprLen = (z_size_t)c_stream.total_out; } -#ifdef ZLIBNG_ENABLE_TESTS +#ifndef TEST_STOCK_ZLIB /* =========================================================================== * Test inflateSync() * We expect a certain compressed block layout, so skip this with the original zlib. @@ -979,7 +979,7 @@ int main(int argc, char *argv[]) { #endif test_flush(compr, &comprLen); -#ifdef ZLIBNG_ENABLE_TESTS +#ifndef TEST_STOCK_ZLIB test_sync(compr, comprLen, uncompr, uncomprLen); #endif comprLen = uncomprLen; diff --git a/test/fuzz/CMakeLists.txt b/test/fuzz/CMakeLists.txt index e5a7455dda..8f0972de7f 100644 --- a/test/fuzz/CMakeLists.txt +++ b/test/fuzz/CMakeLists.txt @@ -39,9 +39,7 @@ foreach(FUZZER ${FUZZERS}) target_link_libraries(${FUZZER} ${FUZZING_ENGINE}) endif() - if(ZLIB_ENABLE_TESTS) - file(GLOB FUZZER_TEST_FILES ${PROJECT_SOURCE_DIR}/*) - set(FUZZER_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${FUZZER}> ${FUZZER_TEST_FILES}) - add_test(NAME ${FUZZER} COMMAND ${FUZZER_COMMAND}) - endif() + file(GLOB FUZZER_TEST_FILES ${PROJECT_SOURCE_DIR}/*) + set(FUZZER_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:${FUZZER}> ${FUZZER_TEST_FILES}) + add_test(NAME ${FUZZER} COMMAND ${FUZZER_COMMAND}) endforeach() diff --git a/test/infcover.c b/test/infcover.c index 91b6b57961..ba922dfcb3 100644 --- a/test/infcover.c +++ b/test/infcover.c @@ -618,6 +618,7 @@ static void cover_inflate(void) { inf("63 18 5 40 c 0", "window wrap", 3, -8, 300, Z_OK); } +#ifndef TEST_STOCK_ZLIB /* cover remaining lines in inftrees.c */ static void cover_trees(void) { int ret; @@ -641,6 +642,7 @@ static void cover_trees(void) { fputs("inflate_table not enough errors\n", stderr); Z_UNUSED(ret); } +#endif /* cover remaining inffast.c decoding and window copying */ static void cover_fast(void) { @@ -672,7 +674,9 @@ int main(void) { cover_wrap(); cover_back(); cover_inflate(); +#ifndef TEST_STOCK_ZLIB cover_trees(); +#endif cover_fast(); cover_cve_2022_37434(); return 0; diff --git a/test/test_shared_ng.h b/test/test_shared_ng.h index 81e451998f..f87ef027e2 100644 --- a/test/test_shared_ng.h +++ b/test/test_shared_ng.h @@ -8,7 +8,7 @@ static inline int deflate_prime_32(PREFIX3(stream) *stream, uint32_t value) { int err; -#ifdef ZLIBNG_ENABLE_TESTS +#ifndef TEST_STOCK_ZLIB err = PREFIX(deflatePrime)(stream, 32, value); #else /* zlib's deflatePrime() takes at most 16 bits */ |
