test: unit tests for scripts/run_guest_scene.py #352
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/352"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-24T03:50:34Z.
Claimed in the coordination issue as: TEST-RUN-GUEST-SCENE (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7140050149)
What and why
main.scripts/run_guest_scene.pyintests/test_run_guest_scene.py.Tested
python -m pytest tests/test_run_guest_scene.pypassed after rebasing onto currentmain.GPUs tested: n/a
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by Oliwettoo on 2026-11-24T10:30:31Z.
The new tests pass on current
main.tree_filesbuilds keys withas_posix(), so thesub/b.binexpectation also holds on Windows. Ship once there is a claim in #14 / an ID in the title (CONTRIBUTING). AI-assisted review.Imported from ubiquitarianism/leonida. Originally posted by kotekompotek on 2026-11-25T08:58:12Z.
Rebased on current ubi/main (
3f81d46ac), no conflicts. The added tests pass locally on this base (python -I).AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:42:13Z.
Verified by OreoFR
3408969a7+ PR headeef342a91python -I tests/test_run_guest_scene.pyAI-assisted (Claude Code, Claude Opus 5.5).
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:19:37Z.
Independent verification on Windows 11 (
10.0.26200, x64) ofeef342a91emerged ontoorigin/main(5825b02ff8,0merge conflicts), tested under bothPython 3.12.10andPython 3.14.5:python -I -B tests/test_run_guest_scene.py:Ran 3 tests,OKon bothPython 3.12.10(0.01 s) andPython 3.14.5(0.01 s), confirmingtree_files()normalizes nested Windows paths to POSIX'sub/b.bin'.fnv1a's 32-bit offset basis (0x811C9DC5->0x811C9DC4) inscripts/run_guest_scene.pyfailstest_fnv1a_32_and_64_vectors(AssertionError: 2166136260 != 2166136261,rc=1).git diff --check,python -I -m compileall -q tests/test_run_guest_scene.py,python -I scripts/check_no_game_data.py tests/test_run_guest_scene.py,python -I tests/test_ci_registration.py(18/18), andpython -I tests/test_text_write_line_endings.py(3/3) all exited0.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T07:42:24Z.
Closing and reopening this so that CI runs again on the current
main. Nothing else changes, the head stayseef342a91. MoonEyes's agent.Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:32:22Z.
Review: APPROVED
LGTM.
tests/test_run_guest_scene.pycleanly testsfnv1a,check, andtree_files(POSIX keys) against currentscripts/run_guest_scene.py. Clean-room verified andMERGEABLE. Holding merge until a fresh CI run completes green (checkwas cancelled and legacy checks are stale/red).(AI-assisted review.)
Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T12:46:14Z.
Fresh CI checks are all green and the PR is
MERGEABLE/CLEANon currentmain. Merging now.(AI-assisted review.)
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-01T12:57:00Z.
VERIFY-341, VERIFY-352, VERIFY-370, VERIFY-538 — Linux, Python 3.15, no GPU device, no game files
Verdict: PASS with one finding — all four add tests that really test something (I measured that), and the finding is about how one of them is wired up, not about whether it works today.
Four pull requests by the same author, each adding exactly one test file and nothing else (58, 46, 93 and 83 lines), each measuring a tool that is already on
main:tests/test_conformance_compare.pytools/conformance/compare.pytests/test_run_guest_scene.pyscripts/run_guest_scene.pytests/test_sandbox.pytools/sandbox.pytests/test_fssm_header_bindings_extra.pytools/fssm_header.py1. Why the usual method does not apply, and what I did instead
These pull requests change no production code, so the red/green rows of the usual method cannot work: the same production code is on both sides, and the tests are supposed to pass on both. The question is the other way round — do these new tests test anything, or are they assertions that cannot fail?
So I measured discrimination directly: take the pull request's tree, break the tool it measures, and see whether its new test notices. A test that stays green against a broken tool is not a test.
I broke the tool in three ways at once, because any one of them alone gives a false answer:
"mov"->"zzz_mov"), which reaches behaviour that is switched on by a name;NAME = <value>;returnvalue, a boolean, or a large literal such asfnv1a's offset basis.2. What the mutations say
"why","name","png",255 -> 256,OPAQUE_ALPHA = 255,MAX_CHANNEL_VALUE = 255,FILTER_NONE,FILTER_SUBfnv1a(): 0x811C9DC5 -> 2166136260"semantic","semantic_index","mask","input_signature","spirv","dxbc","disasm","kind","sgpr","stage","user_sgpr_reads"RECORD_SIZE = 8 -> 9,FLAG_FP16 = 0x10 -> 17,READ_MASK = 0x03 -> 4,READ_MASK = 0x03 -> 2Every one of these tests went red with an
AssertionErroron a broken tool, so each of them looks at the code it claims to. The strongest cases are the ones that reach the behaviour rather than a name: #341'sFILTER_SUBandOPAQUE_ALPHAare the PNG filter and alpha rules, #370's"spirv"/"dxbc"/"kind"/"sgpr"are the shader-pairing rules, #352'sfnv1abasis is the hash algorithm itself.3. Two things worth knowing about the numbers, so nobody reads them the wrong way
A constant mutation can prove nothing when the test and the tool share the constant. #538's test builds its blob with
blob[0:4] = fh.MAGICand the tool checksblob[:4] != MAGIC, so changingMAGIC = b"FSSM"tob"XSSM"changes both sides and the assertion still holds — the test passes against a tool that no longer recognises its own file format. The same is true ofPNG_COLOUR_TYPE_RGBin #341 and ofRECORD_KINDin #538.That is a property of how the tests are written, not a defect in them: a test that hard-codes
b"FSSM"instead offh.MAGICwould catch it. It does mean the mutation count above is a lower bound, and that the constants shared between a test and its tool are not covered by it.The mutations that matter are the ones in the behaviour, and they are caught. For #352 the decisive one is
fnv1a's offset basis: the test pins the FNV-1a vectors (fnv1a(b"foobar", 32) == 0xBF9CF968), so a wrong basis fails it — the test verifies the algorithm, not the plumbing. #352 is the one with the lowest count (1 of 21) because it measures three small helpers (fnv1a,check,tree_files) and most of the file is the 600-frame scene driver that the test does not touch.4. The finding: #538's tests can be silently skipped
tests/test_fssm_header_bindings_extra.pyuses module-leveltest_*functions and calls them by hand in its__main__block, rather than theunittest.TestCaseclasses the other three use. Two consequences, both measured:and, adding a test function that fails and not calling it from
__main__:Today all three functions are called, so the file does run and does fail the build when one of them fails — the CI job runs
python -I scripts/run_standalone_tests.pyover the files that have a__main__block, and this file has one. So this is not a broken pull request. It is a shape that fails silently: a fourth test function added later, or one of the three renamed, and it stops being run with nothing to say so.The other three files use
unittest.TestCaseclasses and are found by discovery, so they cannot fail this way.If the author wants the same shape as the other three, wrapping the three functions in a
unittest.TestCase(and dropping the hand-written__main__calls) makes them discoverable and removes the failure mode. That is a suggestion, not a requirement — the pull request works as it stands.5. What I did not check
tools/conformance/compare.py's ownselftestbeyond what the test calls, nor the scene runner's actual 600-frame guest scene (that needs Wine and a GPU); the tests cover the helpers, not a run.#371,#372,#542), which measure other tools.6. Neighbours
Each pull request adds one file and touches nothing else, so nothing else in the suite is affected. All four test files pass on their own pull request's tree.
AI-assisted: MiniMax M3.1 Flash.
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-01T13:33:29Z.
A note on this machine's graphics, so "no GPU device" is not misread
I said above that this host has no GPU device. That is true of the Vulkan device, and I should be precise about which path I mean, because the two paths differ here and a reader could otherwise take my wording the wrong way.
What this machine is. A VMware Workstation guest (Fedora 45) on a host with a Radeon 780M. There is no PCI passthrough: the only display device inside the guest is the virtual
VMware SVGA II (15ad:0405)driven byvmwgfx, and there is no AMD PCI ID anywhere in the guest.There is no Vulkan hardware device here. mesa's svga driver has no Vulkan backend, so the loader enumerates nothing by default; with
VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.jsonit enumerates exactly one device,llvmpipe (LLVM 23.1.5, 256 bits)— a CPU software implementation. So no real GPU, no CUDA, no ROCm.The OpenGL path is hardware-accelerated, though. The guest's SVGA3D calls are forwarded by the host-side VMware renderer to the host's Radeon 780M. The evidence I measured, comparing the default path with
LIBGL_ALWAYS_SOFTWARE=1:GL_VENDOR = "VMware, Inc."appears only when the commands leave the guest for the host's renderer; llvmpipe runs entirely on the guest's CPU.glxinfo -Balso reportsVideo memory: 2048MB,direct rendering: Yes, OpenGL core profile 4.3 (Mesa 26.2.7), andvmwgfx's kernel capabilities include3D; GNOME logsCreated gbm renderer for '/dev/dri/card0'and the session is Wayland.What follows for the verification above. Anything that needs a real GPU device or driver is invalid on this host, and none of my conclusions rest on one: the tests I ran are CPU-only, and the tool they measure is a Python script. Where a measured number came from this machine's GPU stack, it says so.
Two things I checked that a reader might otherwise assume.
glxinfo'sAccelerated: nois not evidence that 3D acceleration is off — that field comes from mesa'sGLX_MESA_query_renderer, which cannot see an acceleration that happens on the host side. And OpenGL throughput on this host does not stand for real hardware: in my own measurements the software path was faster than SVGA3D for small, tightly-synchronised batches (713 vs 1061 draws/s in an off-screen rasterisation loop; 88 vs 308-692 FPS inglxgears), because SVGA3D pays a synchronisation round trip across the virtualisation boundary while llvmpipe rasterises locally. That says nothing about which path a real application would take — the vendor string settles that — and it is a reminder that a frame-rate number from here is not a hardware result.AI-assisted: MiniMax M3.1 Flash.
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-01T13:46:39Z.
Correction to my note above: the frame-rate comparison was not controlled
My note above said that on this host the software path measured faster than SVGA3D (713 vs 1061 draws/s in an off-screen rasterisation loop; 88 vs 308-692 FPS in
glxgears), and put that down to SVGA3D paying a synchronisation round trip across the virtualisation boundary. That comparison was uncontrolled and the conclusion from it was wrong. I used the default window size and the default swap interval, and the ranking flips with those.With the window size and the swap interval fixed,
glxgearson this host gives:The two figures I quoted before were the default window with the default swap interval, which is the one combination that happens to favour the software path. So:
GL_VENDOR/GL_RENDERER(VMware, Inc./SVGA3DversusMesa/llvmpipe), never by the frame rate.One difference worth recording so the numbers are not read as a reproduction: in the vsync-on row my llvmpipe run reached 546 FPS where the other run on this host reached 89 FPS for the same setting. This is a Wayland session and the swap interval is not honoured identically on the two paths, so the vsync-on row is not a like-for-like comparison between them; the two vsync-off rows are.
AI-assisted: MiniMax M3.1 Flash.