Debian Codegraph @

ext/zlib-ng/test/cmake/test-data.cmake

raw
1 # test-data.cmake - Tests targeting data files in the data directory
2
3 # Test compress and verify test against data file using extra args
4 macro(test_minigzip name path)
5 # Construct compression arguments for minigzip
6 set(compress_args -k -c)
7 foreach(extra_arg IN ITEMS "${ARGN}")
8 list(APPEND compress_args ${extra_arg})
9 endforeach()
10
11 # Create unique friendly string for test
12 string(REPLACE ";" "" arg_list "${ARGN}")
13 string(REPLACE " " "" arg_list "${arg_list}")
14 string(REPLACE "-" "" arg_list "${arg_list}")
15
16 set(test_id minigzip-${name}-${arg_list})
17
18 if(NOT TEST ${test_id})
19 add_test(NAME ${test_id}
20 COMMAND ${CMAKE_COMMAND}
21 "-DTARGET=${MINIGZIP_COMMAND}"
22 "-DCOMPRESS_ARGS=${compress_args}"
23 "-DDECOMPRESS_ARGS=-d;-c"
24 -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${path}
25 -DTEST_NAME=${test_id}
26 -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compress-and-verify.cmake)
27 endif()
28 endmacro()
29
30 # List of arg combinations to use during compression
31 set(TEST_CONFIGS
32 -R # Z_RLE
33 -h # Z_HUFFMAN_ONLY
34 -T # Direct store
35 -0 # No compression
36 -1 # Deflate quick
37 -4 # Deflate medium (lazy matches)
38 "-5;-F" # Deflate medium (Z_FIXED)
39 -6 # Deflate medium
40 -9 # Deflate slow
41 "-9;-f" # Deflate slow (Z_FILTERED)
42 )
43
44 # Enumerate all files in data directory to run tests against
45 file(GLOB_RECURSE TEST_FILE_PATHS
46 LIST_DIRECTORIES false
47 RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
48 ${CMAKE_CURRENT_SOURCE_DIR}/data/*)
49
50 # For all files in the data directory, run tests against them
51 foreach(test_file_path ${TEST_FILE_PATHS})
52 if("${test_file_path}" MATCHES ".gz$" OR "${test_file_path}" MATCHES ".out$" OR
53 "${test_file_path}" MATCHES "/.git/" OR "${test_file_path}" MATCHES ".md$")
54 continue()
55 endif()
56 foreach(test_config ${TEST_CONFIGS})
57 get_filename_component(test_name ${test_file_path} NAME)
58 if (test_name STREQUAL "")
59 continue()
60 endif()
61 test_minigzip(${test_name} ${test_file_path} ${test_config})
62 endforeach()
63 endforeach()
64
65 # Additional tests to verify with automatic data type detection arg
66 test_minigzip("detect-text" "data/lcet10.txt" -A)
67 test_minigzip("detect-binary" "data/paper-100k.pdf" -A)