tests: cover x2w_api_trace contract table, decide partial outcomes, and formatting #3753

Manually merged
github merged 1 commit from github-bot/gh-3751 into main 2026-12-01 17:05:18 +00:00 AGit
Owner

@⁠Ammmae0x on GitHub · 2026-12-01 15:22 UTC · original
Ammmae0x:tests/api-trace-unit → main · +1539 −0 · 5 files · 1 commits · merged 2026-12-01 17:04 UTC

Refs #1149.

Adds standalone, strict C++17 portable unit + 1:1 header-mutation tests for x2w_api_trace (src/startup_stubs/api_trace.h), with zero edits to existing files (5 new files only, +1539/-0). tests/api_trace_check.cpp and CMakeLists.txt are untouched; the api_trace_unit prefix keeps all CMake/CTest/target names disjoint from api_trace.

What is covered (27 cases, each callable via --case <name> / <name>, no-arg runs all):

  • declared(): all 15 contracts in the table (exact arg indices, first_bytes, size_argument, second, second_bytes), unknown provider, unknown slot, cross-provider slot mismatch (nullptr).
  • decide(): nullptr contract (Outcome::Unknown); all outputs compared=false or bytes=0 (Outcome::Unreadable, partial=true); 1-output Same & Changed; 2-output Same, first-only changed, second-only changed, both changed; partial cases (Same with partial=true, Changed with partial=true, bytes[i]=0 skipped even when buffer bytes differ); diff at last byte of max_snapshot (64).
  • format(): "?", "unreadable", "same", "same,partial", "changed:<arg>" (including argument index 0 for {0x37e56907, 15}), "changed:<arg>,partial", "changed:<a0>,<a1>", "changed:<a0>,<a1>,partial", exact slot-to-argument mapping for all 15 contracts, fallback with null contract ("changed:0", "changed:-1"), small output buffer truncation.

Mutation controls (6, WILL_FAIL TRUE in tests/cmake/api_trace_unit.cmake, mirrored 1:1 by real copied headers in tests/api_trace_unit_meta_check.py): unreadable_same, partial_flag, zero_bytes_skip, second_arg_map, slot_lookup, format_partial_suffix.

Verification (Linux, this host):

  • g++ -std=c++17 -O2 -Wall -Wextra -Wpedantic -Werror -Isrc tests/api_trace_unit_check.cpp: PASS: api_trace_unit: 27/27 cases passed
  • /tmp/pe-env/bin/python -B tests/api_trace_unit_meta_check.py: PASS: api_trace_unit: 27 cases, 6/6 mutations killed (g++)
  • Scratch CMake + CTest (fragment included standalone; full configure needs dxc, unavailable on Linux): 100% tests passed, 0 tests failed out of 34 (27 cases + _all + 6 WILL_FAIL mutation controls)
  • tests/form_coverage_check.py, tests/docs_links_check.py (208 files / 802 links), tests/bidi_controls_check.py (2827 files) pass; git diff --check clean; merge-tree vs origin/main exits 0; zero personal paths.
  • Full python-linux suite (tools/run_checks_parallel.py with the CI inline list + --from-dir tests/checks/python-linux): all 299 checks passed

Caught in development: the slot_lookup mutant left the provider parameter unused, tripping -Werror=unused-parameter when compiling the mutated header, so the replacement keeps it via (void)provider,; and a known-size small buffer made -Wformat-truncation reject the header's own snprintf at the truncation call site, so format_small_buffer_truncation uses 48-byte buffers with a smaller (volatile-held) size passed to format().

Caveat: no mingw on this host, so no Windows compile check; WIN-VERIFY run is the arbiter.

Windows Verification (70e1ea76)

  • git merge-tree --write-tree upstream/main HEAD -> 9bb5ed15 (exit 0), git diff --check upstream/main...HEAD clean
  • Repo checks: py_compile, form_coverage_check.py, docs_links_check.py (209 files, 806 links), bidi_controls_check.py (2830 files) passed
  • Commands:
cmake --build --preset dev --target api_trace_unit_check api_trace_unit_unreadable_same_mut api_trace_unit_partial_flag_mut api_trace_unit_zero_bytes_skip_mut api_trace_unit_second_arg_map_mut api_trace_unit_slot_lookup_mut api_trace_unit_format_partial_suffix_mut
ctest --preset dev --no-tests=error -j16 -R "^api_trace_unit" --output-on-failure
cmake --build --preset release --target api_trace_unit_check api_trace_unit_unreadable_same_mut api_trace_unit_partial_flag_mut api_trace_unit_zero_bytes_skip_mut api_trace_unit_second_arg_map_mut api_trace_unit_slot_lookup_mut api_trace_unit_format_partial_suffix_mut
ctest --preset release --no-tests=error -j16 -R "^api_trace_unit" --output-on-failure
  • Results: dev 34/34 passed (0.98s); release 34/34 passed (0.77s); direct api_trace_unit_check.exe (dev & release): PASS: api_trace_unit: 27/27 cases passed. AI-assisted.
**@⁠Ammmae0x** on GitHub · 2026-12-01 15:22 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3751) `Ammmae0x:tests/api-trace-unit` → `main` · +1539 −0 · 5 files · 1 commits · merged 2026-12-01 17:04 UTC Refs #1149. Adds standalone, strict C++17 portable unit + 1:1 header-mutation tests for `x2w_api_trace` (`src/startup_stubs/api_trace.h`), with zero edits to existing files (5 new files only, +1539/-0). `tests/api_trace_check.cpp` and `CMakeLists.txt` are untouched; the `api_trace_unit` prefix keeps all CMake/CTest/target names disjoint from `api_trace`. **What is covered (27 cases, each callable via `--case <name>` / `<name>`, no-arg runs all):** - `declared()`: all 15 contracts in the table (exact arg indices, `first_bytes`, `size_argument`, `second`, `second_bytes`), unknown provider, unknown slot, cross-provider slot mismatch (`nullptr`). - `decide()`: `nullptr` contract (`Outcome::Unknown`); all outputs `compared=false` or `bytes=0` (`Outcome::Unreadable`, `partial=true`); 1-output `Same` & `Changed`; 2-output `Same`, first-only changed, second-only changed, both changed; partial cases (`Same` with `partial=true`, `Changed` with `partial=true`, `bytes[i]=0` skipped even when buffer bytes differ); diff at last byte of `max_snapshot` (64). - `format()`: `"?"`, `"unreadable"`, `"same"`, `"same,partial"`, `"changed:<arg>"` (including argument index `0` for `{0x37e56907, 15}`), `"changed:<arg>,partial"`, `"changed:<a0>,<a1>"`, `"changed:<a0>,<a1>,partial"`, exact slot-to-argument mapping for all 15 contracts, fallback with null contract (`"changed:0"`, `"changed:-1"`), small output buffer truncation. **Mutation controls (6, `WILL_FAIL TRUE` in `tests/cmake/api_trace_unit.cmake`, mirrored 1:1 by real copied headers in `tests/api_trace_unit_meta_check.py`):** `unreadable_same`, `partial_flag`, `zero_bytes_skip`, `second_arg_map`, `slot_lookup`, `format_partial_suffix`. **Verification (Linux, this host):** - `g++ -std=c++17 -O2 -Wall -Wextra -Wpedantic -Werror -Isrc tests/api_trace_unit_check.cpp`: `PASS: api_trace_unit: 27/27 cases passed` - `/tmp/pe-env/bin/python -B tests/api_trace_unit_meta_check.py`: `PASS: api_trace_unit: 27 cases, 6/6 mutations killed (g++)` - Scratch CMake + CTest (fragment included standalone; full configure needs `dxc`, unavailable on Linux): `100% tests passed, 0 tests failed out of 34` (27 cases + `_all` + 6 `WILL_FAIL` mutation controls) - `tests/form_coverage_check.py`, `tests/docs_links_check.py` (208 files / 802 links), `tests/bidi_controls_check.py` (2827 files) pass; `git diff --check` clean; merge-tree vs `origin/main` exits 0; zero personal paths. - Full `python-linux` suite (`tools/run_checks_parallel.py` with the CI inline list + `--from-dir tests/checks/python-linux`): `all 299 checks passed` Caught in development: the `slot_lookup` mutant left the `provider` parameter unused, tripping `-Werror=unused-parameter` when compiling the mutated header, so the replacement keeps it via `(void)provider,`; and a known-size small buffer made `-Wformat-truncation` reject the header's own `snprintf` at the truncation call site, so `format_small_buffer_truncation` uses 48-byte buffers with a smaller (volatile-held) size passed to `format()`. Caveat: no mingw on this host, so no Windows compile check; WIN-VERIFY run is the arbiter. <!-- WIN-VERIFY: passed | sha=70e1ea76c6565a1219fa16da10ccda785193ce5d | targets=api_trace_unit_check api_trace_unit_unreadable_same_mut api_trace_unit_partial_flag_mut api_trace_unit_zero_bytes_skip_mut api_trace_unit_second_arg_map_mut api_trace_unit_slot_lookup_mut api_trace_unit_format_partial_suffix_mut | ctest=^api_trace_unit | release=true --> ### Windows Verification (`70e1ea76`) - `git merge-tree --write-tree upstream/main HEAD` -> `9bb5ed15` (exit 0), `git diff --check upstream/main...HEAD` clean - Repo checks: `py_compile`, `form_coverage_check.py`, `docs_links_check.py` (209 files, 806 links), `bidi_controls_check.py` (2830 files) passed - Commands: ```text cmake --build --preset dev --target api_trace_unit_check api_trace_unit_unreadable_same_mut api_trace_unit_partial_flag_mut api_trace_unit_zero_bytes_skip_mut api_trace_unit_second_arg_map_mut api_trace_unit_slot_lookup_mut api_trace_unit_format_partial_suffix_mut ctest --preset dev --no-tests=error -j16 -R "^api_trace_unit" --output-on-failure cmake --build --preset release --target api_trace_unit_check api_trace_unit_unreadable_same_mut api_trace_unit_partial_flag_mut api_trace_unit_zero_bytes_skip_mut api_trace_unit_second_arg_map_mut api_trace_unit_slot_lookup_mut api_trace_unit_format_partial_suffix_mut ctest --preset release --no-tests=error -j16 -R "^api_trace_unit" --output-on-failure ``` - Results: `dev` 34/34 passed (0.98s); `release` 34/34 passed (0.77s); direct `api_trace_unit_check.exe` (`dev` & `release`): `PASS: api_trace_unit: 27/27 cases passed`. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 15:23:39 +00:00
github manually merged commit 5b5ceb2c3c into main 2026-12-01 17:05:18 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.