Skip to content

[rocshmem] Add CTest-based test infrastructure for functional and unit tests - #6334

Merged
edgargabriel merged 25 commits into
developfrom
rocshmem/ctests-conversion
Jun 8, 2026
Merged

edgargabriel merged 25 commits into
developfrom
rocshmem/ctests-conversion

Conversation

@edgargabriel

@edgargabriel edgargabriel commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

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

  • Added CTestFunctionalTests.cmake with functional tests
  • Added CTestUnitTests.cmake with unit test configuration
  • Created test_wrapper.sh for runtime backend detection and conditional skipping
  • Created ctest_with_retry.sh for automatic retry of failed tests (matches driver.sh)
  • Updated CMakeLists.txt in tests/functional_tests and tests/unit_tests
  • Tests organized with labels: RMA, AMO, COLLECTIVE, SIGOPS, STREAM, HEATMAP, etc.
  • Individual log files created per test (matching driver.sh behavior)

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 . -j8

Running Functional Tests

cd build_all_backends/tests/functional_tests

# Run all functional tests
ctest -L functional

# Run with automatic retry (matches driver.sh behavior)
./ctest_with_retry.sh -L functional

# Run specific test suite
ctest -L RMA          # RMA tests
ctest -L AMO          # Atomic operations
ctest -L COLLECTIVE   # Collective operations
ctest -L HEATMAP      # Performance tests

# Run for specific backend (auto-skips incompatible tests)
ROCSHMEM_BACKEND=ipc ctest -L functional
ROCSHMEM_BACKEND=ro ctest -L functional
ROCSHMEM_BACKEND=gda ctest -L functional

# Run specific test
ctest -R put_n2_w1_z1_1048576B -V

Running Unit Tests

cd build_all_backends/tests/unit_tests

# Run all unit tests
ctest

# Run with verbose output
ctest -V

# Run with labels
ctest -L unit
ctest -L IPC
ctest -L SDMA

Log Files

Test logs are created in:

  • Functional tests: build_all_backends/tests/functional_tests/test_logs/
  • Unit tests: CTest captures output (use -V to see details)

Log file naming: <test_name>_n<ranks>_w<workgroups>_z<threads>_<size>B.log

Example:

test_logs/
├── put_n2_w1_z1_1048576B.log
├── get_n2_w1_z1_1048576B.log
├── amo_add_n2_w1_z1.log
└── init_n2_w1_z1.log

Custom log directory:

ROCSHMEM_TEST_LOG_DIR=/path/to/logs ctest -L functional

Running theRock CI categories

The generation of the theRock CI categories requires an additional entry when doing a sparse checkout. Please execute

git sparse-checkout add shared/ctest

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 full

Backward Compatibility

The original driver.sh scripts remain available:

  • rocshmem_functional_driver.sh <executable> <suite> <log_dir> [hostfile]
  • rocshmem_unit_driver.sh <binary> all

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

JIRA ID

AIROCSHMEM- 399

Submission Checklist

Copilot AI review requested due to automatic review settings May 20, 2026 20:23
@edgargabriel
edgargabriel requested a review from a team as a code owner May 20, 2026 20:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.cmake to register the functional test matrix (including labels and per-test logging via a wrapper).
  • Introduces CTestUnitTests.cmake to register unit tests via MPI + gtest filters.
  • Adds helper scripts: test_wrapper.sh (conditional skips + logging) and ctest_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.

@Yiltan

Yiltan commented May 21, 2026

Copy link
Copy Markdown
Contributor

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

https://github.com/ROCm/TheRock/blob/608407f8409b0e33b54361226ab09673927e0f0a/docs/development/test_filtering.md

@edgargabriel

Copy link
Copy Markdown
Contributor Author

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

https://github.com/ROCm/TheRock/blob/608407f8409b0e33b54361226ab09673927e0f0a/docs/development/test_filtering.md

Done, added the quick, standard, comprehensive, and full category with the latest updates

@abouteiller abouteiller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good in general! Maye we also need to update the documentation though

@edgargabriel
edgargabriel force-pushed the rocshmem/ctests-conversion branch 2 times, most recently from dec2721 to 3b71248 Compare May 28, 2026 21:56
Comment thread projects/rocshmem/CMakeLists.txt Resolved
@dileepr1
dileepr1 requested a review from nunnikri June 1, 2026 16:27
@edgargabriel
edgargabriel force-pushed the rocshmem/ctests-conversion branch from 3b71248 to a4aca4b Compare June 1, 2026 17:53
@edgargabriel

edgargabriel commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor Author

High level workflow description, generated with the help of 'claude'

Here's the high-level logical flow of the CTest-based testing system:

  1. CMake Configuration Time (when you run cmake)

cmake is invoked
↓
MaindCMakeLists.txt processes configuration options
↓
find_package(MPI) → populates MPIEXEC_EXECUTABLE, MPIEXEC_NUMPROC_FLAG
↓
ROCSHMEM_USE_CTEST=ON by default
↓
tests/CMakeLists.txt is processed
↓
Functional and Unit test subdirectories are added

In Functional Tests (CTestFunctionalTests.cmake):

Check MPIEXEC_EXECUTABLE exists (bail if not)
↓
Read MCA_PML and MCA_OSC environment variables
→ If set: use those values
→ If not set: default to "ucx"
↓
Store as MCA_PML_VALUE and MCA_OSC_VALUE
↓
For each test definition:
→ Build test command with:
- test_wrapper.sh
- MPIEXEC_EXECUTABLE (e.g., mpirun)
- MPIEXEC_NUMPROC_FLAG -n ${RANKS}
- -mca pml ${MCA_PML_VALUE}
- -mca osc ${MCA_OSC_VALUE}
- Environment variables (-x flags)
- Test executable + arguments
→ Register with add_test()
→ Assign labels (tier, category, backend, variant)
↓
~445 functional tests registered

In Unit Tests (CTestUnitTests.cmake):

Same MCA parameter detection
↓
Build unit test command with MCA parameters
↓
Register unit tests (currently 1 test: unit_tests_n4)

  1. Test Execution Time (when you run ctest)

User runs: ctest -L quick
↓
CTest filters tests by label "quick"
↓
For each matching test:
CTest executes the TEST_COMMAND

Test Command Execution Flow:

test_wrapper.sh <test_name> -n -mca pml ucx -mca osc ucx [env vars] [executable] [args]
↓
Wrapper checks GPU count
→ If insufficient GPUs: exit 125 (skip test)
↓
Wrapper detects backend (smart detection):
→ If ROCSHMEM_BACKEND env var set: use it
→ Else: run rocshmem_info to detect compiled backends
- If 1 backend compiled: use it (apply skip logic)
- If multiple backends: set BACKEND="multi" (no skips)
↓
Wrapper applies skip logic based on backend:
→ If test requires specific backend and doesn't match: exit 125 (skip)
↓
Wrapper constructs final mpirun command:
mpirun -n -mca pml ucx -mca osc ucx -x ENV1 -x ENV2 ... --timeout X --map-by numa
↓
Execute the test
↓
Return exit code to CTest:
→ 0 = pass
→ 125 = skip
→ other = fail

  1. Key Components

MCA Parameters:

  • Set once at CMake configure time (not runtime)
  • Read from MCA_PML and MCA_OSC environment variables
  • Default to "ucx" if not set
  • Baked into every test command as -mca pml ${MCA_PML_VALUE} -mca osc ${MCA_OSC_VALUE}

Backend Detection (in test_wrapper.sh):

  1. Check if ROCSHMEM_BACKEND env var is set → use it
  2. Otherwise, query rocshmem_info to see what's compiled
  3. If single backend (e.g., only IPC): use it and apply skip logic
  4. If multiple backends (e.g., RO+IPC+GDA): set to "multi" and don't skip tests

Test Organization:

  • Labels: Tests tagged with tier (quick/standard/comprehensive/full), category (RMA/AMO/COLLECTIVE), backend (RO/IPC/GDA), variant
    (uuid/default_stream)
  • Filtering: ctest -L quick runs only quick tier, ctest -L RMA runs only RMA tests, etc.
  • Parallel execution: CTest can run tests in parallel (respects PROCESSORS property)

Backward Compatibility:

  • rocshmem_functional_driver.sh still built and installed
  • Works independently from CTest
  • Users can choose: ctest (modern) or ./driver.sh (traditional)
  1. Environment Variable Flow

Configure time:
MCA_PML, MCA_OSC → Baked into test commands

Runtime:
ROCSHMEM_BACKEND → Passed to wrapper, controls backend selection
ROCSHMEM_BACKEND_TYPE → Alternative to ROCSHMEM_BACKEND (wrapper checks both)

Test execution:
ROCSHMEM_MAX_NUM_CONTEXTS → Set per-test via -x flag
UCX_ROCM_IPC_SIGPOOL_MAX_ELEMS → Set via -x flag
ROCSHMEM_HEAP_SIZE → Set via -x flag
ROCSHMEM_TEST_UUID → Set for uuid variant tests
ROCSHMEM_TEST_USE_DEFAULT_STREAM → Set for default_stream variant

  1. Summary

The flow is: Configure → Register → Filter → Execute → Report

  • Configure: Detect MPI, read MCA parameters, build test commands
  • Register: Each test registered with labels and command
  • Filter: User selects tests via labels
  • Execute: Wrapper checks resources, detects backend, runs mpirun
  • Report: CTest collects results (pass/fail/skip)

All MCA parameters and mpirun flags are determined at CMake configure time, ensuring consistent test execution and matching the old driver.sh
behavior.

@edgargabriel
edgargabriel force-pushed the rocshmem/ctests-conversion branch 2 times, most recently from cae24e8 to 26dbaf4 Compare June 2, 2026 14:18
@edgargabriel

Copy link
Copy Markdown
Contributor Author

@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:

  • configuration of theRock test categories are now done based on the test_configuration.yaml file
  • included some more tests into the 'quick' category to cover more functional areas, but still staying below the 5 min limit
  • recognizing the MCA_PML and MCA_OSC environment variables at rocshmem configure time that influence the arguments of the mpirun command line that is being constructed
  • use the variables set by find_package(MPI) instead of trying to define new ones.

@edgargabriel
edgargabriel force-pushed the rocshmem/ctests-conversion branch from 26dbaf4 to 1bb2599 Compare June 3, 2026 13:49
edgargabriel and others added 9 commits June 5, 2026 10:26
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>
edgargabriel and others added 16 commits June 5, 2026 10:26
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>
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
@edgargabriel
edgargabriel force-pushed the rocshmem/ctests-conversion branch from 046ab05 to 819f5d8 Compare June 5, 2026 15:26
@edgargabriel
edgargabriel merged commit c541756 into develop Jun 8, 2026
11 of 12 checks passed
@edgargabriel
edgargabriel deleted the rocshmem/ctests-conversion branch June 8, 2026 18:37
dileepr1 added a commit to ROCm/TheRock that referenced this pull request Jul 28, 2026
## 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants