test: accept a save name exactly at the length cap #1691

Closed
ChazY11 wants to merge 1 commit from upstream-pr/1698 into main
ChazY11 commented 2026-11-24 17:20:03 +00:00 (Migrated from github.com)

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


What

x2w_save::valid_name refuses a name longer than max_name_bytes (128). The fixture asserted only the too-long side:

expect(!x2w_save::valid_name(std::string(x2w_save::max_name_bytes + 1, 'a')), "name length is capped");

Changing the comparison in src/startup_stubs/save_store.h from > to >= leaves that green, so a legal 128-byte name
would be refused with nothing noticing. This adds the accepted side.

     expect(!x2w_save::valid_name(std::string(x2w_save::max_name_bytes + 1, 'a')), "name length is capped");
+    // The other side of that limit: a name of exactly the cap has to be accepted.
+    expect(x2w_save::valid_name(std::string(x2w_save::max_name_bytes, 'a')), "a name at the cap is accepted");

Tested

cmake --preset dev
cmake --build --preset dev --target startup_gamesave_persist
ctest --preset dev --no-tests=error -R '^startup_gamesave_persist$' -V
with the case, save_store.h untouched        PASSED
with the case, `>` changed to `>=`           FAILED   (rebuilt, binary timestamp checked)
reverted, plus the rest of the save tests    PASSED, with the two _system cases Skipped (77) as before

This is the same file and fixture as #1682; that one covered the space rules, this one the length boundary. If you would
rather see both in one change, tell me and I will fold them together.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6587461838 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1698). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:20:03Z. --- ## What `x2w_save::valid_name` refuses a name longer than `max_name_bytes` (128). The fixture asserted only the too-long side: ```cpp expect(!x2w_save::valid_name(std::string(x2w_save::max_name_bytes + 1, 'a')), "name length is capped"); ``` Changing the comparison in `src/startup_stubs/save_store.h` from `>` to `>=` leaves that green, so a legal 128-byte name would be refused with nothing noticing. This adds the accepted side. ```diff expect(!x2w_save::valid_name(std::string(x2w_save::max_name_bytes + 1, 'a')), "name length is capped"); + // The other side of that limit: a name of exactly the cap has to be accepted. + expect(x2w_save::valid_name(std::string(x2w_save::max_name_bytes, 'a')), "a name at the cap is accepted"); ``` ## Tested ```powershell cmake --preset dev cmake --build --preset dev --target startup_gamesave_persist ctest --preset dev --no-tests=error -R '^startup_gamesave_persist$' -V ``` ```text with the case, save_store.h untouched PASSED with the case, `>` changed to `>=` FAILED (rebuilt, binary timestamp checked) reverted, plus the rest of the save tests PASSED, with the two _system cases Skipped (77) as before ``` This is the same file and fixture as #1682; that one covered the space rules, this one the length boundary. If you would rather see both in one change, tell me and I will fold them together. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 18:02:36 +00:00
tedin7 commented 2026-11-24 18:02:37 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head f403f87f31ad284df42e8c1956f86efda6df4f69. Only tests/startup_gamesave_persist.cpp changes (+2/-0); no production code.

Linux limits. Linux x86_64. Built with x86_64-w64-mingw32-g++ -std=c++17 -Wall -Wextra -static -Isrc and run under wine: not Windows, not through CTest or CMake, not with MSVC. The two symlink/directory-link controls print "skipped" here, as the PR notes for the _system cases.

What I ran

  • Unmodified head: MinGW build with no warnings; wine run prints startup_gamesave_persist: ok, exit 0.
  • Mutation on src/startup_stubs/save_store.h line 41, name.size() > max_name_bytes -> >=, rebuilt and run: FAIL: a name at the cap is accepted, exit 1. Header restored, git status clean.
  • The new line sits next to the existing too-long assertion, uses max_name_bytes (128) rather than a literal, and weakens nothing; the other conditions in valid_name (separators, trailing dot, suffixes) cannot reject an all-a name, so the assertion isolates the length rule.

Findings

  • None blocking. The change does what the PR says: it pins the accepted side of the cap, and the off-by-one in either direction is now caught (the existing line covers + 1).
  • I did not check the claim about #1682 or the PowerShell/CTest numbers.

AI-assisted review; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044145805 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1698#pullrequestreview-6044145805). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T17:25:47Z. **Review:** COMMENTED --- Review of head `f403f87f31ad284df42e8c1956f86efda6df4f69`. Only `tests/startup_gamesave_persist.cpp` changes (+2/-0); no production code. **Linux limits.** Linux x86_64. Built with `x86_64-w64-mingw32-g++ -std=c++17 -Wall -Wextra -static -Isrc` and run under `wine`: not Windows, not through CTest or CMake, not with MSVC. The two symlink/directory-link controls print "skipped" here, as the PR notes for the _system cases. **What I ran** - Unmodified head: MinGW build with no warnings; wine run prints `startup_gamesave_persist: ok`, exit 0. - Mutation on `src/startup_stubs/save_store.h` line 41, `name.size() > max_name_bytes` -> `>=`, rebuilt and run: `FAIL: a name at the cap is accepted`, exit 1. Header restored, `git status` clean. - The new line sits next to the existing too-long assertion, uses `max_name_bytes` (128) rather than a literal, and weakens nothing; the other conditions in `valid_name` (separators, trailing dot, suffixes) cannot reject an all-`a` name, so the assertion isolates the length rule. **Findings** - None blocking. The change does what the PR says: it pins the accepted side of the cap, and the off-by-one in either direction is now caught (the existing line covers `+ 1`). - I did not check the claim about #1682 or the PowerShell/CTest numbers. AI-assisted review; commands listed were executed locally.
ChazY11 commented 2026-11-24 18:02:57 +00:00 (Migrated from github.com)

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


Superseded by #1704, which covers this cap from both sides together with the other valid_name rules that had no case. Closing so there is one change to review.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139185117 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1698#issuecomment-7139185117). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:25:57Z. --- Superseded by #1704, which covers this cap from both sides together with the other `valid_name` rules that had no case. Closing so there is one change to review.

Pull request closed

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!1691
No description provided.