tests: add unit and mutation tests for native_copy_ranges.h #3654

Merged
Ammmae0x merged 2 commits from upstream-pr/3654 into main 2026-12-01 00:11:58 +00:00
Ammmae0x commented 2026-11-30 21:45:03 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-30T21:45:03Z.


Refs #1149

Adds a portable C++17 unit, differential-fuzz, and configure-time header-mutation test suite for x2w_startup::NativeCopyRanges (src/startup_stubs/native_copy_ranges.h, previously untested in tests/). No existing file is modified; native_copy_ranges.h and device code are untouched.

What landed (5 new files, +923/-0):

  • tests/startup_native_copy_ranges_check.cpp — standard C++17 only, no device or graphics API. Six cases (--case selectable, loud FAIL: <case>: to stderr): empty/inverted ranges are no-ops, adjacent coalesce in both orders, one add bridging three spans, middle/multi-span splits and trims, coverage none/partial/full across exact edges, gaps, and the [UINT64_MAX-16, UINT64_MAX) endpoints, and a deterministic 1500-step splitmix64 differential fuzz against an independent reference model (strict span invariants checked at every step).
  • tests/cmake/startup_native_copy_ranges.cmake — per-case plus startup_native_copy_ranges_all tests, and six WILL_FAIL TRUE mutation controls mirroring era_physical_owns_last_page_control, each a configure-time mutated header copy with a pinned control case.
  • tests/startup_native_copy_ranges_meta_check.py + tests/checks/python-linux/startup_native_copy_ranges.txt — Linux contract audit that compiles and runs the real test and every mutated header copy natively with g++ -std=c++17.
  • docs/experiments/startup-native-copy-ranges.md — cases, controls, and runs.

Tests (Linux):

  • Real C++ test with g++: 6/6 cases passed, including the 1500-step diff_fuzz.
  • Meta check: PASS: startup native copy ranges: 6 cases, 6/6 mutations killed (g++).
  • form_coverage_check.py, docs_links_check.py (192 files/745 links), bidi_controls_check.py (2762 files) pass; diff --check clean; zero personal paths.
  • Full CI python-linux command (tools/run_checks_parallel.py --from-dir tests/checks/python-linux ...): all 282 checks passed.

Windows execution (MSVC) awaits Windows verification:

ctest --preset dev --no-tests=error -R '^startup_native_copy_ranges' -V

Windows Verification (6f1d84ea)

Commit: 6f1d84eaf74ba0bb96af8255ebf9d04d5cd3f4f1 (merge-tree upstream/main HEAD -> 6cc5602f, exit 0; git diff --check clean)
dev: cmake --build --preset dev --target startup_native_copy_ranges_check startup_native_copy_ranges_add_left_mut startup_native_copy_ranges_add_right_mut startup_native_copy_ranges_cpu_write_split_mut startup_native_copy_ranges_coverage_gap_mut startup_native_copy_ranges_coverage_left_mut startup_native_copy_ranges_coverage_empty_mut && ctest --preset dev --no-tests=error -R "^startup_native_copy_ranges" --output-on-failure -> 13/13 passed (0.77s; 7 functional + 6/6 WILL_FAIL header mutants)
release: cmake --build --preset release --target startup_native_copy_ranges_check startup_native_copy_ranges_add_left_mut startup_native_copy_ranges_add_right_mut startup_native_copy_ranges_cpu_write_split_mut startup_native_copy_ranges_coverage_gap_mut startup_native_copy_ranges_coverage_left_mut startup_native_copy_ranges_coverage_empty_mut && ctest --preset release --no-tests=error -R "^startup_native_copy_ranges" -E "cpu_native_archive_" --output-on-failure -> 13/13 passed (0.61s; 7 functional + 6/6 WILL_FAIL header mutants)
Checks: form_coverage_check.py, docs_links_check.py (193 files, 749 links), bidi_controls_check.py (2765 files) -> passed

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5574318492 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3654). Originally posted by [Ammmae0x](https://github.com/Ammmae0x) on 2026-11-30T21:45:03Z. --- Refs #1149 Adds a portable C++17 unit, differential-fuzz, and configure-time header-mutation test suite for `x2w_startup::NativeCopyRanges` (`src/startup_stubs/native_copy_ranges.h`, previously untested in `tests/`). No existing file is modified; `native_copy_ranges.h` and device code are untouched. What landed (5 new files, +923/-0): - `tests/startup_native_copy_ranges_check.cpp` — standard C++17 only, no device or graphics API. Six cases (`--case` selectable, loud `FAIL: <case>:` to stderr): empty/inverted ranges are no-ops, adjacent coalesce in both orders, one add bridging three spans, middle/multi-span splits and trims, coverage none/partial/full across exact edges, gaps, and the `[UINT64_MAX-16, UINT64_MAX)` endpoints, and a deterministic 1500-step splitmix64 differential fuzz against an independent reference model (strict span invariants checked at every step). - `tests/cmake/startup_native_copy_ranges.cmake` — per-case plus `startup_native_copy_ranges_all` tests, and six `WILL_FAIL TRUE` mutation controls mirroring `era_physical_owns_last_page_control`, each a configure-time mutated header copy with a pinned control case. - `tests/startup_native_copy_ranges_meta_check.py` + `tests/checks/python-linux/startup_native_copy_ranges.txt` — Linux contract audit that compiles and runs the real test and every mutated header copy natively with `g++ -std=c++17`. - `docs/experiments/startup-native-copy-ranges.md` — cases, controls, and runs. Tests (Linux): - Real C++ test with g++: 6/6 cases passed, including the 1500-step diff_fuzz. - Meta check: `PASS: startup native copy ranges: 6 cases, 6/6 mutations killed (g++)`. - `form_coverage_check.py`, `docs_links_check.py` (192 files/745 links), `bidi_controls_check.py` (2762 files) pass; `diff --check` clean; zero personal paths. - Full CI python-linux command (`tools/run_checks_parallel.py --from-dir tests/checks/python-linux ...`): all 282 checks passed. Windows execution (MSVC) awaits Windows verification: ```text ctest --preset dev --no-tests=error -R '^startup_native_copy_ranges' -V ``` ### Windows Verification (`6f1d84ea`) ```text Commit: 6f1d84eaf74ba0bb96af8255ebf9d04d5cd3f4f1 (merge-tree upstream/main HEAD -> 6cc5602f, exit 0; git diff --check clean) dev: cmake --build --preset dev --target startup_native_copy_ranges_check startup_native_copy_ranges_add_left_mut startup_native_copy_ranges_add_right_mut startup_native_copy_ranges_cpu_write_split_mut startup_native_copy_ranges_coverage_gap_mut startup_native_copy_ranges_coverage_left_mut startup_native_copy_ranges_coverage_empty_mut && ctest --preset dev --no-tests=error -R "^startup_native_copy_ranges" --output-on-failure -> 13/13 passed (0.77s; 7 functional + 6/6 WILL_FAIL header mutants) release: cmake --build --preset release --target startup_native_copy_ranges_check startup_native_copy_ranges_add_left_mut startup_native_copy_ranges_add_right_mut startup_native_copy_ranges_cpu_write_split_mut startup_native_copy_ranges_coverage_gap_mut startup_native_copy_ranges_coverage_left_mut startup_native_copy_ranges_coverage_empty_mut && ctest --preset release --no-tests=error -R "^startup_native_copy_ranges" -E "cpu_native_archive_" --output-on-failure -> 13/13 passed (0.61s; 7 functional + 6/6 WILL_FAIL header mutants) Checks: form_coverage_check.py, docs_links_check.py (193 files, 749 links), bidi_controls_check.py (2765 files) -> passed ``` AI-assisted. <!-- WIN-VERIFY: passed | sha=6f1d84eaf74ba0bb96af8255ebf9d04d5cd3f4f1 | targets=startup_native_copy_ranges_check startup_native_copy_ranges_add_left_mut startup_native_copy_ranges_add_right_mut startup_native_copy_ranges_cpu_write_split_mut startup_native_copy_ranges_coverage_gap_mut startup_native_copy_ranges_coverage_left_mut startup_native_copy_ranges_coverage_empty_mut | ctest=^startup_native_copy_ranges | release=true -->
R0Y00 commented 2026-12-01 00:10:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-12-01T00:10:09Z.

Review: APPROVED


Reviewed the native copy-range fixtures and their six mutation controls. ctest --test-dir <build> --no-tests=error -j1 -R '^startup_native_copy_ranges_' --output-on-failure passed in the Windows Release integration. python -B tests/startup_native_copy_ranges_meta_check.py independently passed with all six mutations caught.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6122836624 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3654#pullrequestreview-6122836624). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-12-01T00:10:09Z. **Review:** APPROVED --- Reviewed the native copy-range fixtures and their six mutation controls. `ctest --test-dir <build> --no-tests=error -j1 -R '^startup_native_copy_ranges_' --output-on-failure` passed in the Windows Release integration. `python -B tests/startup_native_copy_ranges_meta_check.py` independently passed with all six mutations caught.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!3654
No description provided.