Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/relinker/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ int Run(const int argc, char* argv[]) {
for (const auto& executable : executables) outputPaths.push_back(Io::NativePath(executable.OutputPath));
for (const auto& artifact : guestArtifacts) outputPaths.push_back(artifact.Path);
outputPaths.insert(outputPaths.end(), registryPaths.begin(), registryPaths.end());
outputPaths.insert(outputPaths.end(), neededPaths.begin(), neededPaths.end());
if (desktopEntry) {
outputPaths.push_back(desktopEntry->IconPath);
outputPaths.push_back(desktopEntry->EntryPath);
Expand Down
32 changes: 31 additions & 1 deletion core/relinker/relinker/tests/test_output_collisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def prepare(case, windows):
"module": case / "app0/sce_module/sample.prx.guest.prx",
"registry": case / "output.registry.json",
"module-registry": case / "output.sample.prx.guest.prx.registry.json",
"needed": case / "output.needed.json",
"module-needed": case / "output.sample.prx.guest.prx.needed.json",
}
if windows:
paths["diagnostics"] = case / "windows-diagnostics-imports.txt"
Expand Down Expand Up @@ -53,6 +55,34 @@ def main():
checked = 0
with tempfile.TemporaryDirectory(prefix="anyps5-output-collisions-") as directory:
work = Path(directory)
for windows, existing in itertools.product((False, True), repeat=2):
case = work / f"needed-secondary-{windows}-{existing}"
case.mkdir()
source = case / "input.elf"
secondary = case / "output.needed"
source.write_bytes(main_fixture())
secondary.write_bytes(main_fixture())
module = case / "sce_module/sample.prx"
module.parent.mkdir()
module.write_bytes(guest_fixture(PLAIN_SITE))
outputs = [case / name for name in ("output.json", "output.needed.json", "output.registry.json",
"output.needed.registry.json", "output.needed.needed.json",
"app0/sce_module/sample.prx.guest.prx",
"output.sample.prx.guest.prx.registry.json",
"output.sample.prx.guest.prx.needed.json")]
if existing:
for path in outputs:
path.parent.mkdir(parents=True, exist_ok=True)
path.write_bytes(b"previous output")
result = subprocess.run([str(relinker), *(["--windows"] if windows else []), "--registry",
"--executable", secondary.name, str(source), str(outputs[0])], cwd=case,
capture_output=True, text=True, timeout=20)
assert result.returncode == 2 and "Output paths collide" in result.stderr, (
windows, existing, result.returncode, result.stdout, result.stderr)
for path in outputs:
assert path.read_bytes() == b"previous output" if existing else not path.exists(), path
assert source.read_bytes() == secondary.read_bytes() == main_fixture()
assert module.read_bytes() == guest_fixture(PLAIN_SITE)
for windows in (False, True):
command, paths, inputs = prepare(work / f"{windows}-control", windows)
links = paths["executable"].parent / "separate-links"
Expand All @@ -65,7 +95,7 @@ def main():
assert result.returncode == 0, (result.stdout, result.stderr)
for name in ("executable", "module"):
assert paths[name].read_bytes().startswith(b"MZ" if windows else b"\x7fELF")
for name in ("registry", "module-registry"):
for name in ("registry", "module-registry", "needed", "module-needed"):
json.loads(paths[name].read_text())
for path, original in inputs.items():
assert path.read_bytes() == original
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def prepare_secondary(case, windows):
options.extend(["--executable", source.name])
paths[name] = case / f"{source.name}{paths['executable'].suffix}"
paths[f"{name}-registry"] = case / f"{source.name}.registry.json"
paths[f"{name}-needed"] = case / f"{source.name}.needed.json"
if not windows:
icon = case / "sce_sys/icon0.png"
inputs[icon] = icon.read_bytes()
Expand All @@ -46,7 +47,7 @@ def main():
for name in ("executable", "module", *sorted(secondary)):
assert paths[name].read_bytes().startswith(b"MZ" if windows else b"\x7fELF"), paths[name]
for name, path in paths.items():
if "registry" in name:
if "registry" in name or "needed" in name:
json.loads(path.read_text())
for path, original in inputs.items():
assert path.read_bytes() == original, path
Expand Down
Loading