Draft: Migrate Eigen test framework from custom to Google Test (gtest)

Summary

Migrate the Eigen test framework from the custom EIGEN_DECLARE_TEST/CALL_SUBTEST_N macros to Google Test (gtest). Reorganize tests into module subdirectories, convert to TYPED_TEST suites, and optimize the smoketest list.

What changed

  • gtest migration: Replace EIGEN_DECLARE_TEST/CALL_SUBTEST_N with gtest TEST/TYPED_TEST. gtest v1.15.2 via FetchContent. main.h bridges VERIFY/VERIFY_IS_APPROX to gtest expectations.
  • Test splitting: Split 11 targets exceeding 6 GB compile RSS into smaller units with shared _helpers.h headers. Convert 58 monolithic tests to TYPED_TEST suites. Split sparse_basic into 3 parallel tests (sparse_basic, sparse_basic_cplx, sparse_basic_extra) to fix ASAN+UBSAN timeouts. Split block_basic into block_basic (fixed-size, real dynamic vectors) and block_basic_dynamic (complex/integer dynamic matrices).
  • CI fixes: Fix -Wgnu-zero-variadic-macro-arguments warnings via EIGEN_TYPED_TEST_SUITE wrapper macro (20 call sites). Fix ASAN+UBSAN OOM/timeout by splitting mixingtypes_vectorize and tuning sanitizer settings. Increase clang-14 sanitizer smoketest per-test timeout from 120s to 300s. Install libclang-rt-14-dev for the sanitizer:smoketest build. Rename the sanitizer:smoketest job from clang-12 to clang-14.
  • condition_estimator: Migrate newly added test to gtest under test/LU/.
  • Smoketest optimization: 166 → 60 tests (~64% compile-time reduction) while maintaining coverage of all major modules and full scalar-type coverage (float, double, complex, half, bfloat16, integers). Includes 6 Tensor tests for unsupported module coverage.
  • Tensor test renames: Strip obsolete cxx11_ prefix from all 103 tensor test files (89 .cpp, 12 .cu, 2 .h) in unsupported/test/Tensor/. The prefix was a historical artifact from when C++11 was optional; now that Eigen requires C++17 it is meaningless clutter. Updated CMakeLists.txt, #include directives, include guards, and comments.
  • Sanitizer OOM splits: Split 6 additional heavy smoketest TUs to prevent OOM on CI sanitizer builds (saas-linux-medium-amd64, 16 GB):
    • array_cwise_cast → + array_cwise_cast_dynamic (4.2 GB → ~2.1 GB each)
    • mixingtypes_novectorize → + mixingtypes_novectorize_dynamic (4.0 GB → ~2 GB each)
    • product_small_lazy_float → + product_small_lazy_cplxfloat (3.4 GB → ~1.7 GB each)
    • product_small_lazy_double → + product_small_lazy_cplxdouble (3.4 GB → ~1.7 GB each)
    • array_cwise_real → + array_cwise_complex (3.1 GB → ~1.5 GB each)
    • block_basic → + block_basic_dynamic (complex/integer dynamic types)
  • Sanitizer build parallelism: Limit sanitizer build to -j2 via EIGEN_CI_BUILD_JOBS variable (ASAN+UBSAN TUs use 2–4 GB RSS each; -j4 on a 16 GB runner causes OOM kills). Same -j2 cap for the aarch64 gcc-10 smoketest build for the same reason.
  • Compliance / hygiene: Add SPDX-License-Identifier to test files added on the branch. REUSE compliance for split test files and helpers. clang-format-17 cleanup of CI-flagged files.

Smoketest list (60 tests)

Curated subset covering all major Eigen modules with representative scalar types:

Category Tests
Core ops adjoint, basicstuff, block_basic, block_basic_dynamic, constructor, dense_storage, diagonal, diagonalmatrices, dynalloc, indexed_view, linearstructure, mapped_matrix, nullary, permutationmatrices, redux_matrix, ref, resize, selfadjoint, swap, triangular, vectorwiseop
Array array_cwise_operations, array_cwise_real, array_cwise_cast
Numeric types half_float, bfloat16_float, integer_types, numext, special_numbers
Mixed types mixingtypes_vectorize
Products product_small, product_small_lazy_float, product_trmm_float, product_trsolve
Arch packetmath_float, packetmath_complex
Decompositions cholesky, lu, determinant, inverse, householder, qr_colpivoting, jacobisvd_float, bdcsvd_float_dynamic, eigensolver_complex, eigensolver_selfadjoint_dynamic, schur_real
Geometry geo_transformations, geo_homogeneous, umeyama
Sparse sparse_basic, sparse_product
Special special_functions
STL stl_iterators
Tensor tensor_simple, tensor_contraction, tensor_reduction, tensor_morphing, tensor_fft, tensor_thread_pool_basic

Test directory layout

test/: Cholesky/, Core/ (Arch/, Products/), Eigenvalues/, Geometry/, GPU/, IterativeLinearSolvers/, LU/, QR/, SVD/, SparseCholesky/, SparseCore/, SparseLU/, SparseQR/, StlSupport/, Support/, ThreadPool/

Why

The old framework produces opaque numbered targets (test_foo_1, test_foo_2, …) with no indication of what each tests. gtest provides named test cases, --gtest_filter, XML/JSON output for CI, and IDE support.

Edited by Rasmus Munk Larsen

Merge request reports

Loading