mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-18 23:07:07 -05:00
test(relinker): run the file writer's replacement test on a copy of itself
The running-executable replacement test copied /bin/sleep under the names "running" and "leftover" and started the copy. On Ubuntu 26.04 /bin/sleep is the uutils multi-call coreutils binary, which picks the utility from the file name of the path it was started through, not from argv[0], so the copy printed "coreutils: unknown program 'running'" and exited, and file_writer_binary and file_writer_text failed without ever replacing a running executable. The test now copies its own executable and starts it with a "wait" argument that sleeps, so it no longer depends on how a system binary reads its name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b6406a1715
commit
3abfe906bd
1 file changed
+6
-2
@@ -51,7 +51,7 @@ void requireRunningReplacement(const std::filesystem::path& directory, const TVa
|
||||
const auto output = directory / (leftover ? "leftover" : "running");
|
||||
if (leftover)
|
||||
std::ofstream(directory / "leftover.tmp", std::ios::binary) << "killed";
|
||||
std::filesystem::copy_file("/bin/sleep", output);
|
||||
std::filesystem::copy_file(std::filesystem::read_symlink("/proc/self/exe"), output);
|
||||
const auto permissions = std::filesystem::perms::owner_all | std::filesystem::perms::group_all;
|
||||
std::filesystem::permissions(output, permissions);
|
||||
const auto previous = readFile(output);
|
||||
@@ -59,7 +59,7 @@ void requireRunningReplacement(const std::filesystem::path& directory, const TVa
|
||||
if (child < 0)
|
||||
throw std::runtime_error("Cannot start the previous executable");
|
||||
if (child == 0) {
|
||||
execl(output.c_str(), "sleep", "30", nullptr);
|
||||
execl(output.c_str(), output.c_str(), "wait", nullptr);
|
||||
_exit(127);
|
||||
}
|
||||
std::error_code error;
|
||||
@@ -172,6 +172,10 @@ int main(int argc, char* argv[]) {
|
||||
try {
|
||||
if (argc != 2) throw std::runtime_error("Expected binary or text");
|
||||
const std::string mode = argv[1];
|
||||
if (mode == "wait") {
|
||||
sleep(30);
|
||||
return 0;
|
||||
}
|
||||
for (const std::size_t size : {std::size_t{3}, std::size_t{65536}}) {
|
||||
if (mode == "binary") {
|
||||
const std::vector<std::uint8_t> data(size, 0x41);
|
||||
|
||||
Reference in new issue
Block a user