test(relinker): run the file writer's replacement test on a copy of itself #6027
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6027"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-14T19:33:07Z.
What
file_writer_binaryandfile_writer_textfail on Ubuntu 26.04 before they check thatFileWriterreplaces a running executable:Depending on timing, the second line is
Running executable stoppedinstead.The running-executable check that #5018 added (
requireRunningReplacementinFileWriterTests.cpp) copies/bin/sleeptorunningand toleftoverand starts the copy withexecl(output, "sleep", "30"). While the copy runs, the test replaces it withFileWriter. On Ubuntu 26.04,/bin/sleepresolves to/usr/lib/cargo/bin/coreutils/sleepfromrust-coreutils0.8.0-0ubuntu3. That file is one multi-call binary with 115 hard links. I checked how it picks the utility:running, started with argv[0]sleep:coreutils: unknown program 'running', exit code 1sleepthat points to that copy: runssleep/bin/sleepstarted with argv[0]running: runssleepIt 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, asOwnExecutableinGuestSystemExit.cppdoes) and starts it with awaitargument. In that modemainsleeps 30 s, assleep 30did. 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.cppfrom before #5018, both tests fail withReplacing a running executable failed: Cannot open output file: /tmp/anyps5-file-writer-<pid>/running. WithFileWriter.cppfrom #5018's first commit (92618d25c, fixed.tmpname), both fail on.../leftover.CI passes these tests because its Linux hosts run Ubuntu 24.04, where
/bin/sleepis GNU sleep. In build run 38613931595 (push of32e810db4, after #5018), therelinker (ubuntu-latest, g++)job ran on imageubuntu-24.04. Thelinuxjob ran on self-hosted runneranyps5-linux-11(GCC 13.3.0,mesa-vulkan-drivers25.2.8-0ubuntu0.24.04.4). Both passedfile_writer_binaryandfile_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 withctest --test-dir <dir> --output-on-failure --timeout 120.mainb6406a171: 168/170 tests pass. The two failures arefile_writer_binaryandfile_writer_text, both withcoreutils: unknown program 'running'; one then stops withRunning executable stopped, the other withThe previous executable did not start.b6406a171: 170/170 tests pass.file_writer_binaryandfile_writer_textpass 25 of 25 repeats (--repeat until-fail:25). Nowaitprocesses oranyps5-file-writer-*directories are left behind.FileWriter.cppversions, on the same base.main'stools/check_conventions.py --base origin/mainpasses, including--titleand--body.CMake builds
file_writer_testsonly whenCMAKE_SYSTEM_NAMEisLinux, 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 onubuntu-latestor in the linux job.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T21:14:26Z.
Checked the diff (
FileWriterTests.cpponly): the test now copies its own executable and runs it in awaitmode instead of relying on how/bin/sleepreads 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.