Add CMake infrastructure for smoke testing

Necessary CMake changes to implement pre-merge smoke tests
running via CI.
This commit is contained in:
David Tellenbach 2021-03-31 22:09:00 +00:00
parent 5bbc9cea93
commit ae95b74af9
3 changed files with 202 additions and 0 deletions

View File

@ -0,0 +1,131 @@
# List of tests that will be build and run during Eigen's smoke testing. If one
# of these tests doesn't exists or cannot be build with the current configuration
# it will just be skipped.
set(ei_smoke_test_list
adjoint_1
alignedvector3
array_cwise_7
array_cwise_8
array_for_matrix_1
array_of_string
array_replicate_1
array_reverse_1
autodiff_1
autodiff_scalar_1
bandmatrix
bdcsvd_9
bessel_functions_1
bfloat16_float
blasutil_1
block_5
BVH
cholesky_1
cholmod_support_23
cholmod_support_24
conservative_resize_1
constructor_1
corners_1
ctorleakmiscmatrices_4
dense_storage
determinant_1
diagonal_1
diagonal_2
diagonalmatrices_1
dynalloc
eigensolver_complex_1
eigensolver_selfadjoint_8
EulerAngles_1
exceptions
fastmath
first_aligned
geo_alignedbox_2
geo_eulerangles_1
geo_homogeneous_1
geo_hyperplane_1
geo_orthomethods_1
geo_parametrizedline_1
geo_transformations_7
half_float
hessenberg_1
hessenberg_6qr_10
householder_8
indexed_view_1
inplace_decomposition_1
integer_types_1
inverse_1
is_same_dense
jacobi_1
jacobisvd_1
kronecker_product
linearstructure_1
mapped_matrix_1
mapstaticmethods_1
mapstride_1
matrix_square_root_1
meta
minres_2
miscmatrices_1
mixingtypes_7
nestbyvalue
nesting_ops_1
nomalloc_1
nullary_1
num_dimensions
NumericalDiff
numext
packetmath
permutationmatrices_1
polynomialsolver_1
prec_inverse_4x4_1
product_extra_5
product_selfadjoint_1
product_small_7
product_symm_1
product_syrk_1
product_trmm_1
product_trmv_1
product_trsolve_5
qr_1
qr_colpivoting_7
qr_fullpivoting_4
rand
real_qz_1
redux_1
ref_1
resize
rvalue_types_1
schur_complex_1
schur_real_1
selfadjoint_1
sizeof
sizeoverflow
smallvectors
sparse_basic_3
sparse_block_1
sparse_extra_4
sparse_permutations_2
sparse_product_4
sparse_ref_1
sparse_solvers_1
sparse_vector_1
special_functions_1
special_numbers_1
special_packetmath_1
spqr_support_2
stable_norm_1
stddeque_1
stddeque_overload_1
stdlist_1
stdlist_overload_1
stdvector_1
stdvector_overload_1
stl_iterators_1
swap_1
symbolic_index_1
triangular_1
type_aliaslu_9
umeyama_3
unalignedassert
unalignedcount
vectorwiseop_1
visitor_1)

View File

@ -18,6 +18,11 @@ macro(ei_add_test_internal testname testname_with_suffix)
set(filename ${testname}.cpp) set(filename ${testname}.cpp)
endif() endif()
# Add the current target to the list of subtest targets
get_property(EIGEN_SUBTESTS_LIST GLOBAL PROPERTY EIGEN_SUBTESTS_LIST)
set(EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}${targetname}\n")
set_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}")
if(EIGEN_ADD_TEST_FILENAME_EXTENSION STREQUAL cu) if(EIGEN_ADD_TEST_FILENAME_EXTENSION STREQUAL cu)
if(EIGEN_TEST_HIP) if(EIGEN_TEST_HIP)
hip_reset_flags() hip_reset_flags()
@ -413,11 +418,13 @@ macro(ei_init_testing)
define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ") define_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS BRIEF_DOCS " " FULL_DOCS " ")
define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ") define_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY BRIEF_DOCS " " FULL_DOCS " ")
define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ") define_property(GLOBAL PROPERTY EIGEN_TESTS_LIST BRIEF_DOCS " " FULL_DOCS " ")
define_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST BRIEF_DOCS " " FULL_DOCS " ")
set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "") set_property(GLOBAL PROPERTY EIGEN_TESTED_BACKENDS "")
set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "") set_property(GLOBAL PROPERTY EIGEN_MISSING_BACKENDS "")
set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "") set_property(GLOBAL PROPERTY EIGEN_TESTING_SUMMARY "")
set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "") set_property(GLOBAL PROPERTY EIGEN_TESTS_LIST "")
set_property(GLOBAL PROPERTY EIGEN_SUBTESTS_LIST "")
define_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT BRIEF_DOCS " " FULL_DOCS " ") define_property(GLOBAL PROPERTY EIGEN_FAILTEST_FAILURE_COUNT BRIEF_DOCS " " FULL_DOCS " ")
define_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT BRIEF_DOCS " " FULL_DOCS " ") define_property(GLOBAL PROPERTY EIGEN_FAILTEST_COUNT BRIEF_DOCS " " FULL_DOCS " ")
@ -708,3 +715,63 @@ macro(ei_split_testsuite num_splits)
add_dependencies("${current_target}" "${curr_test}") add_dependencies("${current_target}" "${curr_test}")
endforeach() endforeach()
endmacro(ei_split_testsuite num_splits) endmacro(ei_split_testsuite num_splits)
# Defines two custom commands buildsmoketests and smoketests that build and run
# a number of tests specified in smoke_test_list.
#
# Test in smoke_test_list can be either test targets (e.g. packetmath) or
# subtests targets (e.g. packetmath_2). If any of the test are not available
# in the current configuration they are just skipped.
#
# Smoke tests are intended to be run before the whole test suite is invoked,
# e.g., to smoke test patches.
macro(ei_add_smoke_tests smoke_test_list)
# Set the build target to build smoketests
set(buildtarget "buildsmoketests")
add_custom_target("${buildtarget}")
# We build a regex that matches our smoketests only and will pass it to ctest
set(ctest_regex "")
# Get list of all tests and translate it into a CMake list
get_property(EIGEN_TESTS_LIST GLOBAL PROPERTY EIGEN_TESTS_LIST)
string(REGEX REPLACE "\n" " " EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}")
set(EIGEN_TESTS_LIST "${EIGEN_TESTS_LIST}")
separate_arguments(EIGEN_TESTS_LIST)
# Check if the test in smoke_test_list is a currently valid test target
foreach(test IN ITEMS ${smoke_test_list})
# Add tests in smoke_test_list to our smoke test target but only if the test
# is currently available, i.e., is in EIGEN_SUBTESTS_LIST
if ("${test}" IN_LIST EIGEN_TESTS_LIST)
add_dependencies("${buildtarget}" "${test}")
# In the case of a test we match all subtests
set(ctest_regex "${ctest_regex}^${test}_[0-9]+$$|")
endif()
endforeach()
# Get list of all subtests and translate it into a CMake list
get_property(EIGEN_SUBTESTS_LIST GLOBAL PROPERTY EIGEN_SUBTESTS_LIST)
string(REGEX REPLACE "\n" " " EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}")
set(EIGEN_SUBTESTS_LIST "${EIGEN_SUBTESTS_LIST}")
separate_arguments(EIGEN_SUBTESTS_LIST)
# Check if the test in smoke_test_list is a currently valid subtest target
foreach(test IN ITEMS ${smoke_test_list})
# Add tests in smoke_test_list to our smoke test target but only if the test
# is currently available, i.e., is in EIGEN_SUBTESTS_LIST
if ("${test}" IN_LIST EIGEN_SUBTESTS_LIST)
add_dependencies("${buildtarget}" "${test}")
# In the case of a subtest we match exactly
set(ctest_regex "${ctest_regex}^${test}$$|")
endif()
endforeach()
# Remove trailing '|' in ctest regex
string(REGEX REPLACE "\\|$" "" ctest_regex "${ctest_regex}")
message(STATUS "${ctest_regex}")
# Set the test target to run smoketests
set(testtarget "smoketests")
add_custom_target("${testtarget}" COMMAND ctest -R '${ctest_regex}' --random-shuffle)
add_dependencies("${testtarget}" "${buildtarget}")
endmacro(ei_add_smoke_tests)

View File

@ -460,3 +460,7 @@ cmake_dependent_option(EIGEN_TEST_BUILD_DOCUMENTATION "Test building the doxygen
if(EIGEN_TEST_BUILD_DOCUMENTATION) if(EIGEN_TEST_BUILD_DOCUMENTATION)
add_dependencies(buildtests doc) add_dependencies(buildtests doc)
endif() endif()
# Register all smoke tests
include("EigenSmokeTestList")
ei_add_smoke_tests("${ei_smoke_test_list}")