tests: cover descriptor heap handle matching and boundary fallback #3860

Manually merged
github merged 2 commits from github-bot/gh-3858 into gh-pr/3858/base 2026-12-02 15:50:28 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-12-02 14:09 UTC · original
Ammmae0x:tests/descriptor-heap-match-unit → main · +1094 −0 · 5 files · 2 commits · merged 2026-12-02 15:45 UTC

Refs #1149

Portable C++17 unit and header-mutation tests for x2w_startup::match_descriptor_heap (src/startup_stubs/descriptor_heap_match.h), matching tests/cmake/logical_view_table_unit.cmake. The source is unchanged; only 5 new files are added (+1094/-0), and the existing tests/startup_descriptor_heap_match_check.cpp coverage is untouched. The new check uses the disjoint descriptor_heap_match_unit prefix so test names do not collide.

What landed

  • tests/descriptor_heap_match_unit_check.cpp — 10 cases, header-only against src, no device, no loader, no title data. A functor span callback (not a lambda) with static constexpr shared constants; a heap whose span callback returns false writes a span that would match and returns false, so a lookup that ignored the return value is caught.
  • tests/cmake/descriptor_heap_match_unit.cmake — one CTest test per case plus descriptor_heap_match_unit_all, and 5 WILL_FAIL TRUE controls (BEFORE PRIVATE mutated header copies, 1:1 with the meta check).
  • tests/descriptor_heap_match_unit_meta_check.py — audits the contract, compiles and runs the real C++ check and every mutation natively with g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror (or cl with /W4).
  • tests/checks/python-linux/descriptor_heap_match_unit.txt — lists exactly the meta check.
  • docs/experiments/descriptor-heap-match-unit.md — cases, controls, and verification.

Cases

  • empty_count: empty list matches nothing and never invokes span; heap_count == 0 matches nothing despite a matching heap; heap_count truncates the search.
  • span_false: a heap with no span matches nothing at its start or off its boundary; a span-less newest/oldest heap defers without adding a boundary match.
  • zero_increment: increment 0 never matches (and never divides); increment 1 matches every handle on a boundary.
  • handle_below_start: a handle below a start matches nothing; a handle below the newest heap still matches an older heap whose span holds it.
  • count_boundary: offset / increment == count - 1 matches, == count (and count + 1) does not; count 1 matches only its start; count 0 matches nothing.
  • exact_newest_boundary: tagged handles at 0x3/0x4/0x5 (increment 0x20) name their own heap; a heap at 0x23 shares heap 0's slot 1 boundary, so the newest heap is taken with boundary_matches == 2; reused tag/address take the newest heap.
  • off_boundary_newest: a handle off every boundary takes the newest containing heap with off_boundary == true, index rounded down.
  • boundary_beats_fallback: an older exact boundary beats a newer off-boundary fallback; the same heaps off every boundary take the newest fallback.
  • large_uint64: a heap at 0xfffffffffffffF00 (increment 0x40, count 3), a 0x10000000 increment at a large start, and a heap starting at UINT64_MAX.
  • found_none: the default match is none (SIZE_MAX) with found() == false; a heap 0 hit reports found() == true.

Mutation controls (5/5 killed)

  • span_guard_mut: the span guard is weakened so a false return never skips the heap; span_false then returns heap 0 index 0 instead of no match.
  • count_guard_mut: >= count becomes > count; count_boundary then returns heap 0 index count.
  • boundary_mod_mut: offset % increment == 0 becomes true; off_boundary_newest then reports an exact hit instead of the fallback.
  • search_order_mut: the search runs oldest first; exact_newest_boundary then returns heap 0 for the handle at 0x23.
  • fallback_override_mut: the fallback is applied even when a boundary matched; boundary_beats_fallback then returns the fallback heap with off_boundary == true.

There is no control for the increment == 0 guard: dropping it divides by zero, which CTest reports as a crash rather than an expected failure (verified in the scratch CTest run: the control failed with a numerical exception despite WILL_FAIL TRUE), so it has no clean WILL_FAIL control. zero_increment still exercises that guard directly. A first span-guard mutant that dropped the span call entirely did not compile under -Werror=unused-parameter (the parameter became unused), so it was rewritten to weaken the guard while still calling span.

Verification (Linux, this host, g++ -std=c++17, base origin/main 5770f14e)

./out/pe-env/bin/python -B tests/descriptor_heap_match_unit_meta_check.py
PASS: descriptor_heap_match_unit: 10 cases, 5/5 mutations killed (g++)
ctest --test-dir out/descriptor-heap-match-unit-scratch/build --no-tests=error -R '^descriptor_heap_match_unit'
100% tests passed, 0 tests failed out of 16

Full configure needs DXC, unavailable on Linux, so the fragment was configured standalone via symlinked src/tests under out/descriptor-heap-match-unit-scratch (16 tests: 10 cases + all + 5 controls).

./out/pe-env/bin/python -B tests/form_coverage_check.py
form coverage checks passed
./out/pe-env/bin/python -B tests/docs_links_check.py
Checked 242 Markdown files and 921 links.
./out/pe-env/bin/python -B tests/bidi_controls_check.py
Checked 2960 tracked source, script and build/CI files: no bidirectional controls.

Full Linux CI list from .github/workflows/windows.yml (tools/run_checks_parallel.py --from-dir tests/checks/python-linux ...): all 329 checks passed.

git diff --check clean; git merge-tree --write-tree origin/main HEAD exits 0.

Windows Verification (0cb68d8fdca0c8152c063794572a79ac7fd9f85e)

ctest --preset dev --no-tests=error -j16 -R '^descriptor_heap_match_unit' --output-on-failure
-> 100% tests passed, 0 tests failed out of 16 (0.70s)

ctest --preset release --no-tests=error -j16 -R '^descriptor_heap_match_unit' --output-on-failure
-> 100% tests passed, 0 tests failed out of 16 (0.62s)

descriptor_heap_match_unit_check.exe (dev + release): 10/10 cases passed
tests/descriptor_heap_match_unit_meta_check.py (cl): 10 cases, 5/5 mutations killed (cl)

AI-assisted.

**@⁠Ammmae0x** on GitHub · 2026-12-02 14:09 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3858) `Ammmae0x:tests/descriptor-heap-match-unit` → `main` · +1094 −0 · 5 files · 2 commits · merged 2026-12-02 15:45 UTC Refs #1149 Portable C++17 unit and header-mutation tests for `x2w_startup::match_descriptor_heap` (`src/startup_stubs/descriptor_heap_match.h`), matching `tests/cmake/logical_view_table_unit.cmake`. The source is unchanged; only 5 new files are added (+1094/-0), and the existing `tests/startup_descriptor_heap_match_check.cpp` coverage is untouched. The new check uses the disjoint `descriptor_heap_match_unit` prefix so test names do not collide. **What landed** - `tests/descriptor_heap_match_unit_check.cpp` — 10 cases, header-only against `src`, no device, no loader, no title data. A functor span callback (not a lambda) with `static constexpr` shared constants; a heap whose span callback returns `false` writes a span that would match and returns `false`, so a lookup that ignored the return value is caught. - `tests/cmake/descriptor_heap_match_unit.cmake` — one CTest test per case plus `descriptor_heap_match_unit_all`, and 5 `WILL_FAIL TRUE` controls (`BEFORE PRIVATE` mutated header copies, 1:1 with the meta check). - `tests/descriptor_heap_match_unit_meta_check.py` — audits the contract, compiles and runs the real C++ check and every mutation natively with `g++ -std=c++17 -Wall -Wextra -Wpedantic -Werror` (or `cl` with `/W4`). - `tests/checks/python-linux/descriptor_heap_match_unit.txt` — lists exactly the meta check. - `docs/experiments/descriptor-heap-match-unit.md` — cases, controls, and verification. **Cases** - `empty_count`: empty list matches nothing and never invokes `span`; `heap_count == 0` matches nothing despite a matching heap; `heap_count` truncates the search. - `span_false`: a heap with no span matches nothing at its start or off its boundary; a span-less newest/oldest heap defers without adding a boundary match. - `zero_increment`: increment 0 never matches (and never divides); increment 1 matches every handle on a boundary. - `handle_below_start`: a handle below a start matches nothing; a handle below the newest heap still matches an older heap whose span holds it. - `count_boundary`: `offset / increment == count - 1` matches, `== count` (and `count + 1`) does not; count 1 matches only its start; count 0 matches nothing. - `exact_newest_boundary`: tagged handles at `0x3`/`0x4`/`0x5` (increment `0x20`) name their own heap; a heap at `0x23` shares heap 0's slot 1 boundary, so the newest heap is taken with `boundary_matches == 2`; reused tag/address take the newest heap. - `off_boundary_newest`: a handle off every boundary takes the newest containing heap with `off_boundary == true`, index rounded down. - `boundary_beats_fallback`: an older exact boundary beats a newer off-boundary fallback; the same heaps off every boundary take the newest fallback. - `large_uint64`: a heap at `0xfffffffffffffF00` (increment `0x40`, count 3), a `0x10000000` increment at a large start, and a heap starting at `UINT64_MAX`. - `found_none`: the default match is `none` (`SIZE_MAX`) with `found() == false`; a heap 0 hit reports `found() == true`. **Mutation controls (5/5 killed)** - `span_guard_mut`: the span guard is weakened so a `false` return never skips the heap; `span_false` then returns heap 0 index 0 instead of no match. - `count_guard_mut`: `>= count` becomes `> count`; `count_boundary` then returns heap 0 index `count`. - `boundary_mod_mut`: `offset % increment == 0` becomes `true`; `off_boundary_newest` then reports an exact hit instead of the fallback. - `search_order_mut`: the search runs oldest first; `exact_newest_boundary` then returns heap 0 for the handle at `0x23`. - `fallback_override_mut`: the fallback is applied even when a boundary matched; `boundary_beats_fallback` then returns the fallback heap with `off_boundary == true`. There is no control for the `increment == 0` guard: dropping it divides by zero, which CTest reports as a crash rather than an expected failure (verified in the scratch CTest run: the control failed with a numerical exception despite `WILL_FAIL TRUE`), so it has no clean `WILL_FAIL` control. `zero_increment` still exercises that guard directly. A first span-guard mutant that dropped the `span` call entirely did not compile under `-Werror=unused-parameter` (the parameter became unused), so it was rewritten to weaken the guard while still calling `span`. **Verification (Linux, this host, `g++ -std=c++17`, base `origin/main` `5770f14e`)** ```text ./out/pe-env/bin/python -B tests/descriptor_heap_match_unit_meta_check.py PASS: descriptor_heap_match_unit: 10 cases, 5/5 mutations killed (g++) ``` ```text ctest --test-dir out/descriptor-heap-match-unit-scratch/build --no-tests=error -R '^descriptor_heap_match_unit' 100% tests passed, 0 tests failed out of 16 ``` Full configure needs DXC, unavailable on Linux, so the fragment was configured standalone via symlinked `src`/`tests` under `out/descriptor-heap-match-unit-scratch` (16 tests: 10 cases + all + 5 controls). ```text ./out/pe-env/bin/python -B tests/form_coverage_check.py form coverage checks passed ./out/pe-env/bin/python -B tests/docs_links_check.py Checked 242 Markdown files and 921 links. ./out/pe-env/bin/python -B tests/bidi_controls_check.py Checked 2960 tracked source, script and build/CI files: no bidirectional controls. ``` Full Linux CI list from `.github/workflows/windows.yml` (`tools/run_checks_parallel.py --from-dir tests/checks/python-linux ...`): `all 329 checks passed`. `git diff --check` clean; `git merge-tree --write-tree origin/main HEAD` exits 0. ### Windows Verification (`0cb68d8fdca0c8152c063794572a79ac7fd9f85e`) ```text ctest --preset dev --no-tests=error -j16 -R '^descriptor_heap_match_unit' --output-on-failure -> 100% tests passed, 0 tests failed out of 16 (0.70s) ctest --preset release --no-tests=error -j16 -R '^descriptor_heap_match_unit' --output-on-failure -> 100% tests passed, 0 tests failed out of 16 (0.62s) descriptor_heap_match_unit_check.exe (dev + release): 10/10 cases passed tests/descriptor_heap_match_unit_meta_check.py (cl): 10 cases, 5/5 mutations killed (cl) ``` AI-assisted. <!-- WIN-VERIFY: passed | sha=0cb68d8fdca0c8152c063794572a79ac7fd9f85e -->
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 14:11:14 +00:00
Author
Owner

@⁠R0Y00 on GitHub · 2026-12-02 14:15 UTC · original · approved these changes

I checked the five-file test-only diff and a clean trial merge. On the exact head, python3 -B tests/descriptor_heap_match_unit_meta_check.py passed with GCC, exercising all ten cases and catching all five mutations. I also built the unmodified CMake fragment in a standalone harness with MSVC 19.51. ctest --test-dir build --output-on-failure passed 16/16 including the five expected failures. The false span callback, boundary precedence and fallback tests exercise distinct parts of the search contract.

**@⁠R0Y00** on GitHub · 2026-12-02 14:15 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3858#pullrequestreview-6152530512) · **approved these changes** I checked the five-file test-only diff and a clean trial merge. On the exact head, `python3 -B tests/descriptor_heap_match_unit_meta_check.py` passed with GCC, exercising all ten cases and catching all five mutations. I also built the unmodified CMake fragment in a standalone harness with MSVC 19.51. `ctest --test-dir build --output-on-failure` passed 16/16 including the five expected failures. The false span callback, boundary precedence and fallback tests exercise distinct parts of the search contract.
github-bot changed target branch from main to gh-pr/3858/base 2026-12-02 15:50:26 +00:00
github manually merged commit def1c6abfa into gh-pr/3858/base 2026-12-02 15:50:28 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.