From e33ff303e61f9c3541686334ca788509b3db3901 Mon Sep 17 00:00:00 2001 From: Jan Laupetin Date: Tue, 23 Dec 2025 21:09:11 +0100 Subject: [PATCH] chore: add ExtendAndDereference system test --- .../ExtendAndDereference/CombinedZoneT6.zone | 4 + .../Game/T6/ExtendAndDereference/README.md | 9 ++ .../ZoneWithMaterialT6.zone | 4 + .../ExtendAndDereference/ZoneWithTechsetT6.ff | Bin 0 -> 1664 bytes .../ZoneWithTechsetT6.zone | 3 + .../ExtendAndDereference/materials/test.json | 77 ++++++++++++ .../Game/T6/ExtendAndDereferenceT6.cpp | 119 ++++++++++++++++++ 7 files changed, 216 insertions(+) create mode 100644 test/SystemTests/Game/T6/ExtendAndDereference/CombinedZoneT6.zone create mode 100644 test/SystemTests/Game/T6/ExtendAndDereference/README.md create mode 100644 test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithMaterialT6.zone create mode 100644 test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithTechsetT6.ff create mode 100644 test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithTechsetT6.zone create mode 100644 test/SystemTests/Game/T6/ExtendAndDereference/materials/test.json create mode 100644 test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp diff --git a/test/SystemTests/Game/T6/ExtendAndDereference/CombinedZoneT6.zone b/test/SystemTests/Game/T6/ExtendAndDereference/CombinedZoneT6.zone new file mode 100644 index 00000000..eb46c78d --- /dev/null +++ b/test/SystemTests/Game/T6/ExtendAndDereference/CombinedZoneT6.zone @@ -0,0 +1,4 @@ +>game,T6 + +techniqueset,trivial_floatz_2992w610 +material,test diff --git a/test/SystemTests/Game/T6/ExtendAndDereference/README.md b/test/SystemTests/Game/T6/ExtendAndDereference/README.md new file mode 100644 index 00000000..545ba1de --- /dev/null +++ b/test/SystemTests/Game/T6/ExtendAndDereference/README.md @@ -0,0 +1,9 @@ +# Extend and dereference system test + +This makes sure that when reusing assets from an existing zone, asset dependencies that are references can be overwritten to be non-references. + +In this case: + +- The zone `ZoneWithTechsetT6` contains the techniqueset `trivial_floatz_2992w610` +- The zone `ZoneWithMaterialT6` contains the material `test` and with a reference to its techniqueset `,trivial_floatz_2992w610` +- The final zone `CombinedZoneT6` is built while loading both of the other fastfile and is expected to contain both the material `test` with a reference to a (actual asset, not a reference) techniqueset `trivial_floatz_2992w610` diff --git a/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithMaterialT6.zone b/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithMaterialT6.zone new file mode 100644 index 00000000..f29d47a8 --- /dev/null +++ b/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithMaterialT6.zone @@ -0,0 +1,4 @@ +>game,T6 + +ignore,ZoneWithTechsetT6 +material,test diff --git a/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithTechsetT6.ff b/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithTechsetT6.ff new file mode 100644 index 0000000000000000000000000000000000000000..096666cc856b6fb1de2a29579a349f14e3df9b9b GIT binary patch literal 1664 zcmc)K2_q8<007|4eU;^y$zC}kcb0q3h2)wmS&qzTL&=elxs_XHG1u^>xl$rAN12JF z%++!vy;%npk!d2wd;j8nKjJ%&z+!K}^z`lm0Dx^l06+ocb*o6tMx#eRSQy2+Ip(Nz z49WAmc?`Y6{!;to@m3iX)5@&q!pUh*Z)S|)wCi8H`(6KK@o*EWsk;unnC?L7{8YQf z#Z?Nq1Gu9}(u;guJN-1y+d_%%kxufQ=BPL=b(xiI{cCnqO@-Os?P<2*=)(NlG+RgR zmJO5MiA3y?QPOcwT`|?>tJPt45Vwsf^>}Q0>UJ~3${yw*k9?k3zRR(E8~Z80$V}|_ z#sx85drnatZ?i-oe8P6t87R;BIv^ptU^;ALPxGOsTtkD@J*EdUWiB@MA2{inxlVM0 ziDPwwv6zRA^I7i3C%bGWo@X@U?$Cf53KA|?_Kb?02iklN9S!fI$yXeUw$zJY=nB38o3~K(4dnC8QmzEHOGXLuoA^3>6@~{zvtqTb>zMTdu&@pRwtxzt%%K8~_ zOYNZas@*xbzh3%LEoOaSK1N6-nqEK8TthS+MrAJzKv+`oGh^SMzG9zJ^b&;Xzqs=H zcJasrz2sTLHVG!3cHXPFlHdj+< zvZ=7MzUHO@M-Iiw+*FQKiyl{Ct)GVc zKB>Uu7{l!(vAN%|+m%)RJTBjk@naX}hfcyF!p3Mvp3x+A36V>*v6SgSkR9h%yw=jFmU*%xH3v zvk$|=)g4O-d}wR8;hgj#OISum3WOB4bi@2bjbc(2f~bwW5Cv($)75&E--R{?xmBaK@{|Cd@KOnErAra#;}E-Yf?=er63@6?eh z%I?R{$x_CG9ad-+QU*Jb;^BmKGdtR&cXC=A#!@9j|FUsVm?atcZf#x=-oM!K^_cXM z8a>+p2@d5aq~%3)+qYPM_lmqnPM0v)A`F%;O+t2ab{uM!{jPa$gVm=)`yzcrOa*|| zF8tZWu;16<%$%EB>ckq|%7t&ra|V70?g`$4yJkd&h=$7T-tChi10Cb44@?7xhGHm>4BshYoQ7Xl zc%mSCE9He+LeyD{$XVEyXzwBGS`w04mcj<+dpo_b_m5W`P?b=tU$fmOb@x5-+K3I? zdw06TNr-3M(>663)ni5UEu~_Yrzb_^roSB|MBm|kH?L+z#zd))T+lG8FW-^{daxduEsc6Sabxn8vWn@|A&784}|qn literal 0 HcmV?d00001 diff --git a/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithTechsetT6.zone b/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithTechsetT6.zone new file mode 100644 index 00000000..dfd78e4e --- /dev/null +++ b/test/SystemTests/Game/T6/ExtendAndDereference/ZoneWithTechsetT6.zone @@ -0,0 +1,3 @@ +>game,T6 + +techniqueset,trivial_floatz_2992w610 diff --git a/test/SystemTests/Game/T6/ExtendAndDereference/materials/test.json b/test/SystemTests/Game/T6/ExtendAndDereference/materials/test.json new file mode 100644 index 00000000..4ec3e470 --- /dev/null +++ b/test/SystemTests/Game/T6/ExtendAndDereference/materials/test.json @@ -0,0 +1,77 @@ +{ + "$schema": "http://openassettools.dev/schema/material.v1.json", + "_game": "t6", + "_type": "material", + "_version": 1, + "cameraRegion": "none", + "constants": [], + "contents": 1, + "gameFlags": [], + "layeredSurfaceTypes": 536870912, + "sortKey": 4, + "stateBits": [ + { + "alphaTest": "disabled", + "blendOpAlpha": "disabled", + "blendOpRgb": "disabled", + "colorWriteAlpha": true, + "colorWriteRgb": true, + "cullFace": "back", + "depthTest": "disabled", + "depthWrite": false, + "dstBlendAlpha": "zero", + "dstBlendRgb": "zero", + "polygonOffset": "offset0", + "polymodeLine": false, + "srcBlendAlpha": "one", + "srcBlendRgb": "one" + } + ], + "stateBitsEntry": [ + -1, + -1, + 0, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1 + ], + "stateFlags": 0, + "surfaceFlags": 0, + "surfaceTypeBits": 0, + "techniqueSet": "trivial_floatz_2992w610", + "textureAtlas": { + "columns": 1, + "rows": 1 + }, + "textures": [] +} diff --git a/test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp b/test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp new file mode 100644 index 00000000..22eb208b --- /dev/null +++ b/test/SystemTests/Game/T6/ExtendAndDereferenceT6.cpp @@ -0,0 +1,119 @@ +#include "Game/T6/GameAssetPoolT6.h" +#include "Linker.h" +#include "OatTestPaths.h" +#include "SystemTestsPaths.h" +#include "ZoneLoading.h" + +#include +#include +#include +#include +#include + +namespace fs = std::filesystem; +using namespace std::literals; + +namespace +{ + void BuildZoneWithMaterial(const fs::path& testDir, const fs::path& outputPath) + { + const auto testDirStr = testDir.string(); + const auto outputPathStr = outputPath.string(); + + const char* argStrings[]{ + "SystemTests", // bin + "--verbose", + "--asset-search-path", + testDirStr.c_str(), + "--source-search-path", + testDirStr.c_str(), + "--output-folder", + outputPathStr.c_str(), + "ZoneWithMaterialT6", + }; + + LinkerArgs args; + + bool shouldContinue = true; + const auto couldParseArgs = args.ParseArgs(std::extent_v, argStrings, shouldContinue); + + REQUIRE(couldParseArgs); + REQUIRE(shouldContinue); + + const auto linker = Linker::Create(std::move(args)); + const auto linkerResult = linker->Start(); + + REQUIRE(linkerResult); + } + + void BuildCombinedZone(const fs::path& testDir, const fs::path& outputPath) + { + const auto testDirStr = testDir.string(); + const auto outputPathStr = outputPath.string(); + + const auto zoneWithTechsetPathStr = (testDir / "ZoneWithTechsetT6.ff").string(); + const auto zoneWithMaterialPathStr = (outputPath / "ZoneWithMaterialT6.ff").string(); + + const char* argStrings[]{ + "SystemTests", // bin + "--verbose", + "--load", + zoneWithTechsetPathStr.c_str(), + "--load", + zoneWithMaterialPathStr.c_str(), + "--source-search-path", + testDirStr.c_str(), + "--output-folder", + outputPathStr.c_str(), + "CombinedZoneT6", + }; + + LinkerArgs args; + + bool shouldContinue = true; + const auto couldParseArgs = args.ParseArgs(std::extent_v, argStrings, shouldContinue); + + REQUIRE(couldParseArgs); + REQUIRE(shouldContinue); + + const auto linker = Linker::Create(std::move(args)); + const auto linkerResult = linker->Start(); + + REQUIRE(linkerResult); + } + + void CheckCombinedZoneContent(const fs::path& outputPath) + { + const auto expectedZonePath = (fs::path(outputPath) / "CombinedZoneT6.ff").string(); + auto maybeZone = ZoneLoading::LoadZone(expectedZonePath, std::nullopt); + REQUIRE(maybeZone); + + auto zone = std::move(*maybeZone); + auto pools = dynamic_cast(zone->m_pools.get()); + + REQUIRE(zone->m_game_id == GameId::T6); + REQUIRE(zone->m_platform == GamePlatform::PC); + REQUIRE(zone->m_name == "CombinedZoneT6"); + REQUIRE(pools->GetTotalAssetCount() == 2); + REQUIRE(pools->m_technique_set->GetAsset("trivial_floatz_2992w610")); + + const auto* material = pools->m_material->GetAsset("test"); + REQUIRE(material); + REQUIRE(material->Asset()->techniqueSet); + REQUIRE(material->Asset()->techniqueSet->name == "trivial_floatz_2992w610"s); + REQUIRE(material->Asset()->techniqueSet->techniques[T6::TECHNIQUE_UNLIT]); + } + + // x64 for now produces invalid zones, don't try to load them yet +#ifdef ARCH_x86 + TEST_CASE("Extend and dereference(T6)", "[t6][system][simple]") + { + const auto testDir = oat::paths::GetSystemTestsDirectory() / "Game/T6/ExtendAndDereference"; + const auto outputPath = oat::paths::GetTempDirectory("ExtendAndDereferenceT6"); + + BuildZoneWithMaterial(testDir, outputPath); + BuildCombinedZone(testDir, outputPath); + CheckCombinedZoneContent(outputPath); + } +#endif +} // namespace