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) 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",