]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add a simple numdiff relative tolerance test. 4007/head
authorDavid Wells <wellsd2@rpi.edu>
Wed, 1 Mar 2017 14:40:42 +0000 (09:40 -0500)
committerDavid Wells <wellsd2@rpi.edu>
Wed, 1 Mar 2017 14:40:42 +0000 (09:40 -0500)
This test ensures that we can use numdiff to check differences with a relative
tolerance (i.e., that numdiff is not a symlink to diff).

cmake/macros/macro_deal_ii_pickup_tests.cmake

index 460ed70ca2e54d463fa6b04017feb56382aa7b14..3ef5bfff067d063923121bf2173f3c0757a40bfc 100644 (file)
@@ -133,6 +133,45 @@ MACRO(DEAL_II_PICKUP_TESTS)
     ENDIF()
   ENDFOREACH()
 
+  #
+  # Also check that numdiff is not a symlink to diff by running a relative
+  # tolerance test. Note that we set NUMDIFF_EXECUTABLE to diff in case we were
+  # not able to find it above, but here we check that the executable is really
+  # named 'numdiff'.
+  #
+  STRING(FIND "${NUMDIFF_EXECUTABLE}" "numdiff" _found_numdiff_binary)
+  IF(NOT "${_found_numdiff_binary}" STREQUAL "-1")
+    SET(_first_test_file_name
+      "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/numdiff-test-1.txt")
+    SET(_second_test_file_name
+      "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/numdiff-test-2.txt")
+    FILE(WRITE "${_first_test_file_name}" "0.99999999998\n2.0\n1.0\n")
+    FILE(WRITE "${_second_test_file_name}" "1.00000000001\n2.0\n1.0\n")
+
+    EXECUTE_PROCESS(COMMAND ${NUMDIFF_EXECUTABLE}
+      "-r" "1.0e-8" "--" "${_first_test_file_name}" "${_second_test_file_name}"
+      TIMEOUT 4 # seconds
+      OUTPUT_QUIET
+      ERROR_QUIET
+      RESULT_VARIABLE _numdiff_tolerance_test_status
+      )
+
+    #
+    # Tidy up:
+    #
+    FILE(REMOVE ${_first_test_file_name})
+    FILE(REMOVE ${_second_test_file_name})
+
+    IF(NOT "${_numdiff_tolerance_test_status}" STREQUAL "0")
+      MESSAGE(FATAL_ERROR
+        "\nThe detected numdiff executable was not able to pass a simple "
+        "relative tolerance test. This usually means that either numdiff "
+        "was misconfigured or that it is a symbolic link to diff. "
+        "The test suite needs numdiff to work correctly: please reinstall "
+        "numdiff and run the test suite configuration again.\n")
+    ENDIF()
+  ENDIF()
+
   #
   # Set time limit:
   #

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.