From 9962fc5171cb8f739860ecbf661966d40f877b5e Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Fri, 6 Sep 2013 02:24:12 +0000 Subject: [PATCH] Add support for mpirun=x syntax git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@30616 0785d39b-7218-0410-832d-ea1e28bc413d --- .../cmake/macros/macro_deal_ii_add_test.cmake | 29 ++++++++++++------- .../macros/macro_deal_ii_pickup_tests.cmake | 18 ++++++++---- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/deal.II/cmake/macros/macro_deal_ii_add_test.cmake b/deal.II/cmake/macros/macro_deal_ii_add_test.cmake index 714eb27d65..5bd819908a 100644 --- a/deal.II/cmake/macros/macro_deal_ii_add_test.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_add_test.cmake @@ -28,14 +28,22 @@ # # # Usage: -# DEAL_II_ADD_TEST(category test_name comparison_file [configurations]) +# DEAL_II_ADD_TEST(category test_name comparison_file n_cpu [configurations]) # # This macro assumes that a source file # # ./tests/category/.cc # +# as well as the comparison file +# +# ./tests/category/ +# # is available in the testsuite. # +# If is equal to 0, the plain, generated executable will be run. If +# is a number larger than 0, the mpirun loader will be used to +# launch the executable +# # [configurations] is a list of configurations against this test should be # run. Possible values are an empty list, DEBUG, RELEASE or # "DEBUG;RELEASE". @@ -44,7 +52,7 @@ # . # -MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) +MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file _n_cpu) FOREACH(_build ${DEAL_II_BUILD_TYPES}) @@ -82,17 +90,24 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) ${DEAL_II_BASE_NAME}${DEAL_II_${_build}_SUFFIX} ) + # + # Build up the command line to run the test depending on _n_cpu: + # + IF("${_n_cpu}" STREQUAL "0") + SET(_run_command ${_full_test}) + ELSE() + SET(_run_command mpirun -np ${_n_cpu} ${_full_test}) + ENDIF() # # Add a top level target to run and compare the test: # - ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_test}/output COMMAND # A this stage a build is always successful: :-) ${CMAKE_COMMAND} -E echo "${_full_test}: BUILD successful" COMMAND - ${_full_test} + ${_run_command} || (echo "${_full_test}: RUN failed. Output:" && cat output && rm output @@ -109,7 +124,6 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) ${_full_test} ${CMAKE_SOURCE_DIR}/cmake/scripts/normalize.pl ) - ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_test}/diff COMMAND ${TEST_DIFF} @@ -137,7 +151,6 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) # # And finally add the test: # - ADD_TEST(NAME ${_category}/${_test} COMMAND ${CMAKE_COMMAND} -DTEST=${_full_test}.diff @@ -149,10 +162,6 @@ MACRO(DEAL_II_ADD_TEST _category _test_name _comparison_file) LABEL "${_category}" TIMEOUT ${TEST_TIME_LIMIT} ) - ENDIF() - ENDFOREACH() - ENDMACRO() - diff --git a/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake b/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake index 3342bc92a4..de26c18acc 100644 --- a/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_pickup_tests.cmake @@ -28,7 +28,6 @@ MACRO(DEAL_II_PICKUP_TESTS) GET_FILENAME_COMPONENT(_category ${CMAKE_CURRENT_SOURCE_DIR} NAME) FILE(GLOB _tests "*.output") - FOREACH(_test ${_tests}) # @@ -44,8 +43,8 @@ MACRO(DEAL_II_PICKUP_TESTS) ENDIF() # - # Query configuration and check whether we support it. Otherwise do - # not define test: + # Query configuration and check whether we support it. Otherwise + # set _define_test to FALSE: # STRING(REGEX MATCHALL "WITH_([0-9]|[A-Z]|_)*=(ON|OFF)" _matches ${_test}) FOREACH(_match ${_matches}) @@ -60,10 +59,19 @@ MACRO(DEAL_II_PICKUP_TESTS) ENDIF() ENDFOREACH() + IF(_define_test) + # - # TODO: mpirun support + # Determine whether the test should be run with mpirun: # + STRING(REGEX MATCH "mpirun=([0-9]*)" _n_cpu ${_test}) + IF("${_n_cpu}" STREQUAL "") + # 0 indicates that no mpirun should be used + SET(_n_cpu 0) + ELSE() + STRING(REGEX REPLACE "^mpirun=([0-9]*)$" "\\1" _n_cpu ${_n_cpu}) + ENDIF() IF(_test MATCHES debug) SET(_configuration DEBUG) @@ -75,7 +83,7 @@ MACRO(DEAL_II_PICKUP_TESTS) SET(_comparison ${_test}) STRING(REGEX REPLACE "\\..*" "" _test ${_test}) - DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison} ${_configuration}) + DEAL_II_ADD_TEST(${_category} ${_test} ${_comparison} ${_n_cpu} ${_configuration}) ENDIF() ENDFOREACH() -- 2.39.5