Repository navigation
[rocshmem] Add CTest-based test infrastructure for functional and unit tests - #6334
Conversation
There was a problem hiding this comment.
Pull request overview
Adds native CTest integration for rocSHMEM’s functional and unit tests, aiming to provide a CMake/CTest-driven alternative to the existing driver.sh workflows while keeping the legacy scripts available.
Changes:
- Introduces
CTestFunctionalTests.cmaketo register the functional test matrix (including labels and per-test logging via a wrapper). - Introduces
CTestUnitTests.cmaketo register unit tests via MPI + gtest filters. - Adds helper scripts:
test_wrapper.sh(conditional skips + logging) andctest_with_retry.sh(rerun-failed behavior).
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocshmem/tests/unit_tests/CTestUnitTests.cmake | New CTest registration for MPI-based unit tests. |
| projects/rocshmem/tests/unit_tests/CMakeLists.txt | Enables optional CTest registration via ROCSHMEM_USE_CTEST. |
| projects/rocshmem/tests/functional_tests/test_wrapper.sh | New runtime wrapper for backend-based skipping and per-test logging. |
| projects/rocshmem/tests/functional_tests/CTestFunctionalTests.cmake | New CTest registration for functional tests, labels, env, and mpirun invocation. |
| projects/rocshmem/tests/functional_tests/ctest_with_retry.sh | Wrapper to retry failed CTest tests via --rerun-failed. |
| projects/rocshmem/tests/functional_tests/CMakeLists.txt | Enables optional CTest registration and installs helper scripts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
We should probably add the groupings "quick, standard, comprehensive, full" for the tests to make The Rock integration easier. Also filters for different arches, I think we currently do that in rocJenkins |
Done, added the quick, standard, comprehensive, and full category with the latest updates |
abouteiller
left a comment
There was a problem hiding this comment.
Looks good in general! Maye we also need to update the documentation though
dec2721 to
3b71248
Compare
3b71248 to
a4aca4b
Compare
|
High level workflow description, generated with the help of 'claude' Here's the high-level logical flow of the CTest-based testing system:
cmake is invoked In Functional Tests (CTestFunctionalTests.cmake): Check MPIEXEC_EXECUTABLE exists (bail if not) In Unit Tests (CTestUnitTests.cmake): Same MCA parameter detection
User runs: ctest -L quick Test Command Execution Flow: test_wrapper.sh <test_name> -n -mca pml ucx -mca osc ucx [env vars] [executable] [args]
MCA Parameters:
Backend Detection (in test_wrapper.sh):
Test Organization:
Backward Compatibility:
Configure time: Runtime: Test execution:
The flow is: Configure → Register → Filter → Execute → Report
All MCA parameters and mpirun flags are determined at CMake configure time, ensuring consistent test execution and matching the old driver.sh |
cae24e8 to
26dbaf4
Compare
|
@abouteiller I think I was able to recover what was accidentally lost, if you have a few minutes, can you please re-review? The major changes:
|
26dbaf4 to
1bb2599
Compare
convert the logic for running our tests from the driver.sh scripts to ctests
Add intelligent backend detection logic that adapts to build configuration: - If ROCSHMEM_BACKEND is explicitly set, use that value - Otherwise, auto-detect from rocshmem_info: - Single backend build: auto-detect and apply skip logic - Multi-backend build: set to "multi", let rocshmem choose, no skip logic This allows flexible testing strategies: - Explicit backend testing: ROCSHMEM_BACKEND=ipc ctest -L standard - Auto-detect in single-backend builds: ctest -L standard - Multi-backend builds: run all tests without skipping Backend-specific skip logic now only applies when backend is known (ro, ipc, or gda), not when backend is "multi" or "unknown". Verified with all three backends enabled (RO, IPC, GDA): - ROCSHMEM_BACKEND=ipc: 9/9 tests pass (B=ipc in logs) - ROCSHMEM_BACKEND=ro: 5/9 pass, 4 skipped (GET/AMO skipped for RO) - No ROCSHMEM_BACKEND: Backend detected as "multi", all tests run Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add unit_test_wrapper.sh for GPU count checking and skip logic - Configure unit test to use wrapper with SKIP_RETURN_CODE 125 - Add tier labels (quick, standard, comprehensive, full) to all_tests_n4 - Install wrapper script to build directory This integrates unit tests into the CTest tier system, allowing: ctest -L quick # Includes unit test ctest -L unit # Unit tests only ctest -L functional # Functional tests only Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add comprehensive test summary at CMake configure time showing: - Total test count across all tiers - CI tier commands (quick, standard, comprehensive, full) - Test category filters (functional, unit, RMA, AMO, etc.) - Backend-specific testing examples - Subdirectory test commands Enable testing at top level to coordinate functional and unit tests. Example output: ctest -L quick # Quick smoke test (~9 tests, ~1-2 min) ctest -L standard # Standard suite (~179 tests, ~15-20 min) ctest -L comprehensive # Comprehensive (~291 tests, ~30-40 min) ctest -L full # Full suite (all 449 tests, ~45-60 min) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Major overhaul of functional test infrastructure:
1. Multi-Dimensional Label System:
- Category labels: RMA, PUT, GET, AMO, COLLECTIVE, STREAM, SIGOPS
- Tier labels: quick, standard, comprehensive, full (hierarchical)
- Backend compatibility: backend_all, backend_ipc, backend_gda, backend_ro
- GPU architecture: gpu_all, gpu_gfx942, gpu_gfx90a, etc.
- Variant labels: variant_base, variant_uuid, variant_default_stream
2. Automatic Variant Multiplication:
- Tier-level variants (UUID): standard/comprehensive/full tiers run tests twice
* Base variant (no UUID)
* UUID variant (ROCSHMEM_TEST_UUID=1)
- Test-specific variants (default_stream): only for stream tests
* Creates 4 variants: base, UUID, stream, UUID+stream
3. Helper Functions:
- begin_test_group/end_test_group: Group-based test definition
- Variant generation and combination logic
- Tier propagation (quick ⊂ standard ⊂ comprehensive ⊂ full)
- Backend compatibility labels
4. Test Registration Improvements:
- Simplified grouped syntax for test definitions
- Environment variable propagation via mpirun -x flags
- Test wrapper integration for runtime skip logic
- SKIP_RETURN_CODE 125 for skipped tests
Test counts:
- Quick: 9 tests (8 functional + 1 unit)
- Standard: 179 tests (93 base + 85 UUID + 1 unit)
- Comprehensive: 291 tests
- Full: 449 tests
Usage examples:
ctest -L standard -L variant_uuid # UUID variants only
ctest -L RMA -L backend_ipc # RMA tests for IPC backend
ctest -L quick # Quick smoke test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wrapper script for unit tests that: - Detects available GPUs using amd-smi or rocm-smi - Skips tests if insufficient GPUs available - Returns exit code 125 (CTest skip code) - Honors HOSTFILE environment variable for multi-node Usage: unit_test_wrapper.sh <test_name> <required_ranks> mpirun ... Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Avoid confusion by using a more descriptive name. The test name now clearly indicates it's for unit tests specifically, not all tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Improve test coverage across CI tiers by promoting key tests: 1. Device bitcode tests (4 tests) → moved to quick tier - Validates device bitcode functionality early in CI - Tests various workgroup/thread configurations - Quick tier now: 13 tests (was 9) 2. Stream tests (6 test variants) → moved to standard tier - putmem_on_stream with variants (4 tests: base, uuid, default_stream, uuid+default_stream) - barrier_all_on_stream with variants (2 tests: base, uuid) - Provides stream coverage in standard CI runs - Standard tier now: 189 tests (was 179) Updated tier counts: - Quick: 13 tests (+4) - Standard: 189 tests (+10) - Comprehensive: 301 tests (+10) - Full: 445 tests (was 449, -4 from reclassification) All tests verified passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
to use the test_categories.yaml file, to be in-line with the other projects in rocm-system
Integrate new tests added after rebase including tile RMA operations and extended workgroup configurations into the YAML-based test categorization system. Changes: - Add 14 tile test types (103-116) for 2D/strided memory operations - Create add_tile_tests() function with comprehensive tier categorization - Tile tests are IPC-backend only with proper backend_ipc labels - Expand standard tier to include w1 and w8 workgroup patterns - Add teamsync, putmem_signal_on_stream to standard tier - Add w16, w32, w64 workgroup patterns to comprehensive tier - Add new flood test variants to full tier (putnbi, getnbi, p, g, waitadd) Test counts: - Quick: 10 tests (pre-commit) - Standard: 122 tests (PR validation) - Comprehensive: 434 tests (nightly, includes 30 tile tests) - Full: 478 tests (weekly) - Total functional tests: 486 (up from 444) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This allows users to run tests from the project root using: ctest --test-dir build -L quick Without enable_testing() in the main CMakeLists.txt, CTest can only be invoked from test subdirectories. This change enables the more convenient top-level invocation pattern. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Added BUILD_CTESTS option to main CMakeLists.txt (default: OFF) - Renamed ROCSHMEM_USE_CTEST to BUILD_CTESTS for consistency with other BUILD_* options (BUILD_FUNCTIONAL_TESTS, BUILD_UNIT_TESTS, etc.) - Updated all build config scripts that enable tests to also enable BUILD_CTESTS for tier-based CTest execution: - scripts/build_configs/all_backends - scripts/build_configs/gda - scripts/build_configs/ipc_single - scripts/build_configs/ipc_tests_only - scripts/build_configs/ro_ipc - scripts/build_configs/ro_net When BUILD_CTESTS=ON, tests are registered with CTest and can be run with tier-based labels: ctest --test-dir build -L quick ctest --test-dir build -L standard ctest --test-dir build -L comprehensive ctest --test-dir build -L full Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test counts were hardcoded in the summary output and would become stale as tests are added or moved between tiers. Removed the specific counts since they cannot be accurately determined at this point in the CMake configuration (tier labels are applied later in subdirectories via the YAML parser). Users can see actual test counts per tier by running: ctest --test-dir build -L <tier> -N Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
to the ctest infrastructure
Only enable CTest infrastructure when BUILD_CTESTS=ON to avoid creating the test target when CTest tests won't be registered. Changes: - Guard enable_testing() in projects/rocshmem/CMakeLists.txt - Guard enable_testing() in projects/rocshmem/tests/CMakeLists.txt Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enable tests to be executed from the installation directory without requiring access to the build directory. This is critical for monorepo CI/CD integration where tests need to run from installed packages. Key changes: - Create install-time CTestTestfile.cmake templates that use relative paths to locate test executables and wrapper scripts - Generate install-time test definitions during CMake configuration with proper path resolution for installed layout - Install test categorization infrastructure (test_categories.yaml, TestCategories.cmake) to support future tier label functionality - Use legacy add_test() syntax for compatibility with CTest Tests can now be run from <install>/share/rocshmem with: ctest # Run all tests ctest -L functional # Run functional tests only ctest -L unit # Run unit tests only Tier-based filtering (quick/standard/comprehensive/full) remains available from the build directory due to CTest runtime limitations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Reduce configure-time noise by removing redundant usage messages. Users can find test filtering options via --help or documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Enables monorepo CI to use tier labels (quick/standard/comprehensive/full) when running tests from the ROCshmem installation directory, required for integrated CI/CD workflows. The shared infrastructure's apply_ctest_category_labels() generates CMake-time commands that don't work at CTest runtime. This adds ApplyInstallTierLabels.cmake which generates CTest-compatible set_tests_properties() calls instead. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update the installation destination for all CTestTestfile.cmake files from share/rocshmem to bin/rocshmem, following monorepo integration conventions. Changes: - Install root CTestTestfile.cmake to bin/rocshmem/ - Install functional tests to bin/rocshmem/tests/functional/ - Install unit tests to bin/rocshmem/tests/unit/ - Update all relative paths in templates and test generation functions to account for new working directory location - Update documentation comments to reflect new usage location The test executables remain in bin/ and wrapper scripts remain in share/rocshmem/, with relative paths updated accordingly. Usage: cd <install>/bin/rocshmem && ctest -L quick Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Relocate rocshmem_functional_tests and rocshmem_unit_tests from bin/
to libexec/rocshmem/, following monorepo conventions where test
executables are installed to CMAKE_INSTALL_LIBEXECDIR.
Changes:
- Install rocshmem_functional_tests to libexec/rocshmem/
- Install rocshmem_unit_tests to libexec/rocshmem/
- Update all relative paths in test generation functions to reference
../../../../libexec/rocshmem/ from bin/rocshmem/tests/{functional,unit}/
- Use standard install() command instead of rocm_install() for proper
RUNTIME DESTINATION handling
CTestTestfile.cmake files remain in bin/rocshmem/ as configured.
Test wrapper scripts remain in share/rocshmem/.
Usage remains: cd <install>/bin/rocshmem && ctest -L quick
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Relocate rocshmem_functional_tests and rocshmem_unit_tests from libexec/rocshmem/ to share/rocshmem/, consolidating all test-related files in the share directory. Changes: - Install rocshmem_functional_tests to share/rocshmem/ - Install rocshmem_unit_tests to share/rocshmem/ - Update all relative paths in test generation functions and templates to reference ../../../../share/rocshmem/ for both executables and wrapper scripts This simplifies the installation layout by keeping all test infrastructure (executables, wrappers, and scripts) in a single directory while CTest configuration files remain in bin/rocshmem/ for monorepo integration. Usage remains: cd <install>/bin/rocshmem && ctest -L quick Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update the install-time CTestTestfile.cmake to only include subdirectories for test types that are actually built, preventing errors when running CTest from the installation directory with partial test builds. Changes: - Conditionally generate subdirs() calls based on BUILD_FUNCTIONAL_TESTS and BUILD_UNIT_TESTS CMake options - If functional tests are disabled, the functional subdirectory won't be included in the install-time CTest configuration - If unit tests are disabled, the unit subdirectory won't be included This allows tier labels (quick, standard, comprehensive, full) to work correctly even when only a subset of test types are built. For example, if only functional tests are built, running "ctest -L quick" from bin/rocshmem will execute only the functional tests in the quick tier. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handle the scenario where we only have a sparse checkout. Do not abort in that case if some higher-level scripts are missing. ctest in that case will build our functional tests correctly, but theRock categories might not be available
046ab05 to
819f5d8
Compare
## Summary TheRock side of test-filter standardization for **rocSHMEM**, paired with [ROCm/rocm-systems#6334](ROCm/rocm-systems#6334). rocm-systems#6334 adds native CTest integration for rocSHMEM: `projects/rocshmem/tests/test_categories.yaml` plus `apply_ctest_category_labels()` wiring that installs relocatable `bin/rocshmem/**/CTestTestfile.cmake` files (a root dispatcher that `subdirs()` into `tests/functional` and `tests/unit`) carrying the `quick`/`standard`/`comprehensive`/`full` tier labels. This PR wires TheRock so the generic `test_runner.py` can drive those tests from the installed artifact: - **`comm-libs/CMakeLists.txt`** — pass `-DBUILD_CTESTS=${THEROCK_BUILD_TESTING}` to the rocshmem subproject. The CTest registration and the install-tree `CTestTestfile.cmake` generation in #6334 are gated behind `BUILD_CTESTS` (default `OFF`), so without this the install tree would contain no `bin/rocshmem/**` and `test_runner.py` would fail with `Test directory does not exist`. - **`comm-libs/artifact-rocshmem.toml`** — populate the previously-empty `test` component: `bin/rocshmem/**` (the install-tree CTest files), `bin/rocshmem_unit_tests`, the `share/rocshmem/*` CTest wrapper scripts, and the `device_bitcode` HSACOs. The functional binary and `rocshmem_info` already live in the `run` component (fetched via `rocshmem_run`). - **`build_tools/install_rocm_from_artifacts.py`** — add a `--rocshmem` artifact selector that pulls `rocshmem_lib`/`_run`/`_test` plus OpenMPI (`mpirun` + libs) needed to launch the tests. - **`build_tools/github_actions/fetch_test_configurations.py`** — add a `rocshmem` test job using `test_runner.py` (`fetch_artifact_args = "--rocshmem --tests"`), on Linux multi-GPU runners (the functional/unit tests launch via `mpirun` with `RANKS` 2..64, same setup as `rccl`). - **`fetch_test_configurations_test.py`** — relax the assertion that assumed exactly one multi-GPU job repo-wide, now that rocshmem is a second multi-GPU job alongside rccl. `test_runner.py` needs no `COMPONENT_DIR_MAPPING` entry (job name `rocshmem` == install dir `bin/rocshmem`). ## Test plan - [x] `python3 -m pytest build_tools/github_actions/tests/fetch_test_configurations_test.py` (22 passed) - [x] `black --check` on the edited Python files - [x] `--rocshmem` registered in `install_rocm_from_artifacts.py --help` - [x] `artifact-rocshmem.toml` parses; test `include` resolves - [x] CI: build with `THEROCK_BUILD_TESTING=ON`, confirm `bin/rocshmem/CTestTestfile.cmake` + `tests/{functional,unit}/CTestTestfile.cmake` are installed and bundled in the test artifact - [x] CI: `TEST_COMPONENT=rocshmem TEST_TYPE=quick python test_runner.py` discovers labels and runs `ctest -L quick` from `THEROCK_BIN_DIR/rocshmem` ## Test Results Test Run: https://github.com/ROCm/TheRock/actions/runs/30112055659/job/89560360151?pr=5691 Made with [Cursor](https://cursor.com) --------- Co-authored-by: Cursor <cursoragent@cursor.com>
Motivation
This commit adds native CTest integration for rocshmem functional and unit
tests, providing an alternative to the shell-based driver.sh scripts while
maintaining backward compatibility.
Changes
Compilation Flags
To enable CTest-based tests during build:
cmake -DGPU_TARGETS=gfx950 \ -DROCSHMEM_USE_CTEST=ON \ -DBUILD_FUNCTIONAL_TESTS=ON \ -DBUILD_UNIT_TESTS=ON \ .. cmake --build . -j8Running Functional Tests
Running Unit Tests
Log Files
Test logs are created in:
build_all_backends/tests/functional_tests/test_logs/-Vto see details)Log file naming:
<test_name>_n<ranks>_w<workgroups>_z<threads>_<size>B.logExample:
Custom log directory:
Running theRock CI categories
The generation of the theRock CI categories requires an additional entry when doing a sparse checkout. Please execute
in addition to setting the cone to point to the project/rocshmem directly.
cd build ctest --test-dir=./tests -L quick ctest --test-dir=./tests -L standard ctest --test-dir=./tests -L comprehensive ctest --test-dir=./tests -L fullBackward Compatibility
The original driver.sh scripts remain available:
rocshmem_functional_driver.sh <executable> <suite> <log_dir> [hostfile]rocshmem_unit_driver.sh <binary> allCo-Authored-By: Claude Opus 4.6 noreply@anthropic.com
JIRA ID
AIROCSHMEM- 399
Submission Checklist