diff options
author | Evan Nemerson <evan@nemerson.com> | 2016-06-20 13:07:35 -0700 |
---|---|---|
committer | Evan Nemerson <evan@nemerson.com> | 2016-07-26 08:53:26 -0700 |
commit | 93ef13f8235b48f80964c6da092fb5aec514c3d9 (patch) | |
tree | f05c392678367f766c076b31e85f2ee0d77e6891 /tests | |
parent | 8b7e3c7ba54df4b1edf59069b54e92aa79ed8f46 (diff) | |
download | brotli-93ef13f8235b48f80964c6da092fb5aec514c3d9.zip brotli-93ef13f8235b48f80964c6da092fb5aec514c3d9.tar.gz brotli-93ef13f8235b48f80964c6da092fb5aec514c3d9.tar.bz2 |
Add CMake build system.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/run-compatibility-test.cmake | 28 | ||||
-rw-r--r-- | tests/run-roundtrip-test.cmake | 35 |
2 files changed, 63 insertions, 0 deletions
diff --git a/tests/run-compatibility-test.cmake b/tests/run-compatibility-test.cmake new file mode 100644 index 0000000..9e7461b --- /dev/null +++ b/tests/run-compatibility-test.cmake @@ -0,0 +1,28 @@ +string(REGEX REPLACE "([a-zA-Z0-9\\.]+)\\.compressed(\\.[0-9]+)?$" "\\1" REFERENCE_DATA "${INPUT}") +get_filename_component(OUTPUT_NAME "${REFERENCE_DATA}" NAME) + +execute_process( + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND ${BROTLI_CLI} -f -d -i "${INPUT}" -o "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro" + RESULT_VARIABLE result) +if(result) + message(FATAL_ERROR "Decompression failed") +endif() + +function(test_file_equality f1 f2) + if(NOT CMAKE_VERSION VERSION_LESS 2.8.7) + file(SHA512 "${f1}" f1_cs) + file(SHA512 "${f2}" f2_cs) + if(NOT "${f1_cs}" STREQUAL "${f2_cs}") + message(FATAL_ERROR "Files do not match") + endif() + else() + file(READ "${f1}" f1_contents) + file(READ "${f2}" f2_contents) + if(NOT "${f1_contents}" STREQUAL "${f2_contents}") + message(FATAL_ERROR "Files do not match") + endif() + endif() +endfunction() + +test_file_equality("${REFERENCE_DATA}" "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro") diff --git a/tests/run-roundtrip-test.cmake b/tests/run-roundtrip-test.cmake new file mode 100644 index 0000000..6cbd906 --- /dev/null +++ b/tests/run-roundtrip-test.cmake @@ -0,0 +1,35 @@ +get_filename_component(OUTPUT_NAME "${INPUT}" NAME) + +execute_process( + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND ${BROTLI_CLI} -f -q ${QUALITY} -i "${INPUT}" -o "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.bro" + RESULT_VARIABLE result) +if(result) + message(FATAL_ERROR "Compression failed") +endif() + +execute_process( + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + COMMAND ${BROTLI_CLI} -f -d -i "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.bro" -o "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro" + RESULT_VARIABLE result) +if(result) + message(FATAL_ERROR "Decompression failed") +endif() + +function(test_file_equality f1 f2) + if(NOT CMAKE_VERSION VERSION_LESS 2.8.7) + file(SHA512 "${f1}" f1_cs) + file(SHA512 "${f2}" f2_cs) + if(NOT "${f1_cs}" STREQUAL "${f2_cs}") + message(FATAL_ERROR "Files do not match") + endif() + else() + file(READ "${f1}" f1_contents) + file(READ "${f2}" f2_contents) + if(NOT "${f1_contents}" STREQUAL "${f2_contents}") + message(FATAL_ERROR "Files do not match") + endif() + endif() +endfunction() + +test_file_equality("${INPUT}" "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbro") |