aboutsummaryrefslogtreecommitdiff
path: root/src/tests/core/nup_writer.cpp
diff options
context:
space:
mode:
authorcirakg <cirakg@cirakg.xyz>2026-11-02 22:58:00 +0100
committercirakg <cirakg@cirakg.xyz>2026-11-02 22:58:00 +0100
commitcf0502ad274022480cb264e0e75390863cd49608 (patch)
treefd672b27a4cbddffb3acbb09ee59d3dd96ba489c /src/tests/core/nup_writer.cpp
parentff234849d6a41d2c2d29cf09408ac66e202d68e7 (diff)
parent0da830e94169b9040007b69c8147ab00b6574e36 (diff)
Merge branch 'nx2' into ldn/room-handshake
Diffstat (limited to 'src/tests/core/nup_writer.cpp')
-rw-r--r--src/tests/core/nup_writer.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/tests/core/nup_writer.cpp b/src/tests/core/nup_writer.cpp
index ce1a0717ed..c0230d8694 100644
--- a/src/tests/core/nup_writer.cpp
+++ b/src/tests/core/nup_writer.cpp
@@ -390,3 +390,56 @@ 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");
+}
+
+TEST_CASE("NUP probes the version from the game data list tag", "[nup]") {
+ TempDir t;
+ const auto root = t.path / "Game";
+ Put(root / "base/exefs/main", "main");
+ Put(root / "base/exefs/main.npdm", Npdm(TitleId));
+ Put(root / "base/romfs/GameData/GameDataList.Product.100.byml.zs", "x");
+ Put(root / "base/romfs/System/Resource/ResourceSizeTable.Product.rsizetable.zs", "x");
+ Put(root / "updates/458752/exefs/main", "main");
+ Put(root / "updates/458752/exefs/main.npdm", Npdm(TitleId));
+ Put(root / "updates/458752/romfs/GameData/GameDataList.Product.320.byml.zs", "x");
+ Put(root / "updates/458752/romfs/GameData/GameDataList.Product.320.revision.txt", "1");
+
+ auto probed = FileSys::Nup::ProbeMetadata(root);
+ REQUIRE(probed.display_version == "3.2.0");
+ REQUIRE(probed.version_source == "update 458752");
+
+ fs::remove_all(root / "updates");
+ probed = FileSys::Nup::ProbeMetadata(root);
+ REQUIRE(probed.display_version == "1.0.0");
+ REQUIRE(probed.version_source == "base");
+}