aboutsummaryrefslogtreecommitdiff
path: root/src/tests/core/nup_writer.cpp
diff options
context:
space:
mode:
authorkraibse <33869366+kraibse@users.noreply.github.com>2026-11-02 17:23:47 +0100
committerkraibse <33869366+kraibse@users.noreply.github.com>2026-11-02 17:23:47 +0100
commit4267169006fc4ed43f6d810e08426fb8058de9c0 (patch)
treeeb348a7667b10888b6c06b2d8a56397847c1e6b8 /src/tests/core/nup_writer.cpp
parentcaed5a34484942d3ecf9b9a84c83f31d1a6e3020 (diff)
file_sys: let the NUP packer override and probe the name, icon and version
PackOptions::metadata overrides the title name, icon and display version found in the dump. A version override is written to the base and to the newest update, since the NUP loader reads the version from the newest update first. ProbeMetadata reads what a dump would be packed with, the version coming from the newest update that reports one, else the base. Assisted-by: Claude Sonnet 5.5 (wrote the metadata overrides, ProbeMetadata and their test)
Diffstat (limited to 'src/tests/core/nup_writer.cpp')
-rw-r--r--src/tests/core/nup_writer.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/tests/core/nup_writer.cpp b/src/tests/core/nup_writer.cpp
index ce1a0717ed..bb0148139b 100644
--- a/src/tests/core/nup_writer.cpp
+++ b/src/tests/core/nup_writer.cpp
@@ -390,3 +390,34 @@ TEST_CASE("NUP output is reproducible", "[nup]") {
}
REQUIRE(hex == "df8446903ab2c39a51af0304935eb4aa5d8ead105440976ceae7ab97133f6143");
}
+
+TEST_CASE("NUP writes metadata overrides to the base and the newest update", "[nup]") {
+ TempDir t;
+ const auto root = t.path / "Game";
+ MakeDump(root);
+ const auto probed = FileSys::Nup::ProbeMetadata(root);
+ REQUIRE(probed.title_name.empty());
+ REQUIRE(probed.icon.empty());
+ // The version comes from the RomFS resource size table of the newest update that has one.
+ REQUIRE(probed.display_version == "1.1.0");
+ REQUIRE(probed.version_source == "update 65536");
+
+ FileSys::Nup::PackOptions options;
+ options.metadata.title_name = "Custom Name";
+ options.metadata.icon = {0xFF, 0xD8, 0xFF, 0xD9};
+ options.metadata.display_version = "9.8.7";
+ const auto archive = t.path / "Game.nup";
+ REQUIRE(FileSys::Nup::PackDump(root, archive, options) == FileSys::Nup::PackResult::Success);
+
+ FileSys::RealVfsFilesystem real;
+ NupContainer nup{real.OpenFile(archive.string(), FileSys::OpenMode::Read)};
+ REQUIRE(nup.GetStatus() == Loader::ResultStatus::Success);
+ const auto& packages = nup.GetPackages();
+ REQUIRE(packages.size() == 4);
+ REQUIRE(packages[0].title_name == "Custom Name");
+ REQUIRE(packages[0].icon == options.metadata.icon);
+ REQUIRE(packages[0].display_version == "9.8.7");
+ REQUIRE(packages[2].version == 131072);
+ REQUIRE(packages[2].display_version == "9.8.7");
+ REQUIRE(packages[1].display_version == "1.1.0");
+}