diff --git a/core/relinker/cli/tests/CliArgsTests.cpp b/core/relinker/cli/tests/CliArgsTests.cpp index 433118159..305b66e71 100644 --- a/core/relinker/cli/tests/CliArgsTests.cpp +++ b/core/relinker/cli/tests/CliArgsTests.cpp @@ -224,6 +224,41 @@ void windowsFixedBase() { } +void moduleDirectories() { + const auto args = parse({"--module-dir", "Media/Plugins", "input.elf", "--module-dir", "extra", "output.elf"}); + require(args.moduleDirectories == std::vector{"Media/Plugins", "extra"}, "--module-dir directories were not recorded in order"); + require(args.inputPath == "input.elf" && args.outputPath == "output.elf", "--module-dir consumed a positional path"); + expectThrows({"--module-dir"}, "--module-dir requires a directory"); + expectThrows({"--skip-sce-module", "--module-dir", "Media/Plugins", "input.elf", "output.elf"}, "--module-dir conflicts with --skip-sce-module"); + expectThrows({"--module-dir", "Media/Plugins", "--skip-sce-module", "input.elf", "output.elf"}, "--module-dir conflicts with --skip-sce-module"); +} + +void sceModulePath() { + const auto args = parse({"--sce-module-path", "modules", "input.elf", "output.elf"}); + require(args.sceModulePath == "modules", "--sce-module-path value was not captured"); + expectThrows({"--sce-module-path"}, "--sce-module-path requires a nonempty path"); + expectThrows({"--sce-module-path", "", "input.elf", "output.elf"}, "--sce-module-path requires a nonempty path"); + expectThrows({"--sce-module-path", "--registry", "input.elf", "output.elf"}, "--sce-module-path requires a nonempty path"); + expectThrows({"--sce-module-path", "a", "--sce-module-path", "b", "input.elf", "output.elf"}, "--sce-module-path must be specified once"); + expectThrows({"--skip-sce-module", "--sce-module-path", "modules", "input.elf", "output.elf"}, "--sce-module-path conflicts with --skip-sce-module"); + expectThrows({"--sce-module-path", "modules", "--skip-sce-module", "input.elf", "output.elf"}, "--sce-module-path conflicts with --skip-sce-module"); +} + +void targetSelection() { + const auto macos = parse({"--macos", "input.elf", "output.elf"}); + require(macos.toMacos && !macos.toWindows, "--macos did not select only the macOS target"); + const auto rosetta = parse({"--to-rosetta", "input.elf", "output.elf"}); + require(rosetta.toRosetta && rosetta.toIntel, "--to-rosetta did not imply --to-intel"); + const auto rosettaOnMacos = parse({"--macos", "--to-rosetta", "input.elf", "output.elf"}); + require(rosettaOnMacos.toMacos && rosettaOnMacos.toRosetta && rosettaOnMacos.toIntel, "--to-rosetta was rejected with --macos"); + const std::string targetConflict = "--windows conflicts with --macos"; + expectThrows({"--windows", "--macos", "input.elf", "output.elf"}, targetConflict); + expectThrows({"--macos", "--windows", "input.elf", "output.elf"}, targetConflict); + const std::string rosettaConflict = "--to-rosetta conflicts with --windows"; + expectThrows({"--windows", "--to-rosetta", "input.elf", "output.elf"}, rosettaConflict); + expectThrows({"--to-rosetta", "--windows", "input.elf", "output.elf"}, rosettaConflict); +} + int main() { try { defaults(); @@ -238,6 +273,9 @@ int main() { excludeSceModuleConsumesNextTokenVerbatim(); excludeSceModuleWithoutValue(); excludeConflictsWithSkip(); + moduleDirectories(); + sceModulePath(); + targetSelection(); executables(); unusedFilter(); unusedFilterRejectsBadValues();