tests: cover x2w_save_pack layout, overflow guards, and serialization #3748

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

@⁠Ammmae0x on GitHub · 2026-12-01 14:23 UTC · original
Ammmae0x:tests/save-blob-pack-unit → main · +1021 −0 · 5 files · 1 commits · merged 2026-12-01 17:04 UTC

Refs #1149.

Portable C++17 unit, overflow-boundary, layout, and 1:1 header-mutation tests for x2w_save_pack (src/startup_stubs/save_blob_pack.h), with zero edits to existing files (5 new files only). The new check uses the disjoint save_blob_pack_unit prefix so test names do not collide with startup_save_blob_pack.

What landed (commit e1204e30):

  • tests/save_blob_pack_unit_check.cpp: 22 cases, pure C++17, no <windows.h>. Layout (sizeof(Blob) == 24, offsetof(Blob, data) == 16, BlobInfo layout); both bytes_needed overloads (empty inputs set out to 0, exact formula count*24 + sum(name.size() + 1 + bytes.size()), record-table count overflow, null sizes pointer, UINT32_MAX payload accepted vs UINT32_MAX + 1 refused, the name_bytes >= SIZE_MAX - data_bytes NUL-room boundary and the exact SIZE_MAX fit one below it, extra overflow by one, a SIZE_MAX payload, and a two-piece cumulative overflow, each refusal leaving out unchanged); write() serialization (empty write leaves the buffer untouched, empty name with zero-byte payload, binary payload with embedded NULs, three-piece mix, name with an embedded NUL), verifying exact NUL-terminated strings, pointer offsets inside dest, info.size, guard bytes, and an end cursor equal to bytes_needed.
  • tests/cmake/save_blob_pack_unit.cmake: per-case CTests plus save_blob_pack_unit_all and 6 WILL_FAIL TRUE header-copy controls (u32_cap, name_nul_guard, extra_overflow_guard, write_nul, write_info_size, add_accumulate) with mutated copies under startup_stubs/save_blob_pack.h and BEFORE PRIVATE include.
  • tests/save_blob_pack_unit_meta_check.py, tests/checks/python-linux/save_blob_pack_unit.txt, docs/experiments/save-blob-pack-unit.md.

Linux checks (this host, g++ -std=c++17):

/tmp/pe-env/bin/python -B tests/save_blob_pack_unit_meta_check.py
PASS: save_blob_pack_unit: 22 cases, 6/6 mutations killed (g++)

Scratch CMake + CTest: 29/29 (22 cases, save_blob_pack_unit_all, 6 mutation controls). Form, docs (208 files / 802 links), and bidi (2827 files) checks pass; parallel Python runner 299/299; diff --check clean; merge-tree vs origin/main exits 0.

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

AI-assisted.

Windows Verification (e1204e30)

  • git merge-tree --write-tree upstream/main HEAD -> 8aa64c9d (exit 0), git diff --check clean
  • Python 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 save_blob_pack_unit_check save_blob_pack_unit_u32_cap_mut save_blob_pack_unit_name_nul_guard_mut save_blob_pack_unit_extra_overflow_guard_mut save_blob_pack_unit_write_nul_mut save_blob_pack_unit_write_info_size_mut save_blob_pack_unit_add_accumulate_mut
ctest --preset dev --no-tests=error -R "^save_blob_pack_unit" --output-on-failure
cmake --build --preset release --target save_blob_pack_unit_check save_blob_pack_unit_u32_cap_mut save_blob_pack_unit_name_nul_guard_mut save_blob_pack_unit_extra_overflow_guard_mut save_blob_pack_unit_write_nul_mut save_blob_pack_unit_write_info_size_mut save_blob_pack_unit_add_accumulate_mut
ctest --preset release --no-tests=error -R "^save_blob_pack_unit" --output-on-failure
  • Results: dev 29/29 passed (0.95s); release 29/29 passed (0.95s); save_blob_pack_unit_check: PASS: save_blob_pack_unit: 22/22 cases passed. AI-assisted.
**@⁠Ammmae0x** on GitHub · 2026-12-01 14:23 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/3746) `Ammmae0x:tests/save-blob-pack-unit` → `main` · +1021 −0 · 5 files · 1 commits · merged 2026-12-01 17:04 UTC Refs #1149. Portable C++17 unit, overflow-boundary, layout, and 1:1 header-mutation tests for `x2w_save_pack` (`src/startup_stubs/save_blob_pack.h`), with zero edits to existing files (5 new files only). The new check uses the disjoint `save_blob_pack_unit` prefix so test names do not collide with `startup_save_blob_pack`. What landed (commit `e1204e30`): - `tests/save_blob_pack_unit_check.cpp`: 22 cases, pure C++17, no `<windows.h>`. Layout (`sizeof(Blob) == 24`, `offsetof(Blob, data) == 16`, `BlobInfo` layout); both `bytes_needed` overloads (empty inputs set `out` to 0, exact formula `count*24 + sum(name.size() + 1 + bytes.size())`, record-table count overflow, null sizes pointer, `UINT32_MAX` payload accepted vs `UINT32_MAX + 1` refused, the `name_bytes >= SIZE_MAX - data_bytes` NUL-room boundary and the exact `SIZE_MAX` fit one below it, extra overflow by one, a `SIZE_MAX` payload, and a two-piece cumulative overflow, each refusal leaving `out` unchanged); `write()` serialization (empty write leaves the buffer untouched, empty name with zero-byte payload, binary payload with embedded NULs, three-piece mix, name with an embedded NUL), verifying exact NUL-terminated strings, pointer offsets inside `dest`, `info.size`, guard bytes, and an end cursor equal to `bytes_needed`. - `tests/cmake/save_blob_pack_unit.cmake`: per-case CTests plus `save_blob_pack_unit_all` and 6 `WILL_FAIL TRUE` header-copy controls (`u32_cap`, `name_nul_guard`, `extra_overflow_guard`, `write_nul`, `write_info_size`, `add_accumulate`) with mutated copies under `startup_stubs/save_blob_pack.h` and `BEFORE PRIVATE` include. - `tests/save_blob_pack_unit_meta_check.py`, `tests/checks/python-linux/save_blob_pack_unit.txt`, `docs/experiments/save-blob-pack-unit.md`. Linux checks (this host, `g++ -std=c++17`): ```text /tmp/pe-env/bin/python -B tests/save_blob_pack_unit_meta_check.py PASS: save_blob_pack_unit: 22 cases, 6/6 mutations killed (g++) ``` Scratch CMake + CTest: 29/29 (22 cases, `save_blob_pack_unit_all`, 6 mutation controls). Form, docs (208 files / 802 links), and bidi (2827 files) checks pass; parallel Python runner 299/299; `diff --check` clean; merge-tree vs `origin/main` exits 0. No mingw on this host, so no Windows compile check; WIN-VERIFY run is the arbiter. AI-assisted. <!-- WIN-VERIFY: passed | sha=e1204e30f4a9bc436e662ab1d258e48ec011416c | targets=save_blob_pack_unit_check save_blob_pack_unit_u32_cap_mut save_blob_pack_unit_name_nul_guard_mut save_blob_pack_unit_extra_overflow_guard_mut save_blob_pack_unit_write_nul_mut save_blob_pack_unit_write_info_size_mut save_blob_pack_unit_add_accumulate_mut | ctest=^save_blob_pack_unit | release=true --> ### Windows Verification (`e1204e30`) - `git merge-tree --write-tree upstream/main HEAD` -> `8aa64c9d` (exit 0), `git diff --check` clean - Python 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 save_blob_pack_unit_check save_blob_pack_unit_u32_cap_mut save_blob_pack_unit_name_nul_guard_mut save_blob_pack_unit_extra_overflow_guard_mut save_blob_pack_unit_write_nul_mut save_blob_pack_unit_write_info_size_mut save_blob_pack_unit_add_accumulate_mut ctest --preset dev --no-tests=error -R "^save_blob_pack_unit" --output-on-failure cmake --build --preset release --target save_blob_pack_unit_check save_blob_pack_unit_u32_cap_mut save_blob_pack_unit_name_nul_guard_mut save_blob_pack_unit_extra_overflow_guard_mut save_blob_pack_unit_write_nul_mut save_blob_pack_unit_write_info_size_mut save_blob_pack_unit_add_accumulate_mut ctest --preset release --no-tests=error -R "^save_blob_pack_unit" --output-on-failure ``` - Results: `dev` 29/29 passed (0.95s); `release` 29/29 passed (0.95s); `save_blob_pack_unit_check`: `PASS: save_blob_pack_unit: 22/22 cases passed`. AI-assisted.
Refs #1149. Portable C++17 unit tests for src/startup_stubs/save_blob_pack.h
with zero edits to existing files: 22 cases (Blob/BlobInfo layout, both
bytes_needed overloads incl. UINT32_MAX cap, NUL-room and SIZE_MAX exact-fit
boundaries, cumulative overflow, and write() serialization incl. embedded
NULs) plus 6 WILL_FAIL TRUE header-mutation controls. AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-01 14:24:38 +00:00
github manually merged commit 64b2705ed9 into main 2026-12-01 17:05:21 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.