test(relinker): run the file writer's replacement test on a copy of itself #6027

Merged
nikowolf123 merged 1 commit from upstream-pr/6027 into main 2026-10-17 03:27:59 +00:00
nikowolf123 commented 2026-10-14 19:33:07 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-14T19:33:07Z.


What

file_writer_binary and file_writer_text fail on Ubuntu 26.04 before they check that FileWriter replaces a running executable:

coreutils: unknown program 'running'
The previous executable did not start

Depending on timing, the second line is Running executable stopped instead.

The running-executable check that #5018 added (requireRunningReplacement in FileWriterTests.cpp) copies /bin/sleep to running and to leftover and starts the copy with execl(output, "sleep", "30"). While the copy runs, the test replaces it with FileWriter. On Ubuntu 26.04, /bin/sleep resolves to /usr/lib/cargo/bin/coreutils/sleep from rust-coreutils 0.8.0-0ubuntu3. That file is one multi-call binary with 115 hard links. I checked how it picks the utility:

  • a copy named running, started with argv[0] sleep: coreutils: unknown program 'running', exit code 1
  • a symlink named sleep that points to that copy: runs sleep
  • /bin/sleep started with argv[0] running: runs sleep

It goes by the file name of the path it was started through, not by argv[0]. So the copy exits at once, and the test never gets to replace a running executable.

The test now copies its own executable (/proc/self/exe, as OwnExecutable in GuestSystemExit.cpp does) and starts it with a wait argument. In that mode main sleeps 30 s, as sleep 30 did. Nothing else in the test changes. It no longer depends on how a system binary reads its name.

The check still catches both failures that #5018 fixed. With the new test and FileWriter.cpp from before #5018, both tests fail with Replacing a running executable failed: Cannot open output file: /tmp/anyps5-file-writer-<pid>/running. With FileWriter.cpp from #5018's first commit (92618d25c, fixed .tmp name), both fail on .../leftover.

CI passes these tests because its Linux hosts run Ubuntu 24.04, where /bin/sleep is GNU sleep. In build run 38613931595 (push of 32e810db4, after #5018), the relinker (ubuntu-latest, g++) job ran on image ubuntu-24.04. The linux job ran on self-hosted runner anyps5-linux-11 (GCC 13.3.0, mesa-vulkan-drivers 25.2.8-0ubuntu0.24.04.4). Both passed file_writer_binary and file_writer_text. On Ubuntu 26.04 both tests fail, and CI would fail the same way if either host moved to 26.04. #5200's Tested section lists these two failures on Ubuntu 26.04.

Tested

WSL2 Ubuntu 26.04, g++ 15.2.0, CMake 4.2.3. Relinker-only build with the configure flags of CI's relinker job (-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++ -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON), tested with ctest --test-dir <dir> --output-on-failure --timeout 120.

  • main b6406a171: 168/170 tests pass. The two failures are file_writer_binary and file_writer_text, both with coreutils: unknown program 'running'; one then stops with Running executable stopped, the other with The previous executable did not start.
  • This change on b6406a171: 170/170 tests pass. file_writer_binary and file_writer_text pass 25 of 25 repeats (--repeat until-fail:25). No wait processes or anyps5-file-writer-* directories are left behind.
  • The two mutation runs above, against the earlier FileWriter.cpp versions, on the same base.
  • main's tools/check_conventions.py --base origin/main passes, including --title and --body.

CMake builds file_writer_tests only when CMAKE_SYSTEM_NAME is Linux, so Windows and macOS do not run it. I did not run it on Ubuntu 24.04 myself. CI runs it there, in the relinker job on ubuntu-latest or in the linux job.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes. Written with Claude Code; I reviewed every line and ran the tests above.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4863397963 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6027). Originally posted by [nikowolf123](https://github.com/nikowolf123) on 2026-10-14T19:33:07Z. --- ### What `file_writer_binary` and `file_writer_text` fail on Ubuntu 26.04 before they check that `FileWriter` replaces a running executable: ``` coreutils: unknown program 'running' The previous executable did not start ``` Depending on timing, the second line is `Running executable stopped` instead. The running-executable check that #5018 added (`requireRunningReplacement` in `FileWriterTests.cpp`) copies `/bin/sleep` to `running` and to `leftover` and starts the copy with `execl(output, "sleep", "30")`. While the copy runs, the test replaces it with `FileWriter`. On Ubuntu 26.04, `/bin/sleep` resolves to `/usr/lib/cargo/bin/coreutils/sleep` from `rust-coreutils` 0.8.0-0ubuntu3. That file is one multi-call binary with 115 hard links. I checked how it picks the utility: - a copy named `running`, started with argv[0] `sleep`: `coreutils: unknown program 'running'`, exit code 1 - a symlink named `sleep` that points to that copy: runs `sleep` - `/bin/sleep` started with argv[0] `running`: runs `sleep` It goes by the file name of the path it was started through, not by argv[0]. So the copy exits at once, and the test never gets to replace a running executable. The test now copies its own executable (`/proc/self/exe`, as `OwnExecutable` in `GuestSystemExit.cpp` does) and starts it with a `wait` argument. In that mode `main` sleeps 30 s, as `sleep 30` did. Nothing else in the test changes. It no longer depends on how a system binary reads its name. The check still catches both failures that #5018 fixed. With the new test and `FileWriter.cpp` from before #5018, both tests fail with `Replacing a running executable failed: Cannot open output file: /tmp/anyps5-file-writer-<pid>/running`. With `FileWriter.cpp` from #5018's first commit (92618d25c, fixed `.tmp` name), both fail on `.../leftover`. CI passes these tests because its Linux hosts run Ubuntu 24.04, where `/bin/sleep` is GNU sleep. In [build run 38613931595](https://github.com/boykopovar/AnyPS5/actions/runs/38613931595) (push of 32e810db4, after #5018), the `relinker (ubuntu-latest, g++)` job ran on image `ubuntu-24.04`. The `linux` job ran on self-hosted runner `anyps5-linux-11` (GCC 13.3.0, `mesa-vulkan-drivers` 25.2.8-0ubuntu0.24.04.4). Both passed `file_writer_binary` and `file_writer_text`. On Ubuntu 26.04 both tests fail, and CI would fail the same way if either host moved to 26.04. #5200's Tested section lists these two failures on Ubuntu 26.04. ### Tested WSL2 Ubuntu 26.04, g++ 15.2.0, CMake 4.2.3. Relinker-only build with the configure flags of CI's relinker job (`-G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=g++ -DANYPS5_RELINKER_ONLY=ON -DBUILD_TESTING=ON`), tested with `ctest --test-dir <dir> --output-on-failure --timeout 120`. - `main` b6406a171: 168/170 tests pass. The two failures are `file_writer_binary` and `file_writer_text`, both with `coreutils: unknown program 'running'`; one then stops with `Running executable stopped`, the other with `The previous executable did not start`. - This change on b6406a171: 170/170 tests pass. `file_writer_binary` and `file_writer_text` pass 25 of 25 repeats (`--repeat until-fail:25`). No `wait` processes or `anyps5-file-writer-*` directories are left behind. - The two mutation runs above, against the earlier `FileWriter.cpp` versions, on the same base. - `main`'s `tools/check_conventions.py --base origin/main` passes, including `--title` and `--body`. CMake builds `file_writer_tests` only when `CMAKE_SYSTEM_NAME` is `Linux`, so Windows and macOS do not run it. I did not run it on Ubuntu 24.04 myself. CI runs it there, in the relinker job on `ubuntu-latest` or in the linux job. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes. Written with Claude Code; I reviewed every line and ran the tests above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-16 21:14:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T21:14:26Z.


Checked the diff (FileWriterTests.cpp only): the test now copies its own executable and runs it in a wait mode instead of relying on how /bin/sleep reads its name. Relinker build and scoped ctest are green (136/136), and the relinker jobs on ubuntu/windows/macos pass; merging.

#6877 makes the same change and was opened later, so it will be closed as a duplicate.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6224815871 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/6027#issuecomment-6224815871). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T21:14:26Z. --- Checked the diff (`FileWriterTests.cpp` only): the test now copies its own executable and runs it in a `wait` mode instead of relying on how `/bin/sleep` reads its name. Relinker build and scoped ctest are green (136/136), and the relinker jobs on ubuntu/windows/macos pass; merging. #6877 makes the same change and was opened later, so it will be closed as a duplicate.
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
boykopovar/AnyPS5!6027
No description provided.