checkmd5refs.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Copyright (c) 2014 Mathieu Malaterre <mathieu.malaterre@voxxl.com>
  2. #
  3. # Redistribution and use is allowed according to the terms of the New
  4. # BSD license.
  5. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  6. # check md5 refs
  7. #
  8. # This script will be used to make sure we never introduce a regression on any
  9. # of the nonregression file.
  10. #
  11. # The approach is relatively simple, we compute a md5sum for each of the decode
  12. # file. Anytime the md5sum is different from the reference one, we assume
  13. # something went wrong and simply fails. of course if could happen during the
  14. # course of openjpeg development that the internals are changed that impact the
  15. # decoding process that the output would be bitwise different (while PSNR would
  16. # be kept identical).
  17. # Another more conventional approach is to store the generated output from
  18. # openjpeg however storing the full generated output is generally useless since
  19. # we do not really care about the exact pixel value, we simply need to known
  20. # when a code change impact output generation. furthermore storing the
  21. # complete generated output file, tends to make the svn:/openjpeg-data really
  22. # big.
  23. # This script expect two inputs
  24. # REFFILE: Path to the md5sum.txt file
  25. # OUTFILENAME: The name of the generated file we want to check The script will
  26. # check whether a PGX or a PNG file was generated in the test suite (computed
  27. # from OUTFILENAME)
  28. get_filename_component(OUTFILENAME_NAME ${OUTFILENAME} NAME)
  29. string(FIND ${OUTFILENAME_NAME} "." SHORTEST_EXT_POS REVERSE)
  30. string(SUBSTRING ${OUTFILENAME_NAME} 0 ${SHORTEST_EXT_POS} OUTFILENAME_NAME_WE)
  31. file(GLOB globfiles "Temporary/${OUTFILENAME_NAME_WE}*.pgx" "Temporary/${OUTFILENAME_NAME_WE}*.png" "Temporary/${OUTFILENAME_NAME_WE}*.tif")
  32. if(NOT globfiles)
  33. message(SEND_ERROR "Could not find output PGX files: ${OUTFILENAME_NAME_WE}")
  34. endif()
  35. # REFFILE follow what `md5sum -c` would expect as input:
  36. file(READ ${REFFILE} variable)
  37. foreach(pgxfullpath ${globfiles})
  38. file(MD5 ${pgxfullpath} output)
  39. get_filename_component(pgxfile ${pgxfullpath} NAME)
  40. string(REGEX MATCH "[0-9a-f]+ ${pgxfile}" output_var "${variable}")
  41. set(output "${output} ${pgxfile}")
  42. if("${output_var}" STREQUAL "${output}")
  43. message(STATUS "equal: [${output_var}] vs [${output}]")
  44. else()
  45. message(SEND_ERROR "not equal: [${output_var}] vs [${output}]")
  46. endif()
  47. endforeach()