test: add STEP-119 RCRR boundary variants and audit
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
Some checks failed
validate-scripts / validate-scripts (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
#!/usr/bin/env python3
|
||||
"""STEP-119 RCRR 验证器结构契约测试;合成样本不代表真机 GTest 或 GPU PASS。"""
|
||||
import importlib.util
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
MODULE = Path(__file__).with_name("verify_step113_fast_path.py")
|
||||
spec = importlib.util.spec_from_file_location("step113", MODULE)
|
||||
verifier = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(verifier)
|
||||
|
||||
|
||||
def sample(retained):
|
||||
return {
|
||||
"planValid": True,
|
||||
"basePreserved": False,
|
||||
"tideLayerExcluded": True,
|
||||
"originalBaseLayerCount": 63,
|
||||
"effectiveBaseLayerCount": 62,
|
||||
"excludedLayerId": "tide-spots",
|
||||
"excludedLayerSource": "tide",
|
||||
"excludedLayerCount": 1,
|
||||
"actualLayers": 64,
|
||||
"commands": {"emptyBuiltinAnnotationLayerRemoved": True,
|
||||
"annotationSourcePreserved": True},
|
||||
"sources": [{"sourceId": "navsea_delivery"},
|
||||
{"sourceId": "rn-weather-fields"}],
|
||||
"retained": retained,
|
||||
}
|
||||
|
||||
|
||||
def regions(r0_end, r2_start):
|
||||
return [
|
||||
{"begin": 0, "end": r0_end},
|
||||
{"begin": r2_start, "end": 63},
|
||||
{"begin": 63, "end": 64},
|
||||
]
|
||||
|
||||
|
||||
class Step119RcrrVerifierTests(unittest.TestCase):
|
||||
def test_three_rcrr_shapes_have_distinct_expected_boundaries(self):
|
||||
shapes = {
|
||||
"RCRR_C_NARROW_NO_TIDE": regions(31, 33),
|
||||
"RCRR_C_WIDE_NO_TIDE": regions(2, 38),
|
||||
"RCRR_R_DYNAMIC_NO_TIDE": regions(33, 38),
|
||||
}
|
||||
for scenario, retained in shapes.items():
|
||||
with self.subTest(scenario=scenario):
|
||||
self.assertTrue(verifier.scene_parity_valid(sample(retained), scenario))
|
||||
for other in shapes:
|
||||
if other != scenario:
|
||||
self.assertFalse(verifier.scene_parity_valid(sample(retained), other))
|
||||
|
||||
def test_missing_source_or_annotation_policy_never_passes(self):
|
||||
for scenario, retained in [
|
||||
("RCRR_C_NARROW_NO_TIDE", regions(31, 33)),
|
||||
("RCRR_C_WIDE_NO_TIDE", regions(2, 38)),
|
||||
("RCRR_R_DYNAMIC_NO_TIDE", regions(33, 38)),
|
||||
]:
|
||||
with self.subTest(scenario=scenario):
|
||||
a = sample(retained)
|
||||
a["sources"].append({"sourceId": "tide"})
|
||||
self.assertFalse(verifier.scene_parity_valid(a, scenario))
|
||||
b = sample(retained)
|
||||
b["commands"]["emptyBuiltinAnnotationLayerRemoved"] = False
|
||||
self.assertFalse(verifier.scene_parity_valid(b, scenario))
|
||||
|
||||
def test_wrong_final_extent_and_wrong_retained_count_rejected(self):
|
||||
a = sample(regions(31, 33))
|
||||
a["retained"][-1]["end"] = 65
|
||||
self.assertFalse(verifier.scene_parity_valid(a, "RCRR_C_NARROW_NO_TIDE"))
|
||||
b = sample(regions(31, 33)[:2])
|
||||
self.assertFalse(verifier.scene_parity_valid(b, "RCRR_C_NARROW_NO_TIDE"))
|
||||
|
||||
def test_existing_static_no_tide_contract_preserved(self):
|
||||
a = sample([{"begin": 0, "end": 62}])
|
||||
self.assertTrue(verifier.scene_parity_valid(a, "STATIC_RC_NO_TIDE"))
|
||||
self.assertFalse(verifier.scene_parity_valid(a, "RCRR_C_NARROW_NO_TIDE"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main(verbosity=2)
|
||||
@@ -18,7 +18,10 @@ APK = ARTIFACTS / "MapLibreAndroidTestApp-validation-opengl-debug-x86_64.apk"
|
||||
BUILD_INFO = ARTIFACTS / "build-info.txt"
|
||||
PACKAGE = "org.maplibre.android.testapp"
|
||||
ACTIVITY = f"{PACKAGE}/{PACKAGE}.activity.particle.ParticleCoreLayerValidationActivity"
|
||||
SCENARIOS = ("STATIC_RC", "PBF63", "PARTICLE_OFF", "PARTIAL_RCRR", "SOURCE_CHANGE", "STATIC_RC_NO_TIDE")
|
||||
SCENARIOS = ("STATIC_RC", "PBF63", "PARTICLE_OFF", "PARTIAL_RCRR", "SOURCE_CHANGE", "STATIC_RC_NO_TIDE",
|
||||
"RCRR_C_NARROW_NO_TIDE", "RCRR_C_WIDE_NO_TIDE", "RCRR_R_DYNAMIC_NO_TIDE")
|
||||
NO_TIDE_SCENARIOS = {"STATIC_RC_NO_TIDE", "RCRR_C_NARROW_NO_TIDE",
|
||||
"RCRR_C_WIDE_NO_TIDE", "RCRR_R_DYNAMIC_NO_TIDE"}
|
||||
LOG_ENTRY = re.compile(r"^[A-Z]/STEP113Gate\(\s*(\d+)\):\s*(\{.+\})\s*$")
|
||||
|
||||
|
||||
@@ -106,6 +109,24 @@ def extract(logcat, pid, expected):
|
||||
return [x[1] for x in sorted(result, key=lambda item: item[0])]
|
||||
|
||||
|
||||
def rcrr_segments_valid(sample, scenario):
|
||||
"""Verify exact R/C boundaries in the new isolated, 64-layer PBF Test App cases."""
|
||||
retained = sample.get("retained", [])
|
||||
if len(retained) != 3:
|
||||
return False
|
||||
r0, r2, r3 = retained
|
||||
if (r0.get("begin") != 0 or r2.get("end") != r3.get("begin")
|
||||
or r3.get("end") != 64 or r3.get("begin") != 63):
|
||||
return False
|
||||
if scenario == "RCRR_C_NARROW_NO_TIDE":
|
||||
return r0.get("end") == 31 and r2.get("begin") == 33
|
||||
if scenario == "RCRR_C_WIDE_NO_TIDE":
|
||||
return r0.get("end") == 2 and r2.get("begin") == 38
|
||||
if scenario == "RCRR_R_DYNAMIC_NO_TIDE":
|
||||
return r0.get("end") == 33 and r2.get("begin") == 38
|
||||
return False
|
||||
|
||||
|
||||
def scene_parity_valid(sample, scenario):
|
||||
"""Fail closed on the *declared* base style, not just a loose layer count.
|
||||
|
||||
@@ -117,7 +138,7 @@ def scene_parity_valid(sample, scenario):
|
||||
"""
|
||||
if not sample.get("planValid"):
|
||||
return False
|
||||
if scenario != "STATIC_RC_NO_TIDE":
|
||||
if scenario not in NO_TIDE_SCENARIOS:
|
||||
return sample.get("basePreserved") is True and not sample.get("tideLayerExcluded", False)
|
||||
return (
|
||||
sample.get("basePreserved") is False
|
||||
@@ -131,9 +152,16 @@ def scene_parity_valid(sample, scenario):
|
||||
and sample.get("commands", {}).get("emptyBuiltinAnnotationLayerRemoved") is True
|
||||
and sample.get("commands", {}).get("annotationSourcePreserved") is True
|
||||
and all(source.get("sourceId") != "tide" for source in sample.get("sources", []))
|
||||
and len(sample.get("retained", [])) == 1
|
||||
and sample["retained"][0].get("begin") == 0
|
||||
and sample["retained"][0].get("end") == 62
|
||||
and sample.get("actualLayers") == 64
|
||||
and (
|
||||
(scenario == "STATIC_RC_NO_TIDE" and
|
||||
len(sample.get("retained", [])) == 1 and
|
||||
sample["retained"][0].get("begin") == 0 and
|
||||
sample["retained"][0].get("end") == 62)
|
||||
or
|
||||
(scenario != "STATIC_RC_NO_TIDE" and
|
||||
rcrr_segments_valid(sample, scenario))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -222,7 +250,7 @@ def run():
|
||||
"sourceReport": (
|
||||
"STEP-118 user-approved TEST-APP-ONLY 62-layer derivative; "
|
||||
"original 63-layer PBF Style remains unmodified; not STEP-114 smoke"
|
||||
if args.scenario == "STATIC_RC_NO_TIDE"
|
||||
if args.scenario in NO_TIDE_SCENARIOS
|
||||
else "STEP-113 original 63-layer PBF test scene; not STEP-114 smoke"
|
||||
),
|
||||
"durationSecondsRequested": args.seconds,
|
||||
|
||||
Reference in New Issue
Block a user