From 104ba98bf64bdd356f4ca3a8d63c3171536a83a7 Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Mon, 12 Oct 2026 11:12:32 -0500 Subject: [PATCH 1/2] debug-tools: Build and package amd-dbgapi test suite rocdbgapi now builds a unit test suite through ENABLE_TESTS and ENABLE_UNIT_TESTS, installing the test binaries under a dedicated install component. Wire THEROCK_BUILD_TESTING through to ENABLE_TESTS so the suite is built whenever testing is enabled, add therock-googletest as a build dependency when that's the case, and fold the test binaries into the amd-dbgapi artifact as a new test component so they get staged and distributed like everything else. Co-Authored-By: Claude Sonnet 5.5 --- build_tools/packaging/linux/package.json | 11 +++++++++++ debug-tools/CMakeLists.txt | 10 ++++++++++ debug-tools/artifact-amd-dbgapi.toml | 7 +++++++ test_tools/therock_consumer_graph.json | 1 + 4 files changed, 29 insertions(+) diff --git a/build_tools/packaging/linux/package.json b/build_tools/packaging/linux/package.json index 33e590442e1..6fdae8ca5ad 100644 --- a/build_tools/packaging/linux/package.json +++ b/build_tools/packaging/linux/package.json @@ -3046,6 +3046,17 @@ ] } ] + }, + { + "Artifact": "amd-dbgapi", + "Artifact_Subdir": [ + { + "Name": "amd-dbgapi", + "Components": [ + "test" + ] + } + ] } ], "Disable_DWZ": "True", diff --git a/debug-tools/CMakeLists.txt b/debug-tools/CMakeLists.txt index cd4d72eda2d..7416ea67ddb 100644 --- a/debug-tools/CMakeLists.txt +++ b/debug-tools/CMakeLists.txt @@ -70,6 +70,13 @@ if(THEROCK_ENABLE_AMD_DBGAPI) set(EXTRA_DEBUG_TOOLS_CMAKE_ARGS "-DBUILD_SHARED_LIBS=OFF") endif() + # Only build and link against GoogleTest when tests are requested, so + # the dependency isn't pulled in for non-testing configurations. + set(EXTRA_AMD_DBGAPI_BUILD_DEPS) + if(THEROCK_BUILD_TESTING) + list(APPEND EXTRA_AMD_DBGAPI_BUILD_DEPS therock-googletest) + endif() + therock_cmake_subproject_declare(amd-dbgapi USE_DIST_AMDGPU_TARGETS EXTERNAL_SOURCE_DIR "${THEROCK_AMD_DBGAPI_SOURCE_DIR}" @@ -78,9 +85,11 @@ if(THEROCK_ENABLE_AMD_DBGAPI) amd-llvm CMAKE_ARGS -DTHE_ROCK_BUILD=ON + "-DENABLE_TESTS=${THEROCK_BUILD_TESTING}" ${EXTRA_DEBUG_TOOLS_CMAKE_ARGS} BUILD_DEPS ${THEROCK_BUNDLED_LIBBACKTRACE} + ${EXTRA_AMD_DBGAPI_BUILD_DEPS} RUNTIME_DEPS amd-comgr INTERFACE_LINK_DIRS @@ -119,6 +128,7 @@ if(THEROCK_ENABLE_AMD_DBGAPI) dev doc lib + test SUBPROJECT_DEPS amd-comgr amd-dbgapi diff --git a/debug-tools/artifact-amd-dbgapi.toml b/debug-tools/artifact-amd-dbgapi.toml index c4d4cfa6cfe..e4ba5bd21da 100644 --- a/debug-tools/artifact-amd-dbgapi.toml +++ b/debug-tools/artifact-amd-dbgapi.toml @@ -2,4 +2,11 @@ [components.lib."debug-tools/amd-dbgapi/stage"] [components.dbg."debug-tools/amd-dbgapi/stage"] [components.dev."debug-tools/amd-dbgapi/stage"] +exclude = [ + "tests/**", +] [components.doc."debug-tools/amd-dbgapi/stage"] +[components.test."debug-tools/amd-dbgapi/stage"] +include = [ + "tests/**" +] diff --git a/test_tools/therock_consumer_graph.json b/test_tools/therock_consumer_graph.json index f6b8e59d9cc..7320293aa2d 100644 --- a/test_tools/therock_consumer_graph.json +++ b/test_tools/therock_consumer_graph.json @@ -639,6 +639,7 @@ "therock-googletest": { "consumers": [ "amd-comgr", + "amd-dbgapi", "amdsmi", "aqlprofile", "hipblas", From b9e5b8d5e65fe28fe8f48742bbe364c33544569c Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Fri, 6 Nov 2026 04:55:05 -0600 Subject: [PATCH 2/2] TEMP: run amd-dbgapi unit tests in CI Temporary patch to try the dbgapi-cpu test job in CI. Adds a test matrix entry on the rocgdb CPU container and a script that runs each GoogleTest binary installed under tests/rocdbgapi. Not meant to merge with the test build PR. Co-Authored-By: Claude Sonnet 5.5 --- .../fetch_test_configurations.py | 9 ++++ .../test_executable_scripts/test_dbgapi.py | 46 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100755 build_tools/github_actions/test_executable_scripts/test_dbgapi.py diff --git a/build_tools/github_actions/fetch_test_configurations.py b/build_tools/github_actions/fetch_test_configurations.py index a7d3076d5ba..0c4678e6192 100644 --- a/build_tools/github_actions/fetch_test_configurations.py +++ b/build_tools/github_actions/fetch_test_configurations.py @@ -534,6 +534,15 @@ def _family_matches( "windows": 1, }, }, + "dbgapi-cpu": { + "job_name": "dbgapi-cpu", + "fetch_artifact_args": "--debug-tools --tests", + "timeout_minutes": 30, + "test_script": f"python {_get_script_path('test_dbgapi.py')}", + "platform": ["linux", "windows"], + "total_shards": 1, + "linux_cpu_runner": True, + }, "rocgdb-cpu": { **_rocgdb_common, "job_name": "rocgdb-cpu", diff --git a/build_tools/github_actions/test_executable_scripts/test_dbgapi.py b/build_tools/github_actions/test_executable_scripts/test_dbgapi.py new file mode 100755 index 00000000000..59e0a874f22 --- /dev/null +++ b/build_tools/github_actions/test_executable_scripts/test_dbgapi.py @@ -0,0 +1,46 @@ +# Copyright Advanced Micro Devices, Inc. +# SPDX-License-Identifier: MIT + +""" +Test script for the amd-dbgapi unit tests. + +The test binaries are installed under tests/rocdbgapi in the unified ROCm tree. +They are plain GoogleTest executables, so each one is run directly. +""" + +import logging +import os +import platform +import shlex +import subprocess +import sys +from pathlib import Path + +THEROCK_BIN_DIR = os.getenv("THEROCK_BIN_DIR") +if not THEROCK_BIN_DIR: + raise RuntimeError("THEROCK_BIN_DIR environment variable is not set") + +logging.basicConfig(level=logging.INFO, format="%(message)s") + +test_dir = Path(THEROCK_BIN_DIR).resolve().parent / "tests" / "rocdbgapi" + +is_windows = platform.system() == "Windows" +tests = sorted( + p + for p in test_dir.iterdir() + if p.is_file() and (p.suffix == ".exe" if is_windows else os.access(p, os.X_OK)) +) +if not tests: + logging.error(f"No test executables found in {test_dir}") + sys.exit(1) + +failed = [] +for test in tests: + cmd = [str(test)] + logging.info(f"++ Exec [{test_dir}]$ {shlex.join(cmd)}") + if subprocess.run(cmd, cwd=test_dir).returncode != 0: + failed.append(test.name) + +if failed: + logging.error(f"Failed tests: {', '.join(failed)}") + sys.exit(1)