From ff9e4aaba4fa583eb6a63bc9f439668bf89ca95e Mon Sep 17 00:00:00 2001 From: David Wells Date: Wed, 1 Mar 2017 09:40:42 -0500 Subject: [PATCH] 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). --- cmake/macros/macro_deal_ii_pickup_tests.cmake | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) 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: # -- 2.39.5