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
84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
|
|
# Copyright (c) 2026 Advanced Micro Devices, Inc.
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
import importlib.util
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
VALIDATOR_PATH = Path(__file__).with_name("validate-gfx1250-semantic-translations.py")
|
|
SPEC = importlib.util.spec_from_file_location(
|
|
"gfx1250_semantic_validator", VALIDATOR_PATH
|
|
)
|
|
assert SPEC is not None and SPEC.loader is not None
|
|
VALIDATOR = importlib.util.module_from_spec(SPEC)
|
|
SPEC.loader.exec_module(VALIDATOR)
|
|
|
|
SOURCE_ID = "fnv1a64:0123456789abcdef"
|
|
OTHER_SOURCE_ID = "fnv1a64:fedcba9876543210"
|
|
|
|
|
|
def runtime_record(
|
|
*,
|
|
source_id: str,
|
|
changed: int,
|
|
outcome: str = "translated",
|
|
translation_status: int = 0,
|
|
status: int = 0,
|
|
) -> str:
|
|
return (
|
|
"[hsa-hotswap-rj] eager translation "
|
|
f"source_id={source_id} "
|
|
"input_revision=b0 output_revision=a0 "
|
|
f"outcome={outcome} changed={changed} "
|
|
"input_bytes=64 output_bytes=96 "
|
|
f"translation_status={translation_status} status={status}\n"
|
|
)
|
|
|
|
|
|
class RuntimeEvidenceTest(unittest.TestCase):
|
|
def test_accepts_expected_successes_with_one_matching_fixture(self) -> None:
|
|
runtime_text = runtime_record(
|
|
source_id=SOURCE_ID,
|
|
changed=3,
|
|
) + runtime_record(
|
|
source_id=OTHER_SOURCE_ID,
|
|
changed=0,
|
|
)
|
|
|
|
self.assertEqual(
|
|
VALIDATOR.validate_runtime_evidence(runtime_text, SOURCE_ID, 3, 2),
|
|
(1, 2),
|
|
)
|
|
|
|
def test_rejects_matching_success_plus_failed_record(self) -> None:
|
|
runtime_text = runtime_record(
|
|
source_id=SOURCE_ID,
|
|
changed=3,
|
|
) + runtime_record(
|
|
source_id=OTHER_SOURCE_ID,
|
|
changed=0,
|
|
outcome="translation_failed",
|
|
translation_status=1,
|
|
status=1,
|
|
)
|
|
|
|
with self.assertRaisesRegex(ValueError, "1 successful records"):
|
|
VALIDATOR.validate_runtime_evidence(runtime_text, SOURCE_ID, 3, 2)
|
|
|
|
def test_rejects_anonymous_legacy_records(self) -> None:
|
|
runtime_text = (
|
|
"[hsa-hotswap-rj] eager translated "
|
|
"input_bytes=64 output_bytes=96 status=0\n"
|
|
)
|
|
|
|
with self.assertRaisesRegex(
|
|
ValueError, "no successful runtime record matching"
|
|
):
|
|
VALIDATOR.validate_runtime_evidence(runtime_text, SOURCE_ID, 3, 1)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|