test: cover a device name with a trailing space #1693

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

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


What

valid_name strips trailing spaces from the part of the name before the first dot, then compares it with CON, PRN,
AUX and NUL, because Windows resolves "CON .txt" to the device. Deleting that loop keeps
startup_gamesave_persist green:

while (!stem.empty() && stem.back() == ' ') stem.pop_back();   // removed -> no test fails

This adds two names to the refused list so the loop is guarded:

-    const char* bad[] = {..., " x", "x ", "  double-lead"};
+    const char* bad[] = {..., " x", "x ", "  double-lead", "CON .txt", "nul .dat"};

Tested

cmake --preset dev
cmake --build --preset dev --target startup_gamesave_persist
ctest --preset dev --no-tests=error -R '^startup_gamesave_' -V
with the cases, save_store.h untouched        PASSED
with the cases, stem strip loop disabled      FAILED   (rebuilt; binary timestamp checked)
reverted, full build, all save tests          PASSED, with submit_system and read_async_system Skipped (77)

The revert step matters: after a sweep, a binary that was built against the mutant has to be rebuilt before any other
test runs, or an unrelated test can fail on the leftover. I hit that here and rebuilt the whole preset before quoting the
final numbers.

Notes

  • AI-assisted.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6587528260 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1700). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:23:44Z. --- ## What `valid_name` strips trailing spaces from the part of the name before the first dot, then compares it with `CON`, `PRN`, `AUX` and `NUL`, because Windows resolves `"CON .txt"` to the device. Deleting that loop keeps `startup_gamesave_persist` green: ```cpp while (!stem.empty() && stem.back() == ' ') stem.pop_back(); // removed -> no test fails ``` This adds two names to the refused list so the loop is guarded: ```diff - const char* bad[] = {..., " x", "x ", " double-lead"}; + const char* bad[] = {..., " x", "x ", " double-lead", "CON .txt", "nul .dat"}; ``` ## Tested ```powershell cmake --preset dev cmake --build --preset dev --target startup_gamesave_persist ctest --preset dev --no-tests=error -R '^startup_gamesave_' -V ``` ```text with the cases, save_store.h untouched PASSED with the cases, stem strip loop disabled FAILED (rebuilt; binary timestamp checked) reverted, full build, all save tests PASSED, with submit_system and read_async_system Skipped (77) ``` The revert step matters: after a sweep, a binary that was built against the mutant has to be rebuilt before any other test runs, or an unrelated test can fail on the leftover. I hit that here and rebuilt the whole preset before quoting the final numbers. ## Notes - AI-assisted.
upstream-sync closed this pull request 2026-11-24 18:02:38 +00:00
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:26:00Z.


Superseded by #1704, which keeps these two cases and adds the device-name digit boundaries next to them. Closing so there is one change to review.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7139186512 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1700#issuecomment-7139186512). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T17:26:00Z. --- Superseded by #1704, which keeps these two cases and adds the device-name digit boundaries next to them. 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!1693
No description provided.