Debian Codegraph @

tests/run-roundtrip-test.cmake

raw
1 set(ENV{QEMU_LD_PREFIX} "${BROTLI_WRAPPER_LD_PREFIX}")
2
3 execute_process(
4 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
5 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --quality=${QUALITY} ${INPUT} --output=${OUTPUT}.br
6 RESULT_VARIABLE result
7 ERROR_VARIABLE result_stderr)
8 if(result)
9 message(FATAL_ERROR "Compression failed: ${result_stderr}")
10 endif()
11
12 execute_process(
13 WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
14 COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress ${OUTPUT}.br --output=${OUTPUT}.unbr
15 RESULT_VARIABLE result)
16 if(result)
17 message(FATAL_ERROR "Decompression failed")
18 endif()
19
20 function(test_file_equality f1 f2)
21 if(NOT CMAKE_VERSION VERSION_LESS 2.8.7)
22 file(SHA512 "${f1}" f1_cs)
23 file(SHA512 "${f2}" f2_cs)
24 if(NOT "${f1_cs}" STREQUAL "${f2_cs}")
25 message(FATAL_ERROR "Files do not match")
26 endif()
27 else()
28 file(READ "${f1}" f1_contents)
29 file(READ "${f2}" f2_contents)
30 if(NOT "${f1_contents}" STREQUAL "${f2_contents}")
31 message(FATAL_ERROR "Files do not match")
32 endif()
33 endif()
34 endfunction()
35
36 test_file_equality("${INPUT}" "${OUTPUT}.unbr")