#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Representative experiments preserve the full release target set.""" import copy import importlib.util import json from pathlib import Path import unittest ROOT = Path(__file__).resolve().parent spec = importlib.util.spec_from_file_location("experiment_priority", ROOT / "experiment_priority.py") priority = importlib.util.module_from_spec(spec) spec.loader.exec_module(priority) MATRIX = json.loads((ROOT / "conformance.json").read_text()) QUEUE = json.loads((ROOT / "experiment-queue.json").read_text()) class ExperimentPriorityTest(unittest.TestCase): def test_local_boot_model_ranks_first_without_reducing_gate(self): ordered = priority.rank(MATRIX, QUEUE) self.assertEqual(ordered[0]["id"], "am335x-original-nand-boot") self.assertEqual(ordered[0]["affected_release_cells"], 13) self.assertEqual(len(MATRIX["targets"]), 64) self.assertEqual(next(row for row in ordered if row["id"] == "bm1368-command-and-nonce") ["affected_release_cells"], 4) def test_no_selector_or_unexplained_blocker(self): queue = copy.deepcopy(QUEUE) queue["experiments"][0]["board"] = None with self.assertRaisesRegex(ValueError, "no target selector"): priority.rank(MATRIX, queue) queue = copy.deepcopy(QUEUE) queue["experiments"][1]["blocker"] = None with self.assertRaisesRegex(ValueError, "lacks a blocker"): priority.rank(MATRIX, queue) if __name__ == "__main__": unittest.main()