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

Tests: convert quick tests into regular tests #14558

Merged
merged 7 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Jenkinsfile export-ignore
/tests/* export-ignore
/tests/CMakeLists.txt -export-ignore
/tests/quick_tests -export-ignore
/tests/run_test.cmake -export-ignore
/tests/run_*.cmake -export-ignore
/tests/tests.h -export-ignore

#
Expand Down
12 changes: 8 additions & 4 deletions doc/news/changes/minor/20221129Maier
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Improved: The quick_tests mechanism has been redesigned. The tests are now
called <code>quick_tests/[tests].[build]</code> and can be invoked via
ctest as well.
Improved: The quick_tests mechanism has been redesigned. Quick tests are
now part of the regular deal.II testsuite. This means they can be
configured via the <code>setup_tests_quick_tests</code> target, and run via
invoking ctest from the build directory. The <code>test</code> target will
now ensure that the library is fully compiled and quick tests are
configured prior to running all quick tests.

<br>
(Matthias Maier, 2022/11/29)
(Matthias Maier, 2022/11/29, 2022/12/10)

94 changes: 45 additions & 49 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# We define toplevel targets:
# setup_tests - set up testsuite subprojects
# prune_tests - remove all testsuite subprojects
# test - run all quick_tests
#

cmake_minimum_required(VERSION 3.3.0)
Expand All @@ -33,71 +34,46 @@ set_if_empty(MAKEOPTS $ENV{MAKEOPTS})
set_if_empty(DEAL_II_DIR $ENV{DEAL_II_DIR})

#
# A bit of necessary setup if tests are configured as a stand-alone
# project:
# Setup for the case that tests are configured as a stand-alone project:
#

if(NOT DEFINED DEAL_II_HAVE_TESTS_DIRECTORY)
message(STATUS "This is CMake ${CMAKE_VERSION}")
message(STATUS "")

if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "The testsuite cannot be configured in-source. "
"Please create a separate build directory!"
)
endif()

find_package(deal.II 9.3.0 REQUIRED HINTS ${DEAL_II_DIR})
deal_ii_initialize_cached_variables()
project(TESTSUITE CXX)
set(_options "-DDEAL_II_DIR=${DEAL_II_PATH}")

file(WRITE ${CMAKE_BINARY_DIR}/detailed.log
"# CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} on platform ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_PROCESSOR}"
)
endif()

#
# A bit of necessary setup if tests are included via ADD_SUBDIRECTORY from
# the top-level CMake project:
# Setup for the case that tests are included via ADD_SUBDIRECTORY from the
# top-level CMake project:
#

if(DEFINED DEAL_II_HAVE_TESTS_DIRECTORY)

#
# We have to repeat the policy statement here because the new
# CMAKE_MINIMUM_REQUIRED call resets our previous policy set in the main
# CMakeLists.txt file.
#
if("${CMAKE_VERSION}" VERSION_LESS "3.11" AND POLICY CMP0037)
# allow to override "test" target for quick tests
cmake_policy(SET CMP0037 OLD)
endif()

#
# If this CMakeLists.txt file is called from within the deal.II build
# system, set up quick tests as well:
#
add_subdirectory(quick_tests)

message(STATUS "Setting up testsuite")

#
# Write minimalistic CTestTestfile.cmake files to CMAKE_BINARY_DIR and
# CMAKE_BINARY_DIR/tests:
# Write minimalistic CTestTestfile.cmake files to CMAKE_BINARY_DIR:
#
file(WRITE ${CMAKE_BINARY_DIR}/CTestTestfile.cmake "subdirs(tests)\n")

set(_options "-DDEAL_II_DIR=${CMAKE_BINARY_DIR}")

else()

message(STATUS "This is CMake ${CMAKE_VERSION}")
message(STATUS "")

if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "The testsuite cannot be configured in-source. "
"Please create a separate build directory!"
)
endif()

find_package(deal.II 9.3.0 REQUIRED HINTS ${DEAL_II_DIR} $ENV{DEAL_II_DIR})
project(testsuite NONE)
set(_options "-DDEAL_II_DIR=${DEAL_II_PATH}")
endif()

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfile.cmake
"subdirs(quick_tests)\n"
)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/CTestTestfile.cmake "")

#
# Always undefine the following variables in the setup_tests target:
Expand All @@ -115,15 +91,14 @@ endforeach()

#
# Find all testsuite subprojects, i.e., every directory that contains a
# CMakeLists.txt file (with the exception of "quick_tests").
# CMakeLists.txt file.
#
set(_categories)
file(GLOB _dirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/*
)
foreach(_dir ${_dirs})
if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt AND
NOT ${_dir} MATCHES quick_tests)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_dir}/CMakeLists.txt)
list(APPEND _categories ${_dir})
endif()
endforeach()
Expand Down Expand Up @@ -175,6 +150,30 @@ endforeach()


if(DEFINED DEAL_II_HAVE_TESTS_DIRECTORY)

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

if("${CMAKE_VERSION}" VERSION_LESS "3.11" AND POLICY CMP0037)
# allow to override "test" target for quick tests
cmake_policy(SET CMP0037 OLD)
endif()

# 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 target 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 library)
add_dependencies(test setup_tests_quick_tests)

#
# Add a dummy target to make files known to IDEs like qtcreator
#
Expand All @@ -184,11 +183,8 @@ if(DEFINED DEAL_II_HAVE_TESTS_DIRECTORY)
${CMAKE_CURRENT_SOURCE_DIR}/*.h
${CMAKE_CURRENT_SOURCE_DIR}/*/*.cc
${CMAKE_CURRENT_SOURCE_DIR}/*/*.h
)

add_custom_target(dummy_tests_files
SOURCES ${_misc}
)
)
add_custom_target(testsuite SOURCES ${_misc})

message(STATUS "Setting up testsuite - Done")
endif()
215 changes: 4 additions & 211 deletions tests/quick_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,211 +1,4 @@
## ---------------------------------------------------------------------
##
## Copyright (C) 2013 - 2021 by the deal.II authors
##
## This file is part of the deal.II library.
##
## The deal.II library is free software; you can use it, redistribute
## it, and/or modify it under the terms of the GNU Lesser General
## Public License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
## The full text of the license can be found in the file LICENSE.md at
## the top level directory of deal.II.
##
## ---------------------------------------------------------------------

#
# A minimalistic set of tests:
#
enable_testing()

include_directories(
${CMAKE_BINARY_DIR}/include/
${CMAKE_SOURCE_DIR}/include/
${DEAL_II_BUNDLED_INCLUDE_DIRS}
${DEAL_II_INCLUDE_DIRS}
)

# Use the first available build type (this prefers debug mode if available):
list(GET DEAL_II_BUILD_TYPES 0 _mybuild)
message(STATUS "Setting up quick_tests in ${_mybuild} mode")

set(ALL_TESTS) # clean variable

# define a macro to set up a quick test:
macro(make_quicktest test_basename build_name mpi_run)
string(TOLOWER ${build_name} _build_lowercase)
set(_test "quick_tests/${test_basename}.${_build_lowercase}")
set(_target "quick_tests_${test_basename}_${_build_lowercase}")

list(APPEND ALL_TESTS "${_test}")
add_executable(${_target} EXCLUDE_FROM_ALL ${test_basename}.cc)
insource_setup_target(${_target} ${build_name})

if("${mpi_run}" STREQUAL "")
set(_command ${_target})
else()
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(_command ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${mpi_run} ${MPIEXEC_PREFLAGS} ${_target})
else()
set(_command ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${mpi_run} ${MPIEXEC_PREFLAGS} ./${_target})
endif()
endif()
add_custom_target(${_target}_run
DEPENDS ${_target}
COMMAND
${_command} > ${_target}-OK 2>&1
||(echo "${_target}: RUN failed. Output:"
&& cat ${_target}-OK
&& rm ${_target}-OK
&& exit 1)
COMMAND echo "${_test}: PASSED."
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

# this is a hack to make sure the -OK file is deleted even if compilation
# fails.
add_custom_target(reset_${_target}
COMMAND ${CMAKE_COMMAND} -E remove -f ${_target}-OK
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
add_dependencies(${_target} reset_${_target})

add_test(NAME ${_test}
COMMAND ${CMAKE_COMMAND} -DTRGT=${_target}_run -DTEST=${_test}
-DBINARY_DIR=${CMAKE_BINARY_DIR}
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/run_test.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
set_tests_properties(${_test} PROPERTIES
LABEL "sanity checks"
ENVIRONMENT "OMPI_MCA_rmaps_base_oversubscribe=1")
# ^^^ Allow oversubscription for MPI (needed for Openmpi@3.0)
endmacro()


# Simple assembly/solver test. This makes sure we can compile and link correctly
# in debug and release.
foreach(_build ${DEAL_II_BUILD_TYPES})
make_quicktest("step" ${_build} "")
endforeach()

# Test whether thread affinity is well behaved
make_quicktest("affinity" ${_mybuild} "")

# Test if MPI is configured correctly
if (DEAL_II_WITH_MPI)
make_quicktest("mpi" ${_mybuild} 2)
endif()

# Test if TBB works correctly
if (DEAL_II_WITH_TBB)
make_quicktest("tbb" ${_mybuild} "")
endif()

# test taskflow
if (DEAL_II_WITH_TASKFLOW)
make_quicktest("taskflow" ${_mybuild} "")
endif()

# Test p4est. This test exposes a bug in OpenMPI 1.3 and 1.4
# Update to OpenMPI 1.5 or newer.
if (DEAL_II_WITH_P4EST)
make_quicktest("p4est" ${_mybuild} 10)
endif()

# Test petsc
if (DEAL_II_WITH_PETSC)
make_quicktest("step-petsc" ${_mybuild} "")
endif()

# Test slepc
if (DEAL_II_WITH_PETSC AND DEAL_II_WITH_SLEPC)
make_quicktest("step-slepc" ${_mybuild} "")
endif()

# Test trilinos
if (DEAL_II_WITH_TRILINOS)
make_quicktest("step-trilinos" ${_mybuild} "")
endif()

# Test metis
if (DEAL_II_WITH_METIS AND DEAL_II_WITH_MPI)
make_quicktest("step-metis" ${_mybuild} 2)
endif()

# Test LAPACK
if (DEAL_II_WITH_LAPACK)
make_quicktest("lapack" ${_mybuild} "")
endif()

# Test Umfpack
if (DEAL_II_WITH_UMFPACK)
make_quicktest("umfpack" ${_mybuild} "")
endif()

# Test GSL
if (DEAL_II_WITH_GSL)
make_quicktest("gsl" ${_mybuild} "")
endif()

# Test HDF5
if (DEAL_II_WITH_HDF5)
make_quicktest("hdf5" ${_mybuild} "")
endif()

# Test Arpack
if (DEAL_II_WITH_ARPACK AND DEAL_II_WITH_UMFPACK)
make_quicktest("arpack" ${_mybuild} "")
endif()

# Test Adol-C
if (DEAL_II_WITH_ADOLC)
make_quicktest("adolc" ${_mybuild} "")
endif()

# Test SUNDIALS
if (DEAL_II_WITH_SUNDIALS)
make_quicktest("sundials-ida" ${_mybuild} "")
endif()

# Test Assimp
if (DEAL_II_WITH_ASSIMP)
make_quicktest("assimp" ${_mybuild} "")
endif()

# Test CUDA
if (DEAL_II_WITH_CUDA)
make_quicktest("cuda" ${_mybuild} "")
endif()

# Test ScaLAPACK
if (DEAL_II_WITH_SCALAPACK)
make_quicktest("scalapack" ${_mybuild} 5)
endif()

# Test Zlib and Boost
if (DEAL_II_WITH_ZLIB)
make_quicktest("boost_zlib" ${_mybuild} "")
endif()

# Test GMSH
if (DEAL_II_WITH_GMSH)
make_quicktest("gmsh" ${_mybuild} "")
endif()

# Test SymEngine
if (DEAL_II_WITH_SYMENGINE)
make_quicktest("symengine" ${_mybuild} "")
endif()

# Test Kokkos
make_quicktest("kokkos" ${_mybuild} "")

# A custom test target:
add_custom_target(test
COMMAND ${CMAKE_COMMAND} -D ALL_TESTS="${ALL_TESTS}" -DCMAKE_BUILD_TYPE=${_mybuild} -P ${CMAKE_CURRENT_SOURCE_DIR}/run.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running quicktests..."
)

message(STATUS "Setting up quick_tests in ${_mybuild} mode - Done")
cmake_minimum_required(VERSION 3.3.0)
include(../setup_testsubproject.cmake)
project(testsuite CXX)
deal_ii_pickup_tests()
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.