From 748e7b13fcecff8970de9e21611039d180ce66ef Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Fri, 23 Oct 2026 18:08:05 -0500 Subject: [PATCH] Fix model runtime test fixtures --- .../tests/test_persistent_runtime_cache.py | 31 +++++++++++++++---- .../models/tests/test_shipped_default.py | 3 +- prebuilt.json | 2 +- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/openpilot/starpilot/models/tests/test_persistent_runtime_cache.py b/openpilot/starpilot/models/tests/test_persistent_runtime_cache.py index 7103ae8db6..b49f18bfe2 100644 --- a/openpilot/starpilot/models/tests/test_persistent_runtime_cache.py +++ b/openpilot/starpilot/models/tests/test_persistent_runtime_cache.py @@ -1,25 +1,44 @@ """Persistent startup cache selection; not GPU or road qualification.""" from pathlib import Path from unittest.mock import patch +from types import SimpleNamespace import pytest -from openpilot.starpilot.models.runtime_bridge import runtime +from openpilot.starpilot.models import manager +from openpilot.starpilot.models.runtime_bridge import native, runtime +@pytest.mark.parametrize("family", ["legacy9d", "native02e"]) @pytest.mark.parametrize("role", ["driving", "monitoring"]) -def test_inference_cache_survives_reboot_without_changing_role_isolation(role): +def test_inference_cache_survives_reboot_without_changing_role_isolation(role, family): selected = {"role": role} + plan = SimpleNamespace(family=family) with (patch("openpilot.common.hardware.AGNOS", True), patch.object(runtime, "_selection", None), + patch.object(runtime, "_plan", None), + patch.object(manager, "freeze_runtime", return_value=plan) as freeze, + patch.object(native, "prepare", return_value=selected) as native_prepare, patch.object(runtime, "_verify_policy") as verify, patch.object(runtime, "activate", return_value=selected) as activate): assert runtime.prepare(role) is selected - verify.assert_called_once() - activate.assert_called_once_with(runtime.BUNDLE, runtime.MANIFEST_SHA256, - runtime.LEGACY_REVISION, role, Path("/data/starpilot-model-runtime")) + if role == "driving": + freeze.assert_called_once_with(recovery_small_only=False) + else: + freeze.assert_not_called() + if role == "driving" and family == "legacy9d": + verify.assert_called_once() + activate.assert_called_once_with(runtime.BUNDLE, runtime.MANIFEST_SHA256, + runtime.LEGACY_REVISION, role, Path("/data/starpilot-model-runtime")) + native_prepare.assert_not_called() + else: + native_prepare.assert_called_once_with(role, plan if role == "driving" else None) + verify.assert_not_called() + activate.assert_not_called() assert runtime.prepare(role) is selected - assert activate.call_count == 1 + assert (activate.call_count if role == "driving" and family == "legacy9d" else native_prepare.call_count) == 1 + with pytest.raises(RuntimeError, match="cannot change its execution role"): + runtime.prepare("monitoring" if role == "driving" else "driving") def test_host_does_not_create_device_cache(): diff --git a/openpilot/starpilot/models/tests/test_shipped_default.py b/openpilot/starpilot/models/tests/test_shipped_default.py index 842613faf3..51006183cd 100644 --- a/openpilot/starpilot/models/tests/test_shipped_default.py +++ b/openpilot/starpilot/models/tests/test_shipped_default.py @@ -65,7 +65,8 @@ def test_big_default_disabled_and_explicit_download_preserved(tmp_path): def test_verified_download_precedes_shipped_default(tmp_path, monkeypatch): path = tmp_path / "download.pkl" - monkeypatch.setattr(manager, "catalog", lambda _: {DEFAULT_SMALL: {"artifact_sha256": "download-hash", "version": "v15"}}) + monkeypatch.setattr(manager, "catalog", lambda _: {DEFAULT_SMALL: {"artifact_sha256": "download-hash", "version": "v15", + "_runtime_family": "native02e"}}) monkeypatch.setattr(manager, "verified_artifact", lambda *args: path) fallback = tmp_path / "fallback.pkl" def verified_fallback(plan): diff --git a/prebuilt.json b/prebuilt.json index d7764d00e4..1796fecde6 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "17d6284308eb3d8e76211225eb215c60181dc700e1a1c68d14f906906a86b45e", "schema_version": 1} +{"protected_inventory_sha256": "fa4314474b7db3e6ffae318ed89afaaf1a14ae9044f3410e7c190ec09c2e7a36", "schema_version": 1}