Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable examples/ tests in quick tests #15653

Closed
wants to merge 10 commits into from
8 changes: 4 additions & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ jobs:
# simple serial release build using g++

name: linux release serial
runs-on: [ubuntu-20.04]
runs-on: [ubuntu-22.04]

# only run on 'push' or if the 'pull_request' is not a draft:
if: ${{ github.event_name == 'push' || !github.event.pull_request.draft }}

container:
image: dealii/dependencies:jammy

steps:
- uses: actions/checkout@v3
- name: setup
Expand All @@ -34,9 +37,6 @@ jobs:
run: |
g++ -v
cmake --version
- name: modules
run: |
sudo apt-get install g++-10
- name: Build Boost
id: boost
uses: egor-tensin/build-boost@v1
Expand Down
21 changes: 16 additions & 5 deletions cmake/macros/macro_deal_ii_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ function(deal_ii_add_test _category _test_name _comparison_file)
return()
endif()

#
# Determine whether the .run_only keyword is present.
#
# In case no numdiff executable was found we fall back to simply running
# the tests as well (but not comparing them).
#
set(_run_only FALSE)
if(_file MATCHES "\\.run_only$" OR "${NUMDIFF_EXECUTABLE}" STREQUAL "")
set(_run_only TRUE)
endif()

#
# Determine the expected build stage of this test:
#
Expand All @@ -222,11 +233,11 @@ function(deal_ii_add_test _category _test_name _comparison_file)
endif()

#
# Determine whether the .run_only keyword is present:
# If _run_only is set then we don't compare test results. Therefore,
# we won't fail in the "DIFF" stage of a test.
#
set(_run_only FALSE)
if(_file MATCHES "\\.run_only$")
set(_run_only TRUE)
if(_run_only AND "${_expect}" STREQUAL "DIFF")
set(_expect "PASSED")
endif()

#
Expand Down Expand Up @@ -393,7 +404,7 @@ function(deal_ii_add_test _category _test_name _comparison_file)
# "mpirun_0-threads_0".
#

set(_test_target ${_category}.${_test_name}) # diff target name
set(_test_target ${_category}.${_test_name}) # diff/run target name
set(_test_full ${_category}/${_test_name}) # full test name
set(_test_directory ${CMAKE_CURRENT_BINARY_DIR}/${_test_name}.${_build_lowercase}) # directory to run the test in

Expand Down
8 changes: 1 addition & 7 deletions cmake/macros/macro_deal_ii_pickup_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,7 @@ macro(deal_ii_pickup_tests)

set(DEAL_II_SOURCE_DIR) # avoid a bogus warning

# Only run "*.output" comparison tests if we have numdiff:
set(_globs "*.output" "*.run_only")
if("${NUMDIFF_EXECUTABLE}" STREQUAL "")
set(_globs "*.run_only")
endif()

file(GLOB _tests ${_globs})
file(GLOB _tests "*.output" "*.run_only")
foreach(_test ${_tests})
set(_comparison ${_test})
get_filename_component(_test ${_test} NAME)
Expand Down
27 changes: 13 additions & 14 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,25 +164,25 @@ foreach(_category ${_categories})
)
endforeach()

#
# Define a top-level "test" target that runs our quick tests wrapper.
#

if(DEFINED DEAL_II_HAVE_TESTS_DIRECTORY)
add_custom_target(test
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/run_quick_tests.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Running quicktests..."
USES_TERMINAL
)
add_dependencies(test setup_tests_examples)
add_dependencies(test setup_tests_quick_tests)

if(DEFINED DEAL_II_HAVE_TESTS_DIRECTORY)
#
# Define a top-level "test" target that runs our quick tests wrapper.
#

# Use the first available build type (this prefers debug mode if available):
list(GET DEAL_II_BUILD_TYPES 0 _my_build)
add_custom_target(test
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${_my_build} -P ${CMAKE_CURRENT_SOURCE_DIR}/run_quick_tests.cmake
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Running quicktests..."
)

# Depend on the library targets (to ensure that deal.II is actually
# compiled), as well as on the setup_tests_quick_tests target to ensure
# that quick tests are actually available.
add_dependencies(test setup_tests_quick_tests)
#
foreach(_build ${DEAL_II_BUILD_TYPES})
string(TOLOWER ${_build} _build_lowercase)
add_dependencies(test ${DEAL_II_TARGET_NAME}_${_build_lowercase})
Expand All @@ -191,7 +191,6 @@ if(DEFINED DEAL_II_HAVE_TESTS_DIRECTORY)
#
# Add a dummy target to make files known to IDEs like qtcreator
#

file(GLOB _misc
${CMAKE_CURRENT_SOURCE_DIR}/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/*.h
Expand Down
75 changes: 43 additions & 32 deletions tests/run_quick_tests.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,64 +37,75 @@ endif()
message(STATUS "Running quick_tests in ${CMAKE_BUILD_TYPE} mode with -j${_n_processors}:")

#
# Always restrict quick tests with specified build type, but run the step
# and affinity quick tests in all available configuration:
# Redirect quick tests to an output.log for CMake versions 3.18 onwards
# (when we can actually instruct CMake to also print to the standard
# terminal).
#

set(_redirect_output "")
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
set(_redirect_output
OUTPUT_VARIABLE _output ECHO_OUTPUT_VARIABLE
ERROR_VARIABLE _output ECHO_ERROR_VARIABLE
)
endif()

string(TOLOWER "${CMAKE_BUILD_TYPE}" _build_type)
execute_process(COMMAND ${CMAKE_CTEST_COMMAND}
-j${_n_processors} -C ${CMAKE_BUILD_TYPE} --force-new-ctest-process
-R "quick_tests/(step.debug|step.release|affinity|.*.${_build_type})"
OUTPUT_VARIABLE _output ERROR_VARIABLE _output RESULT_VARIABLE _return_value
-R "(quick_tests|examples)/"
--output-on-failure
${_redirect_output}
RESULT_VARIABLE _return_value
)
file(WRITE quick_tests.log ${_output})
message(${_output})

if(NOT "${_return_value}" STREQUAL "0")
if("${_return_value}" STREQUAL "0")
message("
**************************************************************************

🎉 🎉 🎉 All quick tests passed. 🎉 🎉 🎉

**************************************************************************"
)
else()
message("
**************************************************************************
** **
** Error: Some of the quick tests failed. **
** **
**************************************************************************

Check the files quick_tests.log and Testing/Temporary/LastTest.log located
in your build directory for error messages. Alternatively, you can run all
failing quick tests again via
Check the terminal output above. You can run all failing quick tests again
via $ ctest --rerun-failed --output-on-failure -R quick_tests/

$ ctest --rerun-failed --output-on-failure -R quick_tests/
If you need help with this problem, open a bug report on the issue tracker

If you are unable to fix this problem, write to the mailing list linked at
https://www.dealii.org\n"
https://github.com/dealii/dealii/issues/new

or write to the mailing list linked at https://www.dealii.org/mail.html
Please also add the files quick_tests.log , Testing/Temporary/LastTest.log
to your bug report."
)

set(_affinity_issue FALSE)
string(REPLACE "\n" ";" _output "${_output}")
foreach(_line ${_output})
if ("${_line}" MATCHES "affinity.*FAILED")
message("
if ("${_line}" MATCHES " Test .*quick_tests/affinity.*Failed.*sec")
set(_affinity_issue TRUE)
endif()
endforeach()
if(_affinity_issue)
message("
The affinity test can fail when you are linking in a library like BLAS
which uses OpenMP. Even without calling any BLAS functions, OpenMP messes
with the thread affinity which causes TBB to run single-threaded only. You
can fix this by exporting OMP_NUM_THREADS=1. Also see GOMP_CPU_AFFINITY
and OMP_PROC_BIND.\n"
)
endif()
and OMP_PROC_BIND."
)
endif()

if (${_line} MATCHES "step-petsc.*FAILED")
message("
Additional information about PETSc issues is available
at:\nhttp://www.dealii.org/developer/external-libs/petsc.html\n"
)
endif()

if (${test} MATCHES "p4est.*FAILED" AND NOT EXISTS ${test}-OK)
message("
The p4est test can fail if you are running an OpenMPI version before 1.5.
This is a known problem and the only work around is to update to a more
recent version or use a different MPI library like MPICH.\n"
)
endif()
endforeach()
message("\n")

# ensure that this script exits with a non-zero exit code
message(FATAL_ERROR "quick tests failed")
Expand Down