From 8b294eb5b86ebd9036a73dce7dfbf7d8fc94b7b4 Mon Sep 17 00:00:00 2001 From: Augusto Domingos Date: Sat, 19 Sep 2026 15:29:30 +0200 Subject: [PATCH] Add unicode path regression coverage --- src/main.cpp | 2 +- tests/KernelFileSystemTests.cpp | 39 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 34af5582a..0eb3a2e37 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -238,7 +238,7 @@ static bool ParseArgs(int argc, char* argv[], RunOptions& options, bool& show_he ::printf("--game-patch must point to an existing file: %s\n", value.c_str()); return false; } - options.game_patch = value; + options.game_patch = path; } else if (arg == "--screen-width") { options.config.screen_width = static_cast(Common::ToInt32(value)); } else if (arg == "--screen-height") { diff --git a/tests/KernelFileSystemTests.cpp b/tests/KernelFileSystemTests.cpp index a673bc39f..9b4bf1422 100644 --- a/tests/KernelFileSystemTests.cpp +++ b/tests/KernelFileSystemTests.cpp @@ -4,6 +4,7 @@ #include "common/logging/log.h" #include "common/subsystems.h" #include "common/threads.h" +#include "common/stringUtils.h" #include "graphics/presentation/window/windowInternal.h" #include "kernel/fileSystem.h" #include "libs/errno.h" @@ -128,6 +129,43 @@ void CheckMountRoot(const std::filesystem::path &root) { FileSystem::Umount("/app0"); } +void CheckUnicodePaths(const std::filesystem::path &root) { + constexpr std::string_view HostDirectory = + "Test\xc3\xa9-\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e"; + constexpr std::string_view GuestFilename = + "asset-\xc3\xa9-\xe6\x97\xa5\xe6\x9c\xac\xe8\xaa\x9e.bin"; + + const auto unicode_root = + root / Common::PathFromUtf8(HostDirectory); + + Check(std::filesystem::create_directories(unicode_root), + "create Unicode host directory"); + + CheckMountRoot(unicode_root); + + const auto native_file = + unicode_root / Common::PathFromUtf8(GuestFilename); + + Common::File fixture; + Check(fixture.Create(native_file), "create Unicode filename"); + fixture.Close(); + + FileSystem::Mount(unicode_root, "/app0"); + + const auto guest_file = + std::string("/app0/") + std::string(GuestFilename); + + Check(FileSystem::GetRealFilename(guest_file) == native_file, + "resolve Unicode guest path"); + + const int fd = FileSystem::KernelOpen(guest_file.c_str(), 0, 0); + Check(fd >= 3, "open Unicode guest path"); + Check(FileSystem::KernelClose(fd) == OK, + "close Unicode guest path"); + + FileSystem::Umount("/app0"); +} + void CheckDirectoryStream(const std::filesystem::path &root) { const auto directory = root / "directory-stream"; Check(std::filesystem::create_directory(directory), @@ -387,6 +425,7 @@ int main() { TempDirectory temporary; FileSystem::Initialize(); CheckMountRoot(temporary.Path()); + CheckUnicodePaths(temporary.Path()); CheckDirectoryStream(temporary.Path()); CheckAprPaths(temporary.Path()); FileSystem::Mount(temporary.Path(), "/savedata0");