Skip to content

test: unit tests for tools/gen_gdk_runtime_classes.py - #340

Open
kotekompotek wants to merge 1 commit into
ProjectLeonida:mainfrom
kotekompotek:work/test-gen-gdk-runtime-classes
Open

kotekompotek wants to merge 1 commit into
ProjectLeonida:mainfrom
kotekompotek:work/test-gen-gdk-runtime-classes

Conversation

@kotekompotek

@kotekompotek kotekompotek commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST (#14 (comment))

What and why

  • Rebased onto current main.
  • Added unit tests for tools/gen_gdk_runtime_classes.py in tests/test_gen_gdk_runtime_classes.py.

Tested

  • python -m pytest tests/test_gen_gdk_runtime_classes.py passed after rebasing onto current main.

GPUs tested: n/a

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

demoz53 added a commit to demoz53/leonida that referenced this pull request Nov 24, 2026
@Oliwettoo

Copy link
Copy Markdown

The new tests pass on current main (python -I tests/test_gen_gdk_runtime_classes.py). Small nit: the tool prints 1 classes, 1 interfaces -> … into the test output; capturing stdout would keep CI logs clean. There is no claim for this in #14 and no ID in the title, which CONTRIBUTING asks for. AI-assisted review.

QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Indexes the DXBC identities the Xbox native graphics pipelines use, which the native-PSO path needs. The earlier hold (new tool not listed as a translator input) is fixed in 62a9588: native_pso_hashes is now in translator_deps.cmake, make_game.py's translation sources and runtime.yml.

**Why it's good:** Security read of the three-dot diff: tools and tests only, no binaries, downloads or network calls. The PR's own tests: 129 passed. The consistency set, which caught the missing input registration last time, is clean now.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Adds the named NonSemantic.Shader.DebugInfo.100 instruction table so SPIR-V debug instructions disassemble by name. Oliwettoo checked that the table matches SPIRV-Headers' grammar exactly (44 names).

**Why it's good:** Data table plus tests only. Its tests: 47 passed. No behaviour change for shaders without debug info.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** manifest_verifier refuses a --cache path that aliases the input manifest (another spelling, a hard link, a symlink or a case alias), which would otherwise overwrite the manifest: a real data-loss guard. Reviewed as good by Oliwettoo.

**Why it's good:** Its tests: 82 passed, 4 skipped. It merges cleanly together with #346, which touches the same tool; the cumulative run includes both. Note from Oliwettoo: this conflicts with #344, which will need a rebase.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** manifest_verifier also protects every file the manifest lists from being overwritten by cache writes (the companion to #334). Reviewed as good by Oliwettoo.

**Why it's good:** Its tests: 83 passed, 4 skipped, on its own and stacked with #334.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** CI-only: a hung Windows runtime test now fails on its own (per-test ctest --timeout 300, TIMEOUT 180 on the loader test) instead of cancelling the whole job, and the job limit goes from 20 to 35 minutes. Each value is explained in a comment. Reviewed as good by Oliwettoo.

**Why it's good:** Workflow change with no new permissions, actions or downloads. The local tests it touches: 87 passed, 9 skipped. The runner-side effect can only be seen in CI, but there's nothing risky in it: the timeouts only turn hangs into failures.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** d3d12_xs_surface SDK discovery skips a Windows Kits version folder that lacks um/d3d12.h (a WDK-only folder), while an explicit WINDOWS_SDK_INCLUDE/SDK_INCLUDE is still taken as given. Reviewed as good by Oliwettoo.

**Why it's good:** Its tests: 18 passed, 1 skipped. The runtime build on this machine is unaffected (same ctest).

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** stale_build follows includes through the CMake include directories, so a header change in another include dir correctly marks a target stale. Dezmonius independently re-checked the fixed head; the "six failures" he first reported were the new tests running against the old implementation, which is expected.

**Why it's good:** Its tests: 55 passed, 8 skipped, and on current main with main's new tests/test_stale_build.py: 26/26.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Fixes the mesh half of #506: the statistics pool active during vkCmdDrawMeshTasksEXT no longer enables the two clipping counters that VUID-vkCmdDrawMeshTasksEXT-pipelineStatistics-07076 forbids. Verified on an RTX 5070 Ti (sodove), RTX 4080 (quartz-heron-58) and RX 7900 XTX (bvtterbroot), all with validation on; the rebase to 916dbc6 is byte-identical (range-diff checked). Merged on its own first because #577 is stacked on it.

**Why it's good:** On the 4070 SUPER with LEONIDA_VK_VALIDATION=1: plain main fails d3d12_mesh with 3x VUID-...-07076; main + #540 + #577 passes d3d12_mesh, replay_query_edges and replay_query_predication with 0 validation errors, and the counters match sodove's numbers (mesh-only C 8/0, PS 1024).

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
QemmHD added a commit that referenced this pull request Nov 24, 2026
Merging.

**Why merged:** Stacked on #540: the clipping invocations of a mesh segment now come from a mesh-pipeline query, so CInvocations/CPrimitives stay correct for mixed vertex + mesh work. sodove verified the exact head, including the disconnected-feature negative control that found (and now proves fixed) a gap in the test.

**Why it's good:** The embedded SPIR-V in statistics_sum_spirv.h was recompiled from the PR's .comp: all 431 words are identical and spirv-val passes. d3d12_mesh with validation: 0 errors, mixed C 12 vs vertex-only C 2, so the mesh share is 10, as expected.

Tested on Windows 11, RTX 4070 SUPER (NVIDIA 621.24), VS 2022 + Ninja RelWithDebInfo, Vulkan SDK 1.4.363.0, alone on main (21625bc or 51f3160) and in a cumulative merge of #497, #278, #310, #334, #346, #340, #355, #361, #363, #620 and #577 (which carries #540) on main 2d73c24 (git merge-tree: 0 conflicts against current main). Repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests): 566 passed / 5 skipped / 0 failed on main and on main + batch. compileall OK. Full ctest: 302/304 on main and on main + batch (the same two pre-existing failures, d3d12_execute_indirect_validation and d3d12_depth_resolve, no new ones).

AI-assisted (Claude Code, Claude Opus 5.5).
@QemmHD

QemmHD commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Tested on Windows 11 / RTX 4070 SUPER against main 2d73c24: the new tests pass (30 passed), the repo-consistency set stays at 0 failures, and it merges cleanly, also stacked with this hour's batch. Security read of the diff: tests only, nothing else.

The one thing holding the merge is CONTRIBUTING: please post a claiming: <ID> in #14 and put the ID in the PR title (the same thing Oliwettoo asked for on #341/#351/#352). After that, it's ready to merge.

AI-assisted (Claude Code, Claude Opus 5.5).

@kotekompotek
kotekompotek force-pushed the work/test-gen-gdk-runtime-classes branch from 377c1f6 to eabae9e Compare November 24, 2026 15:21
@aslan2142 aslan2142 added missing claim Needs a claim in #14 and removed missing claim Needs a claim in #14 labels Nov 24, 2026
@kotekompotek
kotekompotek force-pushed the work/test-gen-gdk-runtime-classes branch from eabae9e to cab0e9a Compare November 25, 2026 08:57
@kotekompotek

Copy link
Copy Markdown
Contributor Author

Rebased on current ubi/main (3f81d46), no conflicts. The added tests pass locally on this base (python -I).

AI-assisted: yes

@OreoFR

OreoFR commented Nov 28, 2026

Copy link
Copy Markdown
Collaborator

Verified by OreoFR

  • Base: main 3408969a7 + PR head cab0e9a59
  • Test: python -I tests/test_gen_gdk_runtime_classes.py
  • Red on main: 6 OK
  • Green with the PR: 6 OK
  • Verdict: NO RED (test-only PR)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

@zmasi

zmasi commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Independent verification on Windows 11 (10.0.26200, x64) of cab0e9a59c merged onto origin/main (59e65849b0, 0 merge conflicts), tested under both Python 3.12.10 and Python 3.14.5:

  • Suite results:
    • python -I -B tests/test_gen_gdk_runtime_classes.py: Ran 6 tests, OK on both Python 3.12.10 (0.46 s) and Python 3.14.5 (0.15 s).
  • Hygiene: git diff --check, python -I -m compileall -q tests/test_gen_gdk_runtime_classes.py, python -I scripts/check_no_game_data.py tests/test_gen_gdk_runtime_classes.py, python -I tests/test_ci_registration.py (18/18), and python -I tests/test_text_write_line_endings.py (3/3) all exited 0.

AI-assisted.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 29, 2026

@aslan2142 aslan2142 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Conflicts with main: tests/test_gen_gdk_runtime_classes.py already exists on main (atomic-write tests). Your parse_layout/parse_docs/check tests are distinct and valuable — please rebase onto current main, merge these test classes into the existing tests/test_gen_gdk_runtime_classes.py, and trigger a fresh green CI run. (Small optional nit: redirecting stdout around gen.main in tests/test_gen_gdk_runtime_classes.py:121 keeps CI output quiet.)

(AI-assisted review.)

@imShangLi

Copy link
Copy Markdown
Contributor

VERIFY-371, VERIFY-372, VERIFY-495, VERIFY-340 — Linux, Python 3.15, no GPU device, no game files

Verdict: PASS — all four add tests that test something (I measured that), and one of them has a suggestion attached that is not a defect.

Four more pull requests by the same author as #341/#352/#370/#538, each adding exactly one test file and no production code:

PR test file measures
#340 tests/test_gen_gdk_runtime_classes.py tools/gen_gdk_runtime_classes.py
#371 tests/test_shaders_check.py runtime/test/shaders/check.py
#372 tests/test_shaders_build.py runtime/test/shaders/build.py
#495 tests/test_file_mode_extra.py tools/file_mode.py

1. Why the usual method does not apply, and what I did instead

These change no production code, so the red/green rows cannot work: the same production code is on both sides and the tests are meant 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 broke the tool each test measures and saw whether the test noticed.

The kind of mutation that works depends on the module, and getting that wrong is how a "0 caught" reading turns out to be a measurement artefact rather than a finding:

  • tools/sandbox.py, tools/conformance/compare.py, tools/fssm_header.py — behaviour switched by a name or a constant: changing string literals and module constants reaches it.
  • tools/cfg_structure.py, tools/gen_gdk_runtime_classes.py — control-flow algorithms with no constants and no literals: the comparisons themselves are the behaviour, so I flipped comparison operators (== to !=, < to >, …).
  • tools/file_mode.py — permission bits and os calls only: nothing to flip, so I changed the octal literals themselves.

One trap worth recording: the mutations have to be restricted to the functions the test actually calls, and the line numbers must come from the pull request's own copy of the file, not from main's. #371's check.py is 2309 lines in its branch and 2434 on main, so a line range taken from main selects nothing and the mutation count comes out as zero.

2. What the mutations say

PR mutations caught the ones caught
#340 1 1 parse_docs: == -> !=
#371 3 1 complete_build_dirs: == -> !=
#372 2 2 both < -> > in gpu_fallback_flags
#495 5 0 — (see below)

Every caught one went red with an AssertionError, so each of these tests looks at the code it claims to.

3. #495: a weak assertion, and why it is not a defect

tests/test_file_mode_extra.py asserts the permission bits like this:

mode = file_mode.new_file_mode(tmp)
self.assertEqual(calls, 3)
self.assertEqual(mode & ~0o777, 0)

mode & ~0o777 == 0 says only that the mode carries no setuid, setgid or sticky bit — it says nothing about the permission bits themselves. I broke the probe's creation mode in tools/file_mode.py and the new test noticed none of it:

probe mode changed to tests/test_file_mode_extra.py tests/test_file_mode.py (already on main)
0o111 exit 0 — not noticed exit 1 — noticed
0o660 exit 0 — not noticed exit 1 — noticed
0o000 exit 0 — not noticed —

This is not a coverage hole, and that is the important part: main already carries tests/test_file_mode.py, and its test_new_file_mode_follows_the_current_umask asserts the exact bits (assertEqual(file_mode.new_file_mode(directory), 0o640) under umask 0o027), so every one of those breaks is caught there. #495 is not claiming to cover the bits; it covers the probe retry, the retry exhaustion and the fallback when the target is missing, which main's file does not.

So the only thing worth saying to the author is a suggestion: self.assertEqual(mode & ~0o777, 0) would be a stronger test as self.assertEqual(mode & 0o777, 0o644 & ~umask) — or simply by not asserting the bits at all and leaving that to the file on main, since what this pull request is about is the retry path. Either is fine; the test is not wrong as it stands.

4. What I did not check

  • I did not run the real work these tools do: runtime/test/shaders/check.py drives the shader test programs and build.py reads assembly files, so the tests cover the helpers (complete_build_dirs, resolve_build_dir, asm_mattr, asm_fssm, cs_fssm_extra, shader_source), not a shader build. gen_gdk_runtime_classes.py is exercised against synthetic layout text, not the real docs/ tree.
  • The mutation counts are for the mutations I generated, not an exhaustive mutation score.
  • tools/cfg_structure.py has while loops whose conditions I flipped; a flipped loop condition can make the module not terminate. I treat such a mutation as caught — a change that hangs the tool has changed its behaviour — and the test run for it is bounded by a timeout.

5. Neighbours

Each pull request adds one file and touches nothing else. All four test files pass on their own pull request's tree.

AI-assisted: MiniMax M3.1 Flash.

@merzleckeier

Copy link
Copy Markdown
Contributor

I resolved the current add/add conflict locally at cab0e9a5 + b3910e5e, keeping main's three atomic-output tests and all six tests from this PR in the same file. All nine pass with python -I tests/test_gen_gdk_runtime_classes.py on Python 3.14.10.

As a separate negative control for the added layout coverage, I made parse_layout skip *unknown* rows instead of retaining the empty method slot. Only the new test_parses_methods_and_unknown_slots went red. Restoring the generator returned the combined suite to green. This complements the earlier parse_docs mutation. The merge resolution needs only the test file. MEASURED, AI-assisted (Codex).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants