test: cover leading and trailing spaces in save names #1675

Merged
ChazY11 merged 1 commit from upstream-pr/1682 into main 2026-11-24 17:14:49 +00:00
ChazY11 commented 2026-11-24 17:00:28 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T17:00:28Z.


What

x2w_save::valid_name refuses a name whose first or last character is a space
(src/startup_stubs/save_store.h, the name.front() == ' ' and name.back() == ' ' clauses). The refused-name list in
tests/startup_gamesave_persist.cpp has "x." for the trailing dot but no case for either space rule, so both clauses
can be deleted with the fixture still green.

How I found it

Removing either clause from save_store.h and rebuilding startup_gamesave_persist leaves the test passing. With the
three cases added, both removals now fail:

drop `name.front() == ' '`   before: passed     after: FAILED
drop `name.back() == ' '`    before: passed     after: FAILED

The mutations were run against the binary the fixture actually loads (startup_gamesave_persist.exe, target
startup_gamesave_persist), rebuilt each time, and reverted afterwards.

Change

One line: three entries appended to the bad[] list.

-    const char* bad[] = {"", "..", ".", "../x", "a/b", "a\\b", "/abs", "\\abs", "C:x", "C:\\x", "a..b", "x.", "NUL", "com1.txt", "a\nb", "n*", "a.x2w-part"};
+    const char* bad[] = {"", "..", ".", "../x", "a/b", "a\\b", "/abs", "\\abs", "C:x", "C:\\x", "a..b", "x.", "NUL", "com1.txt", "a\nb", "n*", "a.x2w-part", " x", "x ", "  double-lead"};

The existing loop then asserts the refusal through every entry point, not just the predicate: create_container,
write_blob, read_blob, delete_blob and delete_container all have to answer Status::bad_name for each name.

Tested

cmake --preset dev
cmake --build --preset dev --target startup_gamesave_persist
ctest --preset dev --no-tests=error -R '^startup_gamesave_' -V
8 of 8 pass; startup_gamesave_submit_system and startup_gamesave_read_async_system report Skipped (77) here, separately
from the six passes

No behaviour change: the only file touched is the test.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6587104825 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1682). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:00:28Z. --- ## What `x2w_save::valid_name` refuses a name whose first or last character is a space (`src/startup_stubs/save_store.h`, the `name.front() == ' '` and `name.back() == ' '` clauses). The refused-name list in `tests/startup_gamesave_persist.cpp` has `"x."` for the trailing dot but no case for either space rule, so both clauses can be deleted with the fixture still green. ## How I found it Removing either clause from `save_store.h` and rebuilding `startup_gamesave_persist` leaves the test passing. With the three cases added, both removals now fail: ```text drop `name.front() == ' '` before: passed after: FAILED drop `name.back() == ' '` before: passed after: FAILED ``` The mutations were run against the binary the fixture actually loads (`startup_gamesave_persist.exe`, target `startup_gamesave_persist`), rebuilt each time, and reverted afterwards. ## Change One line: three entries appended to the `bad[]` list. ```diff - const char* bad[] = {"", "..", ".", "../x", "a/b", "a\\b", "/abs", "\\abs", "C:x", "C:\\x", "a..b", "x.", "NUL", "com1.txt", "a\nb", "n*", "a.x2w-part"}; + const char* bad[] = {"", "..", ".", "../x", "a/b", "a\\b", "/abs", "\\abs", "C:x", "C:\\x", "a..b", "x.", "NUL", "com1.txt", "a\nb", "n*", "a.x2w-part", " x", "x ", " double-lead"}; ``` The existing loop then asserts the refusal through every entry point, not just the predicate: `create_container`, `write_blob`, `read_blob`, `delete_blob` and `delete_container` all have to answer `Status::bad_name` for each name. ## Tested ```powershell cmake --preset dev cmake --build --preset dev --target startup_gamesave_persist ctest --preset dev --no-tests=error -R '^startup_gamesave_' -V ``` ```text 8 of 8 pass; startup_gamesave_submit_system and startup_gamesave_read_async_system report Skipped (77) here, separately from the six passes ``` No behaviour change: the only file touched is the test. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 18:02:29 +00:00
tedin7 commented 2026-11-24 18:02:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:06:05Z.

Review: COMMENTED


Review for head 6c03c3c9 (comment only, no approval).

Verdict: no blocking findings. Looks like a clean Tier B (tests-only) candidate.

What I checked, line by line:

  • The diff is one line in tests/startup_gamesave_persist.cpp: three strings appended to the existing bad[] list. No existing entry is removed or reordered, and no assertion is changed or weakened.
  • The three new names (" x", "x ", " double-lead") go through the same seven checks as every other refused name (valid_name plus the six store calls), so the coverage is wider than the commit message suggests.
  • Each name reaches one clause in valid_name only. "x " is not a device name, so the stem trim cannot catch it, and the front-space clause is the only thing that refuses " x".
  • Small nit, not blocking: the commit message calls the third case "only spaces at the front", but " double-lead" is two leading spaces plus text. The case is still useful (more than one leading space).
  • Source is plain ASCII, with no Unicode or bidi characters. NUL bytes cannot occur in these C string literals.

Local checks on Linux (g++ 17, -Wall -Wextra, TMPDIR pointed at an empty private dir):

  • Test at the PR head: startup_gamesave_persist: ok, exit 0, no warnings. The private TMPDIR was empty afterwards, so no temp files leaked.
  • git diff --check against the merge base: clean.
  • python3 -I tests/docs_links_check.py: self-test passed, 17 Markdown files and 363 links.
  • python3 -I tests/bidi_controls_check.py: self-test passed, 1280 files, no bidirectional controls.

Mutation checks I actually ran (each on a scratch checkout of src/startup_stubs/save_store.h, then restored):

  1. Removed the name.front() == ' ' clause: the test fails (exit 1). " x" and " double-lead" are both reported as accepted, 14 failures in total.
  2. Removed the name.back() == ' ' clause: the test fails (exit 1). "x " is reported as accepted, 7 failures.
  3. Removed both: the test fails (exit 1).
    So the PR claim holds: each clause was previously deletable with the test green, and now it is not.

Limits: Linux only. I did not run the Windows build, the runtime_proxy.cpp callers, or the full ctest suite. The test uses its own temp store, so nothing outside it was touched.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043841200 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1682#pullrequestreview-6043841200). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:06:05Z. **Review:** COMMENTED --- Review for head `6c03c3c9` (comment only, no approval). **Verdict: no blocking findings. Looks like a clean Tier B (tests-only) candidate.** What I checked, line by line: - The diff is one line in `tests/startup_gamesave_persist.cpp`: three strings appended to the existing `bad[]` list. No existing entry is removed or reordered, and no assertion is changed or weakened. - The three new names (`" x"`, `"x "`, `" double-lead"`) go through the same seven checks as every other refused name (`valid_name` plus the six store calls), so the coverage is wider than the commit message suggests. - Each name reaches one clause in `valid_name` only. `"x "` is not a device name, so the stem trim cannot catch it, and the front-space clause is the only thing that refuses `" x"`. - Small nit, not blocking: the commit message calls the third case "only spaces at the front", but `" double-lead"` is two leading spaces plus text. The case is still useful (more than one leading space). - Source is plain ASCII, with no Unicode or bidi characters. NUL bytes cannot occur in these C string literals. Local checks on Linux (g++ 17, `-Wall -Wextra`, TMPDIR pointed at an empty private dir): - Test at the PR head: `startup_gamesave_persist: ok`, exit 0, no warnings. The private TMPDIR was empty afterwards, so no temp files leaked. - `git diff --check` against the merge base: clean. - `python3 -I tests/docs_links_check.py`: self-test passed, 17 Markdown files and 363 links. - `python3 -I tests/bidi_controls_check.py`: self-test passed, 1280 files, no bidirectional controls. Mutation checks I actually ran (each on a scratch checkout of `src/startup_stubs/save_store.h`, then restored): 1. Removed the `name.front() == ' '` clause: the test fails (exit 1). `" x"` and `" double-lead"` are both reported as accepted, 14 failures in total. 2. Removed the `name.back() == ' '` clause: the test fails (exit 1). `"x "` is reported as accepted, 7 failures. 3. Removed both: the test fails (exit 1). So the PR claim holds: each clause was previously deletable with the test green, and now it is not. Limits: Linux only. I did not run the Windows build, the `runtime_proxy.cpp` callers, or the full ctest suite. The test uses its own temp store, so nothing outside it was touched. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-24 18:02:29 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T17:14:03Z.

Review: COMMENTED


Verification review for commit 6c03c3c9d3b94c0915c3ea4a3a4810abde60a72f:

Scope & Audit

  • Tests-only diff (tests/startup_gamesave_persist.cpp, +1/-1): appends " x", "x ", and " double-lead" to bad[], exercising both x2w_save::valid_name and all six store refusal paths.
  • Zero production code changes, zero weakened assertions, zero temp-file leaks, clean-room/title-neutral.

Checks Executed

  • Linux:
    • git diff --check origin/main...HEAD: clean.
    • python3 -I tests/docs_links_check.py: passed (17 Markdown files, 363 links).
    • python3 -I tests/bidi_controls_check.py: passed (1,280 files, no bidirectional controls).
    • g++ -std=c++17 -Wall -Wextra -Isrc tests/startup_gamesave_persist.cpp + run with private TMPDIR: startup_gamesave_persist: ok, 0 warnings, 0 leaked files.
  • Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP):
    • Debug (--preset dev): startup_gamesave_persist built (4.56s, configure 1.77s); ctest --preset dev -R '^startup_gamesave_persist$' --no-tests=error: 1/1 passed (0.58s).
    • Release /O2 (--preset release): startup_gamesave_persist built (3.93s, configure 1.70s); ctest --preset release -R '^startup_gamesave_persist$' --no-tests=error: 1/1 passed (0.65s).
  • Mutation checks (local, restored after each run):
    1. Removed name.front() == ' ' in src/startup_stubs/save_store.h: failed with exit 1 (FAIL: x, FAIL: bad container name refused, etc.).
    2. Removed name.back() == ' ' in src/startup_stubs/save_store.h: failed with exit 1 (FAIL: x , FAIL: bad container name refused, etc.).

Verdict: 0 P1, 0 P2. Clean Tier B merge candidate.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6043964482 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1682#pullrequestreview-6043964482). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:14:03Z. **Review:** COMMENTED --- Verification review for commit `6c03c3c9d3b94c0915c3ea4a3a4810abde60a72f`: ### Scope & Audit - Tests-only diff (`tests/startup_gamesave_persist.cpp`, +1/-1): appends `" x"`, `"x "`, and `" double-lead"` to `bad[]`, exercising both `x2w_save::valid_name` and all six store refusal paths. - Zero production code changes, zero weakened assertions, zero temp-file leaks, clean-room/title-neutral. ### Checks Executed - **Linux**: - `git diff --check origin/main...HEAD`: clean. - `python3 -I tests/docs_links_check.py`: passed (17 Markdown files, 363 links). - `python3 -I tests/bidi_controls_check.py`: passed (1,280 files, no bidirectional controls). - `g++ -std=c++17 -Wall -Wextra -Isrc tests/startup_gamesave_persist.cpp` + run with private `TMPDIR`: `startup_gamesave_persist: ok`, 0 warnings, 0 leaked files. - **Windows Server 2025 (Build 26100, MSVC 14.44.35207 + D3D12 WARP)**: - **Debug (`--preset dev`)**: `startup_gamesave_persist` built (`4.56s`, configure `1.77s`); `ctest --preset dev -R '^startup_gamesave_persist$' --no-tests=error`: **1/1 passed** (`0.58s`). - **Release `/O2` (`--preset release`)**: `startup_gamesave_persist` built (`3.93s`, configure `1.70s`); `ctest --preset release -R '^startup_gamesave_persist$' --no-tests=error`: **1/1 passed** (`0.65s`). - **Mutation checks (local, restored after each run)**: 1. Removed `name.front() == ' '` in `src/startup_stubs/save_store.h`: failed with exit 1 (`FAIL: x`, `FAIL: bad container name refused`, etc.). 2. Removed `name.back() == ' '` in `src/startup_stubs/save_store.h`: failed with exit 1 (`FAIL: x `, `FAIL: bad container name refused`, etc.). Verdict: 0 P1, 0 P2. Clean Tier B merge candidate. AI-assisted; commands listed were executed locally.
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!1675
No description provided.