-
Notifications
You must be signed in to change notification settings - Fork 24
[DRAFT][rocgdb] Test filter standardization #170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dileepr1
wants to merge
2
commits into
amd-staging
Choose a base branch
from
users/dravindr/tf_rocgdb
base: amd-staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Generated by .github/test-runner/gen_ctestfile.py from | ||
| # .github/test-runner/test_categories.yaml. Do not edit by hand. | ||
| # | ||
| # Rerun the generator after editing test_categories.yaml: | ||
| # python3 .github/test-runner/gen_ctestfile.py | ||
| # | ||
| # Each test invokes the canonical launcher installed one level above | ||
| # the testsuite tree (tests/rocgdb/test_rocgdb.py) via the relative | ||
| # path ../../test_rocgdb.py. ctest sets each test's working directory | ||
| # to the directory containing this CTestTestfile.cmake, so the path | ||
| # resolves inside the install tree and the layout stays relocatable. | ||
| # --try-rocm-path tells the launcher to use the absolute ROCM_PATH | ||
| # exported by TheRock's test_runner.py for locating the testsuite. | ||
|
|
||
| add_test(rocgdb_quick "python3" "../../test_rocgdb.py" "--tier" "quick" "--try-rocm-path") | ||
| set_tests_properties(rocgdb_quick PROPERTIES | ||
| LABELS "quick;pre-commit;smoke" | ||
| TIMEOUT 300) | ||
|
|
||
| add_test(rocgdb_standard "python3" "../../test_rocgdb.py" "--tier" "standard" "--try-rocm-path") | ||
| set_tests_properties(rocgdb_standard PROPERTIES | ||
| LABELS "standard;pr;precheckin" | ||
| TIMEOUT 2700) | ||
|
|
||
| add_test(rocgdb_comprehensive "python3" "../../test_rocgdb.py" "--tier" "comprehensive" "--try-rocm-path") | ||
| set_tests_properties(rocgdb_comprehensive PROPERTIES | ||
| LABELS "comprehensive;nightly;extended" | ||
| TIMEOUT 14400) | ||
|
|
||
| add_test(rocgdb_full "python3" "../../test_rocgdb.py" "--tier" "full" "--try-rocm-path") | ||
| set_tests_properties(rocgdb_full PROPERTIES | ||
| LABELS "full;all" | ||
| TIMEOUT 28800) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| #!/usr/bin/env python3 | ||
| # Copyright Advanced Micro Devices, Inc. | ||
| # SPDX-License-Identifier: MIT | ||
| """ | ||
| Generate .github/test-runner/CTestTestfile.cmake from test_categories.yaml. | ||
|
|
||
| These test-runner files live under .github/ (not next to gdb's upstream | ||
| sources) to keep ROCgdb close to upstream. TheRock's ROCgdb cmake wrapper | ||
| (debug-tools/rocgdb/CMakeLists.txt) installs them, when present, into the | ||
| testsuite tree with EXISTS-guarded install rules so the wrapper still works | ||
| with upstream gdb sources that do not ship these files. The generated file | ||
| lands at: | ||
|
|
||
| <artifacts>/tests/rocgdb/gdb/testsuite/CTestTestfile.cmake | ||
|
|
||
| TheRock's generic test_runner.py then drives it via: | ||
|
|
||
| ctest -L <tier> --test-dir <artifacts>/tests/rocgdb/gdb/testsuite | ||
|
|
||
| Each emitted test invokes the canonical launcher, which TheRock installs | ||
| one level above the testsuite tree at <artifacts>/tests/rocgdb/test_rocgdb.py | ||
| (from this repo's .github/scripts/test_rocgdb.py). ctest sets each test's | ||
| working directory to the directory containing this CTestTestfile.cmake, so | ||
| the launcher is reached via the relative path ../../test_rocgdb.py. This | ||
| keeps the install tree fully relocatable: no env-var plumbing, no absolute | ||
| paths, and no component-specific knowledge on the TheRock side. | ||
|
|
||
| This generator is a developer tool. After editing test_categories.yaml, run: | ||
|
|
||
| python3 .github/test-runner/gen_ctestfile.py | ||
|
|
||
| and commit the regenerated CTestTestfile.cmake alongside the YAML. | ||
| """ | ||
|
|
||
| import argparse | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| try: | ||
| import yaml | ||
| except ImportError: | ||
| sys.stderr.write( | ||
| "ERROR: PyYAML is required. Install it via `pip install pyyaml`.\n" | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
|
|
||
| VALID_TIERS = ("quick", "standard", "comprehensive", "full") | ||
|
|
||
| SCRIPT_DIR = Path(__file__).resolve().parent | ||
| DEFAULT_YAML = SCRIPT_DIR / "test_categories.yaml" | ||
| DEFAULT_OUT = SCRIPT_DIR / "CTestTestfile.cmake" | ||
|
|
||
| # Path from the installed CTestTestfile.cmake | ||
| # (tests/rocgdb/gdb/testsuite/) up to the installed launcher | ||
| # (tests/rocgdb/test_rocgdb.py). | ||
| LAUNCHER_REL = "../../test_rocgdb.py" | ||
|
|
||
|
|
||
| def parse_args() -> argparse.Namespace: | ||
| p = argparse.ArgumentParser(description=__doc__) | ||
| p.add_argument( | ||
| "--yaml", | ||
| type=Path, | ||
| default=DEFAULT_YAML, | ||
| help=f"Path to test_categories.yaml (default: {DEFAULT_YAML}).", | ||
| ) | ||
| p.add_argument( | ||
| "--out", | ||
| type=Path, | ||
| default=DEFAULT_OUT, | ||
| help=f"Output path for CTestTestfile.cmake (default: {DEFAULT_OUT}).", | ||
| ) | ||
| return p.parse_args() | ||
|
|
||
|
|
||
| def _quote_labels(labels) -> str: | ||
| # CTest LABELS property uses ';' as separator. Strip any stray ';' from | ||
| # the YAML-supplied labels (defensive - YAML shouldn't have them, but | ||
| # CTest would silently split and produce wrong labels). | ||
| cleaned = [str(label).replace(";", "_") for label in labels] | ||
| return ";".join(cleaned) | ||
|
|
||
|
|
||
| def render(yaml_path: Path) -> str: | ||
| with yaml_path.open("r", encoding="utf-8") as f: | ||
| cfg = yaml.safe_load(f) or {} | ||
|
|
||
| categories = cfg.get("test_categories") or {} | ||
| execution_settings = cfg.get("execution_settings") or {} | ||
| default_timeout = int(execution_settings.get("default_timeout", 300)) | ||
| category_timeouts = execution_settings.get("category_timeouts") or {} | ||
|
|
||
| lines = [ | ||
| "# Generated by .github/test-runner/gen_ctestfile.py from", | ||
| "# .github/test-runner/test_categories.yaml. Do not edit by hand.", | ||
| "#", | ||
| "# Rerun the generator after editing test_categories.yaml:", | ||
| "# python3 .github/test-runner/gen_ctestfile.py", | ||
| "#", | ||
| "# Each test invokes the canonical launcher installed one level above", | ||
| "# the testsuite tree (tests/rocgdb/test_rocgdb.py) via the relative", | ||
| "# path ../../test_rocgdb.py. ctest sets each test's working directory", | ||
| "# to the directory containing this CTestTestfile.cmake, so the path", | ||
| "# resolves inside the install tree and the layout stays relocatable.", | ||
| "# --try-rocm-path tells the launcher to use the absolute ROCM_PATH", | ||
| "# exported by TheRock's test_runner.py for locating the testsuite.", | ||
| "", | ||
| ] | ||
|
|
||
| emitted_any = False | ||
| for tier in VALID_TIERS: | ||
| spec = categories.get(tier) | ||
| if not spec: | ||
| continue | ||
| labels = spec.get("labels") or [tier] | ||
| timeout = int(category_timeouts.get(tier, default_timeout)) | ||
| # ctest test names must be bare CMake identifiers (no spaces / | ||
| # quotes) so `ctest --print-labels` and label-regex consumers can | ||
| # match them deterministically. | ||
| test_name = f"rocgdb_{tier}" | ||
|
|
||
| # --try-rocm-path makes the launcher prefer the absolute ROCM_PATH that | ||
| # TheRock's test_runner.py exports (derived from THEROCK_BIN_DIR) over | ||
| # the relative OUTPUT_ARTIFACTS_DIR. ctest runs each test with its CWD | ||
| # set to this directory, so a relative OUTPUT_ARTIFACTS_DIR like | ||
| # "./build" would otherwise resolve against the testsuite dir and fail. | ||
| lines.append( | ||
| f'add_test({test_name} "python3" "{LAUNCHER_REL}" ' | ||
| f'"--tier" "{tier}" "--try-rocm-path")' | ||
| ) | ||
| lines.append(f"set_tests_properties({test_name} PROPERTIES") | ||
| lines.append(f' LABELS "{_quote_labels(labels)}"') | ||
| lines.append(f" TIMEOUT {timeout})") | ||
| lines.append("") | ||
| emitted_any = True | ||
|
|
||
| if not emitted_any: | ||
| sys.stderr.write( | ||
| f"ERROR: no test_categories.<tier> entries found in {yaml_path}\n" | ||
| ) | ||
| sys.exit(1) | ||
|
|
||
| return "\n".join(lines).rstrip() + "\n" | ||
|
|
||
|
|
||
| def main() -> None: | ||
| args = parse_args() | ||
| if not args.yaml.is_file(): | ||
| sys.stderr.write(f"ERROR: YAML file not found: {args.yaml}\n") | ||
| sys.exit(1) | ||
|
|
||
| content = render(args.yaml) | ||
| args.out.parent.mkdir(parents=True, exist_ok=True) | ||
| args.out.write_text(content, encoding="utf-8") | ||
| print(f"Wrote {args.out} ({len(content)} bytes)") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.