diff options
| author | cirakg <cirakg@cirakg.xyz> | 2026-10-21 03:55:01 +0200 |
|---|---|---|
| committer | cirakg <cirakg@cirakg.xyz> | 2026-10-21 03:55:01 +0200 |
| commit | 88f1cac4fa530fc30fd6ef01970af11c7a959b8e (patch) | |
| tree | 4e2e52b36a6faa2dd50d3b6b07fbfe46fb5dc48c /tools/tests/test_gen_products.py | |
| parent | a69e23fb5266dd942d125239e7dcbe8a7c8ab956 (diff) | |
fix(codes): bound every 2D encoding step under the watchdog; draw large codes from runs
M6's step sizes were estimates, only exercised with small codes. With the
largest inputs the app accepts, every 2D encoder tripped the watchdog on
the Forerunner 255S (and the biggest steps were far over the 768 KB
watches' limit), so a large code added from the phone would have stopped
the app during settings processing at every start.
- QR: resumable segmentation, Reed-Solomon, interleaving, function
patterns and final mask; mask scoring on rows and columns packed 16
modules per word (same penalties, checked against the per-module rules).
- Reed-Solomon: resumable field tables and generator, encoder shifting
with native slice.
- Data Matrix, Aztec, PDF417: resumable encodation, stuffing, compaction,
placement and build; Data Matrix's grid as a byte array (90 KB -> 35 KB);
PDF417 refuses text that can't fit the screen before compacting.
- Cache format 2 with 16-bit sizes (wide PDF417 was cached wrong); packing
in steps; codes drawn as runs, and from a bitmap painted in steps when a
frame can't draw all runs.
- The job runner does two steps per tick on 768 KB watches;
gen_products --check verifies each product's watchdogCount fits that.
- CodeView renews full brightness (AMOLED) or the backlight (MIP) for up to
a minute from its single ticker; a tap restarts the minute.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/tests/test_gen_products.py')
| -rw-r--r-- | tools/tests/test_gen_products.py | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/tools/tests/test_gen_products.py b/tools/tests/test_gen_products.py index 47424d2..e57973f 100644 --- a/tools/tests/test_gen_products.py +++ b/tools/tests/test_gen_products.py @@ -1,5 +1,5 @@ # Author: cirakg & claude ai -# Summary: Tests for tools/gen_products.py (the manifest product rule). +# Summary: Tests for tools/gen_products.py (the manifest product rule and the watchdog the job runner assumes). """Tests for tools/gen_products.py, with synthetic device definitions.""" from __future__ import annotations @@ -17,6 +17,7 @@ MANIFEST = """<iq:manifest version="3" xmlns:iq="http://www.garmin.com/xml/conne def add_device(devices: Path, product: str, api: list[str], memory: int, group: str = gp.WATCH_GROUP) -> None: folder = devices / product folder.mkdir(parents=True) + set_watchdog(devices, product, gp.WATCHDOG_LARGE if memory > gp.LARGE_WATCH_MEMORY else gp.WATCHDOG_SMALL) compiler = { "displayName": product.upper(), "webDocDeviceGroup": group, @@ -26,6 +27,10 @@ def add_device(devices: Path, product: str, api: list[str], memory: int, group: (folder / "compiler.json").write_text(json.dumps(compiler)) +def set_watchdog(devices: Path, product: str, count: int) -> None: + (devices / product / "simulator.json").write_text(json.dumps({"watchdogCount": count})) + + def write_manifest(tmp_path: Path, products: list[str]) -> Path: path = tmp_path / "manifest.xml" path.write_text(MANIFEST.format(products="".join(f'<iq:product id="{p}"/>' for p in products))) @@ -55,9 +60,23 @@ def test_missing_device_files(tmp_path: Path) -> None: def test_problem_messages() -> None: - device = gp.Device("x", "X", "Edge", (4, 2, 0), 131072) + device = gp.Device("x", "X", "Edge", (4, 2, 0), 131072, 120000) assert device.problems() == [ "group is 'Edge', not 'Watches/Wearables'", "API 4.2.0 is below 5.0.0", "watch apps get 128 KB, below 512 KB", ] + + +def test_watchdog_must_match_the_job_runner(tmp_path: Path) -> None: + devices = tmp_path / "Devices" + add_device(devices, "big_slow", ["6.0.0"], 786432) + set_watchdog(devices, "big_slow", 120000) # would run 2 steps on 120,000 + add_device(devices, "small_fast", ["6.0.0"], 524288) + set_watchdog(devices, "small_fast", 240000) # fine: 1 step, more room + assert gp.check(write_manifest(tmp_path, ["small_fast"]), devices) == gp.EXIT_OK + assert gp.check(write_manifest(tmp_path, ["big_slow"]), devices) == gp.EXIT_UNQUALIFIED + problems = gp.load_device(devices, "big_slow").problems() + assert problems == [ + "watchdog allows 120000 bytecodes per event; the job runner needs 240000 at 768 KB (change Jobs.stepsPerTick)" + ] |
