From: David Wells Date: Wed, 1 Mar 2017 14:40:42 +0000 (-0500) Subject: Add a simple numdiff relative tolerance test. X-Git-Tag: v8.5.0-rc1~84^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4007%2Fhead;p=dealii.git Add a simple numdiff relative tolerance test. 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). --- diff --git a/cmake/macros/macro_deal_ii_pickup_tests.cmake b/cmake/macros/macro_deal_ii_pickup_tests.cmake index 460ed70ca2..3ef5bfff06 100644 --- a/cmake/macros/macro_deal_ii_pickup_tests.cmake +++ b/cmake/macros/macro_deal_ii_pickup_tests.cmake @@ -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: #