diff options
| author | cirakg <cirakg@cirakg.xyz> | 2026-11-02 17:52:11 +0100 |
|---|---|---|
| committer | cirakg <cirakg@cirakg.xyz> | 2026-11-02 17:52:11 +0100 |
| commit | 7fe395e5ab7a42a73262be3ca69b640d2ccd6ec2 (patch) | |
| tree | f0b9eea55b3e1864492d19842950562d3cb17427 /src/tests/core | |
| parent | bf2a94eb29f13073848a16754c983d53a3fc6d44 (diff) | |
| parent | ead60c761e4d58cb4adc8b3b08f67dc10cf1e36b (diff) | |
Merge upstream Djihads80/Eglantine nx2 into nx2
Diffstat (limited to 'src/tests/core')
| -rw-r--r-- | src/tests/core/nup_writer.cpp | 53 |
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"); +} |
