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
75 lines
2.8 KiB
Python
75 lines
2.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Focused schema checks for code.json SQTT funcmap metadata."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import unittest
|
|
from pathlib import Path
|
|
from unittest.mock import patch
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "python"))
|
|
|
|
import rocprof_trace_decoder.codegen as codegen
|
|
|
|
|
|
class CodegenFuncmapTest(unittest.TestCase):
|
|
def generate(self, funcmaps: list[codegen._SqttFuncmap]):
|
|
code_objects = [
|
|
codegen.CodeObject("packed.co", 10),
|
|
codegen.CodeObject("legacy.co", 11),
|
|
][: len(funcmaps)]
|
|
with (
|
|
patch.object(codegen, "_normalize_code_objects", return_value=code_objects),
|
|
patch.object(codegen, "build_address_ranges", return_value=[]),
|
|
patch.object(codegen, "parse_disassembly", return_value=[]),
|
|
patch.object(codegen, "read_symbol_labels", return_value=({}, {})),
|
|
patch.object(codegen, "_read_sqtt_funcmap", side_effect=funcmaps),
|
|
):
|
|
return codegen.generate_code_artifacts(code_objects).code_index.document
|
|
|
|
def test_adds_packed_metadata_without_changing_funcmap_rows(self):
|
|
doc = self.generate(
|
|
[
|
|
codegen._parse_sqtt_funcmap(
|
|
b"M:shader_clock_bits=12;shader_clock_shift=4\n"
|
|
b"F:7:scope@source.cpp:1\n"
|
|
b"U:8:user\n"
|
|
b"R:8:extra_payload_count=1\n"
|
|
)
|
|
]
|
|
)
|
|
|
|
self.assertEqual(
|
|
doc["sqtt_funcmap"],
|
|
[[10, 7, "F", "scope", "source.cpp:1", 0], [10, 8, "U", "user", "", 0]],
|
|
)
|
|
self.assertTrue(all(len(row) == 6 for row in doc["sqtt_funcmap"]))
|
|
self.assertEqual(doc["sqtt_funcmap_layout"], [[10, 12, 4]])
|
|
self.assertEqual(doc["sqtt_funcmap_payloads"], [[10, 8, 1]])
|
|
|
|
def test_legacy_funcmap_exports_rows_without_a_packed_layout(self):
|
|
doc = self.generate(
|
|
[codegen._parse_sqtt_funcmap(b"F:7:scope\nR:7:extra_payload_count=1\n")]
|
|
)
|
|
|
|
self.assertEqual(doc["sqtt_funcmap"], [[10, 7, "F", "scope", "", 0]])
|
|
self.assertNotIn("sqtt_funcmap_layout", doc)
|
|
self.assertEqual(doc["sqtt_funcmap_payloads"], [[10, 7, 1]])
|
|
|
|
def test_incomplete_packed_layout_is_ignored(self):
|
|
doc = self.generate([codegen._parse_sqtt_funcmap(b"M:shader_clock_bits=12\nF:7:scope\n")])
|
|
|
|
self.assertEqual(doc["sqtt_funcmap"], [[10, 7, "F", "scope", "", 0]])
|
|
self.assertNotIn("sqtt_funcmap_layout", doc)
|
|
|
|
def test_packed_layout_does_not_require_named_entries(self):
|
|
doc = self.generate([codegen._parse_sqtt_funcmap(b"M:shader_clock_bits=12;shader_clock_shift=4\n")])
|
|
|
|
self.assertNotIn("sqtt_funcmap", doc)
|
|
self.assertEqual(doc["sqtt_funcmap_layout"], [[10, 12, 4]])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|