[trunk] improve test suite by checking against a reference md5
authorMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 24 Feb 2014 16:07:21 +0000 (16:07 +0000)
committerMathieu Malaterre <mathieu.malaterre@gmail.com>
Mon, 24 Feb 2014 16:07:21 +0000 (16:07 +0000)
tests/nonregression/CMakeLists.txt
tests/nonregression/checkmd5refs.cmake [new file with mode: 0644]
tests/nonregression/md5refs.txt [new file with mode: 0644]

index 0bcf86bc6be8212f7d99435b0803552df1d29d56..95fd08af3ef2186080d66df9a216f03ecbbf463b 100644 (file)
@@ -300,6 +300,12 @@ foreach(OPJ_TEST_CMD_LINE ${OPJ_TEST_CMD_LINE_LIST})
         set_tests_properties(NR-DEC-${INPUT_FILENAME_NAME}-${IT_TEST_DEC}-decode PROPERTIES WILL_FAIL TRUE)
 
       else()
+        # if not failed, check against registered md5:
+        add_test(NAME NR-DEC-${INPUT_FILENAME_NAME}-${IT_TEST_DEC}-decode-md5 COMMAND ${CMAKE_COMMAND}
+          -DREFFILE:STRING=${CMAKE_CURRENT_SOURCE_DIR}/md5refs.txt
+          -DFILENAME:STRING=${INPUT_FILENAME_NAME}
+          -P ${CMAKE_CURRENT_SOURCE_DIR}/checkmd5refs.cmake)
+
 
 # FIXME: add a compare2base function base on raw which
 # can output png diff files if necesary
diff --git a/tests/nonregression/checkmd5refs.cmake b/tests/nonregression/checkmd5refs.cmake
new file mode 100644 (file)
index 0000000..fd583e2
--- /dev/null
@@ -0,0 +1,48 @@
+#  Copyright (c) 2014 Mathieu Malaterre <mathieu.malaterre@voxxl.com>
+#
+#  Redistribution and use is allowed according to the terms of the New
+#  BSD license.
+#  For details see the accompanying COPYING-CMAKE-SCRIPTS file.
+
+# check md5 refs
+#
+# This script will be used to make sure we never introduce a regression on any
+# of the nonregression file.
+#
+# The approach is relatively simple, we compute a md5sum for each of the decode
+# file. Anytime the md5sum is different from the reference one, we assume
+# something went wrong and simply fails.  of course if could happen during the
+# course of openjpeg development that the internals are changed that impact the
+# decoding process that the output would be bitwise different (while PSNR would
+# be kept identical).
+
+#message("0: ${REFFILE}")
+#message("1: ${CMAKE_CURRENT_BINARY_DIR}")
+#message("2: ${FILENAME}")
+execute_process(
+  COMMAND ${CMAKE_COMMAND} -E md5sum ${FILENAME}.png
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Temporary
+  RESULT_VARIABLE res
+  OUTPUT_VARIABLE output
+  ERROR_VARIABLE  error_output
+  OUTPUT_STRIP_TRAILING_WHITESPACE # important
+)
+
+# Pass the output back to ctest
+if(res)
+  message(SEND_ERROR "md5 could not be computed, it failed with value ${res}. Output was: ${error_output}")
+endif()
+
+#message("3: ${output}")
+
+file(READ ${REFFILE} variable)
+#message("4: ${variable}")
+string(REGEX MATCH "^.*${FILENAME}.png" output_var ${variable})
+
+#message("5: ${output_var}")
+
+if("${output_var}" STREQUAL "${output}")
+  #message("6: eqal")
+else()
+  message(SEND_ERROR "not equal: [${output_var}] vs [${output}]")
+endif()
diff --git a/tests/nonregression/md5refs.txt b/tests/nonregression/md5refs.txt
new file mode 100644 (file)
index 0000000..e69de29