Home | History | Annotate | Download | only in tests
      1 string(REGEX REPLACE "([a-zA-Z0-9\\.]+)\\.compressed(\\.[0-9]+)?$" "\\1" REFERENCE_DATA "${INPUT}")
      2 string(REGEX REPLACE "\\.compressed" "" OUTPUT_FILE "${INPUT}")
      3 get_filename_component(OUTPUT_NAME "${OUTPUT_FILE}" NAME)
      4 
      5 execute_process(
      6   WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
      7   COMMAND ${BROTLI_WRAPPER} ${BROTLI_CLI} --force --decompress ${INPUT} --output=${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbr
      8   RESULT_VARIABLE result)
      9 if(result)
     10   message(FATAL_ERROR "Decompression failed")
     11 endif()
     12 
     13 function(test_file_equality f1 f2)
     14   if(NOT CMAKE_VERSION VERSION_LESS 2.8.7)
     15     file(SHA512 "${f1}" f1_cs)
     16     file(SHA512 "${f2}" f2_cs)
     17     if(NOT "${f1_cs}" STREQUAL "${f2_cs}")
     18       message(FATAL_ERROR "Files do not match")
     19     endif()
     20   else()
     21     file(READ "${f1}" f1_contents)
     22     file(READ "${f2}" f2_contents)
     23     if(NOT "${f1_contents}" STREQUAL "${f2_contents}")
     24       message(FATAL_ERROR "Files do not match")
     25     endif()
     26   endif()
     27 endfunction()
     28 
     29 test_file_equality("${REFERENCE_DATA}" "${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_NAME}.unbr")
     30