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