run-roundtrip-test.cmake 1.1 KB

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