Files
TheRock/rocm-systems/projects/rocprof-trace-decoder/test/csv_test.py
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

78 lines
2.3 KiB
Python

#!/usr/bin/env python3
# MIT License
#
# Copyright (c) 2024-2026 Advanced Micro Devices, Inc. All rights reserved.
from __future__ import annotations
import argparse
import glob
import os
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python"))
from rocprof_trace_decoder import Decoder
from rocprof_trace_decoder.code_index import CodeIndex
def _expand(paths: list[str]) -> tuple[list[Path], list[Path]]:
att_files: list[Path] = []
csv_files: list[Path] = []
for arg in paths:
expanded = sorted(glob.glob(arg)) if any(ch in arg for ch in "*?") else [arg]
if not expanded:
raise SystemExit(f"No matches for pattern: {arg}")
for item in expanded:
path = Path(item).resolve()
suffix = path.suffix.lower()
if suffix == ".att":
att_files.append(path)
elif suffix == ".csv":
csv_files.append(path)
return att_files, csv_files
def main() -> int:
parser = argparse.ArgumentParser(description="CSV integration test for rocprof-trace-decoder")
parser.add_argument("--lib", required=True, help="Path to the decoder shared library")
parser.add_argument(
"--suppress-warnings",
action="store_true",
help="Suppress info/warning messages from the decoder",
)
parser.add_argument("files", nargs="*", help=".att and .csv files or glob patterns")
args = parser.parse_args()
if not args.files:
return 0
att_files, csv_files = _expand(args.files)
code_index = CodeIndex.from_stats_csv(csv_files)
with Decoder(args.lib) as decoder:
for att_file in att_files:
records = decoder.parse_file(att_file, isa=code_index)
if (
records.info
and not args.suppress_warnings
and os.getenv("ATT_SUPPRESS_WARNING") is None
):
for info in records.info:
print(f"Warning: {decoder.info_string(info)}", file=sys.stderr)
for wave in records.waves:
code_index.accumulate_wave(wave)
errors = code_index.validate_expected()
if errors:
print(errors[0])
return 1
return 0
if __name__ == "__main__":
raise SystemExit(main())