Repository navigation
test(rocprofiler-compute): Move tests under tests/unit and tests/integration - #9762
Conversation
There was a problem hiding this comment.
Pull request overview
Reorganizes rocprofiler-compute’s pytest suite so test paths encode scope (unit vs integration) and enforces fixture isolation by splitting conftest.py by directory. Adds a GPU-less CI unit-test gate that runs only tests/unit/.
Changes:
- Move/refactor tests into
tests/unit/(mirroringsrc/) andtests/integration/(feature-driven), with__init__.pychaining preserved. - Split
conftest.pyinto root/unit/integration layers to prevent unit tests from reaching integration fixtures at collection time. - Add a new GitHub Actions
unit_testsjob to runpytest tests/unit/onubuntu-latestand gate the ubuntu matrix.
Reviewed changes
Copilot reviewed 31 out of 91 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocprofiler-compute/tests/unit/utils/test_utils_profile_csv.py | Adds unit coverage for stdlib-only CSV helper utilities. |
| projects/rocprofiler-compute/tests/unit/utils/test_utils_counter_defs.py | Adds unit tests for counter/variable extraction helper. |
| projects/rocprofiler-compute/tests/unit/utils/test_specs.py | Adds unit tests for utils.specs behavior and regressions. |
| projects/rocprofiler-compute/tests/unit/utils/test_rocprofv3_avail_interface.py | Adds unit tests for rocprofv3 avail library probing/caching. |
| projects/rocprofiler-compute/tests/unit/utils/test_pattern_matching.py | Adds unit test for glob-matching helper. |
| projects/rocprofiler-compute/tests/unit/utils/test_native_tool_finder.py | Adds unit tests for native collector discovery/build logic. |
| projects/rocprofiler-compute/tests/unit/utils/test_mem_chart_gfx9.py | Adds unit tests for gfx9 memory chart rendering output. |
| projects/rocprofiler-compute/tests/unit/utils/test_file_io.py | Adds unit tests for file I/O dataframe shaping utilities. |
| projects/rocprofiler-compute/tests/unit/utils/test_amdsmi_interface.py | Adds unit tests for AMD SMI wrapper behaviors. |
| projects/rocprofiler-compute/tests/unit/utils/metrics/test_noise_clamper.py | Adds unit tests for multi-pass variance clamping logic. |
| projects/rocprofiler-compute/tests/unit/utils/metrics/test_metrics_common.py | Adds unit tests for metric warning/heuristics helpers. |
| projects/rocprofiler-compute/tests/unit/utils/metrics/test_metric_evaluator.py | Adds unit tests for metric expression evaluation edge cases. |
| projects/rocprofiler-compute/tests/unit/utils/metrics/test_expression.py | Adds unit tests for expression parsing/rewriting utilities. |
| projects/rocprofiler-compute/tests/unit/utils/metrics/test_aggregation.py | Adds unit tests for aggregation helper functions. |
| projects/rocprofiler-compute/tests/unit/utils/metrics/init.py | Establishes unit-test package namespace for metrics tests. |
| projects/rocprofiler-compute/tests/unit/utils/inject_roctx/_backends/init.py | Establishes unit-test package namespace for inject_roctx backend tests. |
| projects/rocprofiler-compute/tests/unit/utils/inject_roctx/init.py | Establishes unit-test package namespace for inject_roctx tests. |
| projects/rocprofiler-compute/tests/unit/utils/init.py | Establishes unit-test package namespace for utils tests. |
| projects/rocprofiler-compute/tests/unit/test_conftest.py | Adjusts import-guard unit test to use explicit pandas module reference. |
| projects/rocprofiler-compute/tests/unit/test_common.py | Adds unit tests for shared tests/common.py helpers. |
| projects/rocprofiler-compute/tests/unit/test_argparser.py | Adds unit tests for CLI argparser behaviors and validation. |
| projects/rocprofiler-compute/tests/unit/roofline/test_roofline_main.py | Adds unit tests for roofline plot generation paths/labels. |
| projects/rocprofiler-compute/tests/unit/roofline/benchmark/test_benchmark_base.py | Adds unit tests for benchmark GPU lock behavior. |
| projects/rocprofiler-compute/tests/unit/roofline/benchmark/init.py | Establishes unit-test package namespace for roofline benchmark tests. |
| projects/rocprofiler-compute/tests/unit/roofline/init.py | Establishes unit-test package namespace for roofline tests. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/widgets/test_instant_button.py | Adds unit tests for TUI InstantButton widget behavior. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/widgets/test_collapsibles.py | Adds unit tests for collapsibles widget/config loading behaviors. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/widgets/menu_bar/test_menu_bar.py | Adds unit tests for menu bar widgets visibility/focus logic. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/widgets/menu_bar/init.py | Establishes unit-test package namespace for menu_bar widgets tests. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/widgets/init.py | Establishes unit-test package namespace for widgets tests. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/utils/test_tui_utils.py | Adds unit tests for TUI utils dataframe shaping and logger. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/utils/init.py | Establishes unit-test package namespace for TUI utils tests. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_tui/init.py | Establishes unit-test package namespace for TUI tests. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_soc/test_soc_base.py | Adds unit tests for SoC counter allocation/bin-packing helpers. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_soc/init.py | Establishes unit-test package namespace for SoC tests. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_profile/init.py | Establishes unit-test package namespace for profile tests. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_analyze/test_analysis_cli.py | Adds unit tests for analyze CLI helpers/backend filtering. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_analyze/test_analysis_base.py | Adds unit tests for analysis CSV concatenation logic. |
| projects/rocprofiler-compute/tests/unit/rocprof_compute_analyze/init.py | Establishes unit-test package namespace for analyze tests. |
| projects/rocprofiler-compute/tests/unit/pc_sampling/test_pc_sampling_profile.py | Adds unit tests for PC-sampling runner/limits logic. |
| projects/rocprofiler-compute/tests/unit/pc_sampling/test_code_object_analysis.py | Adds unit tests for code object info parsing/loading. |
| projects/rocprofiler-compute/tests/unit/pc_sampling/init.py | Establishes unit-test package namespace for pc_sampling tests. |
| projects/rocprofiler-compute/tests/unit/conftest.py | Adds unit-only fixtures (e.g., in-memory DB session). |
| projects/rocprofiler-compute/tests/unit/init.py | Establishes tests.unit package namespace. |
| projects/rocprofiler-compute/tests/integration/test_torch_trace_coverage.py | Updates integration imports to integration-only helper namespace. |
| projects/rocprofiler-compute/tests/integration/test_roofline_analyze.py | Routes workload setup through integration helper module. |
| projects/rocprofiler-compute/tests/integration/test_profile_triton_trace.py | Moves integration fixtures/helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_torch_trace.py | Moves integration helpers (CSV checks) under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_sort.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_sets_func.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_section.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_roofline.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_path.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_multi_rank.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_misc.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_live_attach_detach.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_kernel_execution.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_join.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_iteration_multiplexing.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_profile_dispatch.py | Moves integration helpers under integration namespace. |
| projects/rocprofiler-compute/tests/integration/test_pc_sampling.py | Moves PC-sampling GPU requirements and checks to integration helper. |
| projects/rocprofiler-compute/tests/integration/test_pc_sampling_analyze_cli.py | Routes workload setup through integration helper module. |
| projects/rocprofiler-compute/tests/integration/test_num_xcds.py | Moves GPU SoC probing to integration helper module. |
| projects/rocprofiler-compute/tests/integration/test_metric_validation.py | Moves GPU SoC probing and CSV checks to integration helper module. |
| projects/rocprofiler-compute/tests/integration/test_list_metrics_cli.py | Adds integration coverage for modeless list commands across arches. |
| projects/rocprofiler-compute/tests/integration/test_l1_cache_counters.py | Moves GPU SoC probing to integration helper module. |
| projects/rocprofiler-compute/tests/integration/test_analyze_workloads.py | Routes workload setup through integration helper module. |
| projects/rocprofiler-compute/tests/integration/conftest.py | Adds integration-only fixtures for CLI/GPU execution paths. |
| projects/rocprofiler-compute/tests/integration/common.py | Introduces integration-only helper module (GPU probing/workload setup). |
| projects/rocprofiler-compute/tests/integration/init.py | Establishes tests.integration package namespace. |
| projects/rocprofiler-compute/tests/conftest.py | Removes integration/unit-only fixtures from root conftest, leaving shared hooks/guard/options. |
| projects/rocprofiler-compute/tests/common.py | Removes integration-only helpers to keep unit runs GPU-free and lighter. |
| .github/workflows/rocprofiler-compute-continuous-integration.yml | Adds a dedicated no-GPU unit test job and gates ubuntu matrix on it. |
Suppressed comments (1)
projects/rocprofiler-compute/tests/integration/common.py:165
gpu_soc()shells out torocminfoat import time via module-level callers. Ifrocminfois not installed/available on the host, test collection will error with FileNotFoundError instead of cleanly returning ('','') and letting tests skip. Catch FileNotFoundError and return empty strings.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
520dd5a to
b723c49
Compare
6fa499c to
95d73d0
Compare
b723c49 to
8aab665
Compare
95d73d0 to
ff1e72d
Compare
d37d2aa to
5c6cc20
Compare
ff1e72d to
684f0d2
Compare
5c6cc20 to
21b880c
Compare
684f0d2 to
9b079c6
Compare
21b880c to
b67a99e
Compare
9b079c6 to
90dfb33
Compare
b67a99e to
28f488f
Compare
90dfb33 to
0c18360
Compare
28f488f to
99106be
Compare
|
rocprofiler-compute/tests/test_categories.yaml While addressing comments in #9711 I noticed that the My most recent run of quick category tests came out to 6.3 minutes. Those two dominate the time completely. Requesting if we can move one or both of the test cases out of quick. |
0c18360 to
ba7745b
Compare
99106be to
cba1cb0
Compare
ba7745b to
d8fa8e0
Compare
cba1cb0 to
88e8882
Compare
d8fa8e0 to
495153c
Compare
6a058cc to
e918edc
Compare
Unit tests now mirror the src/ tree, integration tests sit in one flat directory named by feature, so a file's path answers what it covers. A unit test that reaches for an integration fixture fails at collection instead of silently spawning a subprocess. - Chain __init__.py from tests/ down to every leaf. Mirroring only the packages src/ marks as regular makes pytest name a test module utils.metrics.test_common, which shadows the real package and breaks collection; pythonpath is deliberately unchanged for the same reason. - Split conftest.py three ways: the root keeps ProfileModeImportGuard and pytest_addoption, which must stay there or --call-binary stops parsing; tests/unit gets db_session; tests/integration gets the binary_handler fixtures. - Consume profile_helpers.py into tests/integration/common.py along with the helpers no unit test uses. Integration tests import both namespaces explicitly rather than star-importing, so the two helper sets stay distinguishable at the call site. - Repoint every add_test at its new source path. CTest names, test_categories.yaml, and pyproject.toml are untouched. Test bodies are unchanged, so the suite collects the same tests under the same names before and after. Co-Authored-By: Claude Opus 5 (1M context)
- tests/integration/conftest.py computes its own rocprof-compute path and is the only consumer, so the root copy is dead. - Unit-only runs no longer abort on a tree without the script. Co-Authored-By: Claude Opus 5
Bugfix: analyze CTest entries no longer fail at collection on a host without rocminfo. tests/integration/conftest.py imports common.py, which probed the GPU at module scope, so every integration test paid for a rocminfo call before any test ran. - gpu_soc() returns empty strings when rocminfo is absent from PATH, which is the contract its docstring already described, and is memoized so the probe still happens once per session. - gpu_arch and soc become session-scoped fixtures rather than module globals. Helpers inside common.py call gpu_soc() directly since they cannot take fixtures. - AVAILABLE_SETS moves to test_profile_sets_func.py, its only consumer. Parametrization resolves before fixtures exist, so this stays a collection-time call, but only for the module that needs it. - Module-level constants move above the first function definition. Co-Authored-By: Claude Opus 5
Out of scope for this PR, flagged while repointing add_test paths. - #9979 added tests/test_per_kernel_isa_export.py and listed it in test_categories.yaml, but never added an add_test entry, so the file has never run in CI. The yaml only attaches labels to tests CTest already knows about, so the four entries there were inert. - The 8 tests in it pass. Co-Authored-By: Claude Opus 5
e918edc to
0bfac95
Compare
6c3901f
into
rocprofiler-compute-develop
…gration (#9762) ## Motivation A test file's path now answers what it covers. Unit tests mirror the `src/` tree, so a test for `src/utils/parser.py` lives at `tests/unit/utils/test_parser.py`. Integration tests sit in one flat directory named by the feature they drive end to end. The load-bearing part is enforcement: a unit test that reaches for an integration fixture fails at collection instead of silently spawning a subprocess. This is PR 2 of 2 and stacks on #9732. Test bodies are unchanged, so the same tests collect under the same names before and after; only the directory they live in differs. ## Technical Details - `__init__.py` is chained from `tests/` down to every leaf, and `pythonpath` is unchanged. - Helpers (`common.py`) and fixtures (`conftest.py`) are now supported at root, unit, and integration level, each layered onto the one above it. - `profile_helpers.py` is consumed into `tests/integration/common.py`, along with the helpers no unit test uses. Integration tests import the shared and integration namespaces separately. - Every `add_test` is repointed at its new source path. CTest names, `test_categories.yaml`, and `pyproject.toml` are untouched. ## JIRA JIRA ID: AIPROFCOMP-705 ## Test Plan - Collect the suite before and after and confirm the same tests appear under the same names, ignoring the directory they moved to. - `ruff check tests/`, `ruff format --check tests/`, and `gersemi --check CMakeLists.txt`. - `ctest -N` to confirm no CTest name is dropped. - Build with `TEST_FROM_INSTALL=ON` and run the unit entries from the install tree, where `src/` is flattened and the import layout differs from the source tree. - Confirm a unit test cannot reach an integration fixture or helper. ## Test Result - The same tests collect under the same names before and after, with zero diff. - `ruff check`, `ruff format --check`, and `gersemi --check` are clean. - CTest names are unchanged, and every `add_test` source path resolves. - The unit suite passes with no GPU, and every unit CTest entry passes from a `TEST_FROM_INSTALL=ON` install tree. - A unit test requesting `binary_handler_profile_rocprof_compute` fails at collection, and `common` exposes no GPU helpers to unit tests. - GPU and integration tests were not run. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.
…gration (#9762) ## Motivation A test file's path now answers what it covers. Unit tests mirror the `src/` tree, so a test for `src/utils/parser.py` lives at `tests/unit/utils/test_parser.py`. Integration tests sit in one flat directory named by the feature they drive end to end. The load-bearing part is enforcement: a unit test that reaches for an integration fixture fails at collection instead of silently spawning a subprocess. This is PR 2 of 2 and stacks on #9732. Test bodies are unchanged, so the same tests collect under the same names before and after; only the directory they live in differs. ## Technical Details - `__init__.py` is chained from `tests/` down to every leaf, and `pythonpath` is unchanged. - Helpers (`common.py`) and fixtures (`conftest.py`) are now supported at root, unit, and integration level, each layered onto the one above it. - `profile_helpers.py` is consumed into `tests/integration/common.py`, along with the helpers no unit test uses. Integration tests import the shared and integration namespaces separately. - Every `add_test` is repointed at its new source path. CTest names, `test_categories.yaml`, and `pyproject.toml` are untouched. ## JIRA JIRA ID: AIPROFCOMP-705 ## Test Plan - Collect the suite before and after and confirm the same tests appear under the same names, ignoring the directory they moved to. - `ruff check tests/`, `ruff format --check tests/`, and `gersemi --check CMakeLists.txt`. - `ctest -N` to confirm no CTest name is dropped. - Build with `TEST_FROM_INSTALL=ON` and run the unit entries from the install tree, where `src/` is flattened and the import layout differs from the source tree. - Confirm a unit test cannot reach an integration fixture or helper. ## Test Result - The same tests collect under the same names before and after, with zero diff. - `ruff check`, `ruff format --check`, and `gersemi --check` are clean. - CTest names are unchanged, and every `add_test` source path resolves. - The unit suite passes with no GPU, and every unit CTest entry passes from a `TEST_FROM_INSTALL=ON` install tree. - A unit test requesting `binary_handler_profile_rocprof_compute` fails at collection, and `common` exposes no GPU helpers to unit tests. - GPU and integration tests were not run. ## Submission Checklist - [x] Look over the contributing guidelines at https://github.com/ROCm/rocm-systems/blob/develop/CONTRIBUTING.md.
Motivation
A test file's path now answers what it covers. Unit tests mirror the
src/tree, so a test for
src/utils/parser.pylives attests/unit/utils/test_parser.py. Integration tests sit in one flat directorynamed by the feature they drive end to end.
The load-bearing part is enforcement: a unit test that reaches for an
integration fixture fails at collection instead of silently spawning a
subprocess.
This is PR 2 of 2 and stacks on #9732. Test bodies are unchanged, so the same
tests collect under the same names before and after; only the directory they
live in differs.
Technical Details
__init__.pyis chained fromtests/down to every leaf, andpythonpathis unchanged.
common.py) and fixtures (conftest.py) are now supported at root,unit, and integration level, each layered onto the one above it.
profile_helpers.pyis consumed intotests/integration/common.py, alongwith the helpers no unit test uses. Integration tests import the shared and
integration namespaces separately.
add_testis repointed at its new source path. CTest names,test_categories.yaml, andpyproject.tomlare untouched.JIRA
JIRA ID: AIPROFCOMP-705
Test Plan
the same names, ignoring the directory they moved to.
ruff check tests/,ruff format --check tests/, andgersemi --check CMakeLists.txt.ctest -Nto confirm no CTest name is dropped.TEST_FROM_INSTALL=ONand run the unit entries from the installtree, where
src/is flattened and the import layout differs from the sourcetree.
Test Result
ruff check,ruff format --check, andgersemi --checkare clean.add_testsource path resolves.TEST_FROM_INSTALL=ONinstall tree.binary_handler_profile_rocprof_computefails atcollection, and
commonexposes no GPU helpers to unit tests.Submission Checklist