Skip to content

[WIP]Feat(tests): build test infrastructure#144

Open
chen2021673 wants to merge 4 commits intomasterfrom
CTest-clean
Open

[WIP]Feat(tests): build test infrastructure#144
chen2021673 wants to merge 4 commits intomasterfrom
CTest-clean

Conversation

@chen2021673
Copy link
Copy Markdown
Contributor

@chen2021673 chen2021673 commented Apr 14, 2026

Summary

Build a complete, maintainable test infrastructure for InfiniTrain with device-parametrized tests, unified CMake macros, and consistent CUDA/CPU/Distributed coverage.

Closes #120

What changed

1. Test infrastructure foundation (tests/common/)

  • tests/common/test_utils.h: parametrized base classes — InfiniTrainTestP, TensorTestBaseP, AutogradTestBaseP, DistributedInfiniTrainTestP
  • SetUp() auto-skips CUDA tests when no GPU is available
  • GetDevice() replaces hardcoded Device::kCPU throughout all tests

2. CMake macros (tests/common/test_macros.cmake)

  • infini_train_add_test_suite(<name> SOURCES ...) — replaces 3 × infini_train_add_test per test suite
  • INFINI_TRAIN_REGISTER_TEST(TestName) — CPU + CUDA registration (was 4 lines per suite)
  • INFINI_TRAIN_REGISTER_TEST_CPU(TestName) — CPU only
  • INFINI_TRAIN_REGISTER_TEST_DISTRIBUTED(TestName) — Distributed (CUDA + NCCL)

luoyueyuguang and others added 4 commits April 13, 2026 14:33
- Add infini_train_add_test CMake macro for simplified test registration
- Integrate gtest_discover_tests for automatic test case discovery
- Refactor all test directories to use unified macro (autograd, optimizer, hook, slow, lora)
- Reduce test CMakeLists.txt code by 68%
- Add LoRA tests (12 test cases)
- Delete TEST_REPORT.md
- Test labels: cpu/cuda/distributed/slow for flexible test execution
- Add shared test_macros.cmake in tests/common/

BREAKING CHANGE: Test registration now uses macro instead of manual add_test()

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Replace TEST_F with TEST_P across all test suites so each suite runs on
both CPU and CUDA without duplicating test logic. Adds InfiniTrainTestP,
TensorTestBaseP, AutogradTestBaseP, and DistributedInfiniTrainTestP base
classes with automatic CUDA/NCCL skip guards. Introduces
INFINI_TRAIN_REGISTER_TEST* C++ macros and infini_train_add_test_suite
CMake macro to eliminate repetitive INSTANTIATE_TEST_SUITE_P /
infini_train_add_test boilerplate. Removes deprecated test/, slow/, and
split optimizer test files; consolidates optimizer tests into a single
binary with creation  + step suites.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants