mirror of
https://github.com/MCKero6423/uv-k5-v3-emulator.git
synced 2026-10-02 03:15:36 +00:00
The page only knew its own input. A build called f4hwn.fusion.bin reports EGZUMER+F4HWN v6.0.0.CN, and with the multi-system release a committed external slot makes the factory bootloader reflash the internal flash from that slot on every power-on -- so the uploaded image never runs and the page keeps naming it. The firmware prints its own banner on USART1; tools/uvk5_banner.py reads it back, /api/firmware returns running: {banner, matches_uploaded, note}, and the page shows what the device reports, flagging it only when the running version is not in the uploaded image at all.
That reader also exposed a regression of my own: _start_stderr_pump had been rewritten to read the pipe in 64 KB chunks, which kept QEMU from blocking but delivered nothing to the log until 64 KB had accumulated -- and the banner is forty bytes, so it never appeared. It reads lines again, still starting before anything waits on QEMU, and test_uvk5_supervisor passes either way.
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""The page must report what the device says, not what it was asked to boot."""
|
|
import os
|
|
import tempfile
|
|
import unittest
|
|
|
|
import uvk5_banner
|
|
|
|
|
|
class TestBanner(unittest.TestCase):
|
|
def test_it_finds_the_last_banner(self):
|
|
lines = ["[qemu] SERIAL booting", "[qemu] SERIAL UV-K5 Firmware, EGZUMER+F4HWN v6.0.0.CN",
|
|
"[qemu] SERIAL noise", "[qemu] SERIAL UV-K5 Firmware, EGZUMER+F4HWN v5.9.0.CN"]
|
|
self.assertEqual(uvk5_banner.latest(lines), "EGZUMER+F4HWN v5.9.0.CN")
|
|
|
|
def test_no_banner_is_not_a_banner(self):
|
|
self.assertIsNone(uvk5_banner.latest(["[qemu] SERIAL nothing to see", ""]))
|
|
|
|
def test_a_name_that_differs_from_the_banner_is_not_a_mismatch(self):
|
|
"""f4hwn.fusion.bin legitimately reports v6.0.0.CN -- the string is in the file."""
|
|
path = os.path.join(tempfile.mkdtemp(), "f4hwn.fusion.bin")
|
|
with open(path, "wb") as fh:
|
|
fh.write(b"\x00" * 32 + b"EGZUMER+F4HWN v6.0.0.CN" + b"\x00" * 32)
|
|
self.assertTrue(uvk5_banner.image_mentions(path, "EGZUMER+F4HWN v6.0.0.CN"))
|
|
|
|
def test_a_banner_the_image_does_not_contain_is_a_mismatch(self):
|
|
"""This is the 'the bootloader restored a slot instead' case."""
|
|
path = os.path.join(tempfile.mkdtemp(), "wanted.bin")
|
|
with open(path, "wb") as fh:
|
|
fh.write(b"\x00" * 64 + b"EGZUMER+F4HWN v5.9.0.CN" + b"\x00" * 64)
|
|
self.assertFalse(uvk5_banner.image_mentions(path, "EGZUMER+F4HWN v6.0.0.CN"))
|
|
|
|
def test_a_missing_file_does_not_accuse_anything(self):
|
|
self.assertTrue(uvk5_banner.image_mentions("/nonexistent/fw.bin", "anything"))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|