tests: add D3D12 and xmem lease tests for xmem_section_buffer.h #3683

Manually merged
github merged 1 commit from github-bot/gh-3681 into main 2026-12-02 02:13:59 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-12-01 01:10 UTC · original
Ammmae0x:tests/startup-xmem-section-buffer → main · +1129 −0 · 5 files · 1 commits · merged 2026-12-02 02:08 UTC

Refs #1149

x2w_startup::XMemSectionBuffer (src/startup_stubs/xmem_section_buffer.h) was untested directly in tests/. This adds D3D12 + xmem lease tests for it with zero modifications to existing files (5 new files, +1129/−0; header and device code untouched).

What landed

  • tests/startup_xmem_section_buffer_check.cpp — <warp|hardware> <xmem.dll> [<case>], honors XBOX2WINDOWS_ADAPTER, exits 77 only when no hardware adapter is available (or the device lacks existing-heaps support), never skips WARP. The check never links the shim: the DLL path is passed as argv[2], so the missing-DLL case runs before LoadLibraryW. 13 cases: missing-DLL, null device, zero address, zero size, overflowing range, wrong lease version, CPU address, range crossing into an unmapped page, accept refusal (destructor must release the pinned lease), stale-match refusal (accept unmaps the mirrored pages; the final matches(address) must refuse), reopen refusal (first buffer, GPU address and lease untouched), and valid single-page (first_byte 0xf000) and multi-page (first_byte 0xf800, crossing the page boundary) leases with GPU fill/readback, exactly-once destructor release and re-acquire after release. A merely unaligned start is valid; the class has no release() method, so idempotence is checked through the shim (a second release refuses).
  • tests/cmake/startup_xmem_section_buffer.cmake — _warp/_hardware tests (TIMEOUT 60, SKIP_RETURN_CODE 77) plus 5 WILL_FAIL TRUE configure-time header mutation controls mirroring era_physical_owns_last_page_control.
  • tests/startup_xmem_section_buffer_meta_check.py + tests/checks/python-linux/startup_xmem_section_buffer.txt — Linux contract audit plus a Python transliteration of open() and its destructor: 13 cases, 5/5 mutations killed. A scratch-copy self-audit of the meta check itself is killed 6/6 with exact FAIL: messages.
  • docs/experiments/startup-xmem-section-buffer.md — cases, controls, and the Windows run.

Mutation controls

Control Targeted edit Control case
startup_xmem_section_buffer_accept_mut drops || !accept(lease) refuse_accept
startup_xmem_section_buffer_matches_mut drops && matches(address) refuse_stale_match
startup_xmem_section_buffer_reopen_mut if (lease.id || !device becomes if (!device refuse_reopen
startup_xmem_section_buffer_destructor_mut release_(version_, lease.id) becomes false refuse_accept
startup_xmem_section_buffer_bytes_mut bytes_ = bytes becomes bytes_ = 0 valid_single_page

refuse_accept kills two mutants through different assertions: the accept mutant makes open() succeed, while the destructor mutant leaves the lease pinned after destruction. The early guards have no mutant of their own: dropping any of them does not flip its case, because the shim pin refuses the same range afterwards, so those guards are defence in depth and their cases pin the refusal.

Linux verification (worktree on origin/main a3bfd019)

  • Meta check: PASS: startup xmem section buffer: 13 cases, 5/5 mutations killed
  • run_checks_parallel.py --from-dir tests/checks/python-linux (workflow list): all 285 checks passed
  • Form coverage, docs links (195 files / 755 links), bidi controls (2775 files): pass
  • py_compile, diff --check clean, merge-tree exits 0, zero personal paths
  • All 5 CMake fragment replacements verified to apply to the real header (each anchor occurs exactly once); no mingw on this host, so no Windows compile check

Windows Verification (16f36ec2f966565fceed8b94418e6c2787dfaa6b)

Commit: 16f36ec2f966565fceed8b94418e6c2787dfaa6b (merge-tree upstream/main HEAD -> ef40f189, exit 0; git diff --check clean)
Adapter: NVIDIA GeForce RTX 4050 Laptop GPU (vendor=10de device=28e1, XBOX2WINDOWS_ADAPTER=NVIDIA) and WARP
dev: cmake --build --preset dev --target xmem_shim startup_xmem_section_buffer_check ... && ctest --preset dev --no-tests=error -R '^startup_xmem_section_buffer' --output-on-failure -> 7/7 passed (2.07s; warp 0.24s, hardware 0.92s, 13/13 cases, 5/5 mutations killed)
release: cmake --build --preset release --target xmem_shim startup_xmem_section_buffer_check ... && ctest --preset release --no-tests=error -R '^startup_xmem_section_buffer' --output-on-failure -> 7/7 passed (1.82s; warp 0.31s, hardware 0.36s, 13/13 cases, 5/5 mutations killed)
Checks: startup_xmem_section_buffer_meta_check.py (13 cases, 5/5 mutations killed), form_coverage_check.py, docs_links_check.py (196 files, 760 links), bidi_controls_check.py (2778 files) -> passed

AI-assisted.

**@⁠Ammmae0x** on GitHub · 2026-12-01 01:10 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3681) `Ammmae0x:tests/startup-xmem-section-buffer` → `main` · +1129 −0 · 5 files · 1 commits · merged 2026-12-02 02:08 UTC Refs #1149 `x2w_startup::XMemSectionBuffer` (`src/startup_stubs/xmem_section_buffer.h`) was untested directly in `tests/`. This adds D3D12 + xmem lease tests for it with zero modifications to existing files (5 new files, +1129/−0; header and device code untouched). **What landed** - `tests/startup_xmem_section_buffer_check.cpp` — `<warp|hardware> <xmem.dll> [<case>]`, honors `XBOX2WINDOWS_ADAPTER`, exits 77 only when no hardware adapter is available (or the device lacks existing-heaps support), never skips WARP. The check never links the shim: the DLL path is passed as argv[2], so the missing-DLL case runs before `LoadLibraryW`. 13 cases: missing-DLL, null device, zero address, zero size, overflowing range, wrong lease version, CPU address, range crossing into an unmapped page, accept refusal (destructor must release the pinned lease), stale-match refusal (accept unmaps the mirrored pages; the final `matches(address)` must refuse), reopen refusal (first buffer, GPU address and lease untouched), and valid single-page (`first_byte 0xf000`) and multi-page (`first_byte 0xf800`, crossing the page boundary) leases with GPU fill/readback, exactly-once destructor release and re-acquire after release. A merely unaligned start is valid; the class has no `release()` method, so idempotence is checked through the shim (a second release refuses). - `tests/cmake/startup_xmem_section_buffer.cmake` — `_warp`/`_hardware` tests (`TIMEOUT 60`, `SKIP_RETURN_CODE 77`) plus 5 `WILL_FAIL TRUE` configure-time header mutation controls mirroring `era_physical_owns_last_page_control`. - `tests/startup_xmem_section_buffer_meta_check.py` + `tests/checks/python-linux/startup_xmem_section_buffer.txt` — Linux contract audit plus a Python transliteration of `open()` and its destructor: 13 cases, 5/5 mutations killed. A scratch-copy self-audit of the meta check itself is killed 6/6 with exact `FAIL:` messages. - `docs/experiments/startup-xmem-section-buffer.md` — cases, controls, and the Windows run. **Mutation controls** | Control | Targeted edit | Control case | | --- | --- | --- | | `startup_xmem_section_buffer_accept_mut` | drops ` \|\| !accept(lease)` | `refuse_accept` | | `startup_xmem_section_buffer_matches_mut` | drops ` && matches(address)` | `refuse_stale_match` | | `startup_xmem_section_buffer_reopen_mut` | `if (lease.id \|\| !device` becomes `if (!device` | `refuse_reopen` | | `startup_xmem_section_buffer_destructor_mut` | `release_(version_, lease.id)` becomes `false` | `refuse_accept` | | `startup_xmem_section_buffer_bytes_mut` | `bytes_ = bytes` becomes `bytes_ = 0` | `valid_single_page` | `refuse_accept` kills two mutants through different assertions: the accept mutant makes `open()` succeed, while the destructor mutant leaves the lease pinned after destruction. The early guards have no mutant of their own: dropping any of them does not flip its case, because the shim pin refuses the same range afterwards, so those guards are defence in depth and their cases pin the refusal. **Linux verification (worktree on `origin/main` `a3bfd019`)** - Meta check: `PASS: startup xmem section buffer: 13 cases, 5/5 mutations killed` - `run_checks_parallel.py --from-dir tests/checks/python-linux` (workflow list): all 285 checks passed - Form coverage, docs links (195 files / 755 links), bidi controls (2775 files): pass - `py_compile`, `diff --check` clean, `merge-tree` exits 0, zero personal paths - All 5 CMake fragment replacements verified to apply to the real header (each anchor occurs exactly once); no mingw on this host, so no Windows compile check ### Windows Verification (`16f36ec2f966565fceed8b94418e6c2787dfaa6b`) ```text Commit: 16f36ec2f966565fceed8b94418e6c2787dfaa6b (merge-tree upstream/main HEAD -> ef40f189, exit 0; git diff --check clean) Adapter: NVIDIA GeForce RTX 4050 Laptop GPU (vendor=10de device=28e1, XBOX2WINDOWS_ADAPTER=NVIDIA) and WARP dev: cmake --build --preset dev --target xmem_shim startup_xmem_section_buffer_check ... && ctest --preset dev --no-tests=error -R '^startup_xmem_section_buffer' --output-on-failure -> 7/7 passed (2.07s; warp 0.24s, hardware 0.92s, 13/13 cases, 5/5 mutations killed) release: cmake --build --preset release --target xmem_shim startup_xmem_section_buffer_check ... && ctest --preset release --no-tests=error -R '^startup_xmem_section_buffer' --output-on-failure -> 7/7 passed (1.82s; warp 0.31s, hardware 0.36s, 13/13 cases, 5/5 mutations killed) Checks: startup_xmem_section_buffer_meta_check.py (13 cases, 5/5 mutations killed), form_coverage_check.py, docs_links_check.py (196 files, 760 links), bidi_controls_check.py (2778 files) -> passed ``` AI-assisted. <!-- WIN-VERIFY: passed | sha=16f36ec2f966565fceed8b94418e6c2787dfaa6b | targets=startup_xmem_section_buffer_check startup_xmem_section_buffer_accept_mut startup_xmem_section_buffer_matches_mut startup_xmem_section_buffer_reopen_mut startup_xmem_section_buffer_destructor_mut startup_xmem_section_buffer_bytes_mut | ctest=^startup_xmem_section_buffer | release=true -->
Refs #1149

Add D3D12 + xmem lease tests for x2w_startup::XMemSectionBuffer with
zero modifications to existing files: a C++ check covering the early
guards, missing-DLL, accept and stale-match refusals, the reopen
refusal, and valid single/multi-page leases with GPU fill/readback,
exactly-once destructor release and re-acquire after release; a CMake
fragment registering warp/hardware tests plus five WILL_FAIL TRUE
mutation controls; a Linux meta check (13 cases, 5/5 mutations killed);
and a note. Linux: meta check passes, run_checks_parallel 285/285,
form/docs/bidi pass, diff --check clean.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 01:13:10 +00:00
github manually merged commit 0b14fcf153 into main 2026-12-02 02:13:59 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.