From 6a6974a15deb6edf593736cdb8043bfb93064782 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Fri, 13 May 2022 13:50:50 -0500 Subject: Move infinite loop detection into the hosts. Tell the BA during Destroy whether it will be reloaded, and let the BA decide then whether it's module should be unloaded. Show error when infinite prereq loop detected. Only clip the exit code if they're Win32 errors. Set related bundle type to none to avoid downgrades during preqba. --- src/test/burn/TestBA/TestBA.cs | 8 +++++++- src/test/burn/TestData/Manual/BafThmutilTesting/precomp.cpp | 2 ++ src/test/burn/WixToolset.WixBA/WixBA.cs | 9 ++++++++- src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs | 6 ++++-- 4 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/test') diff --git a/src/test/burn/TestBA/TestBA.cs b/src/test/burn/TestBA/TestBA.cs index 5f492efd..1548c05b 100644 --- a/src/test/burn/TestBA/TestBA.cs +++ b/src/test/burn/TestBA/TestBA.cs @@ -171,7 +171,13 @@ namespace WixToolset.Test.BA this.dummyWindow.Dispose(); } - this.Engine.Quit(this.result & 0xFFFF); // return plain old Win32 error, not HRESULT. + var exitCode = this.result; + if ((exitCode & 0xFFFF0000) == unchecked(0x80070000)) + { + exitCode &= 0xFFFF; // return plain old Win32 error, not HRESULT. + } + + this.Engine.Quit(exitCode); } protected override void OnDetectUpdateBegin(DetectUpdateBeginEventArgs args) diff --git a/src/test/burn/TestData/Manual/BafThmutilTesting/precomp.cpp b/src/test/burn/TestData/Manual/BafThmutilTesting/precomp.cpp index b20f4230..fc9d1177 100644 --- a/src/test/burn/TestData/Manual/BafThmutilTesting/precomp.cpp +++ b/src/test/burn/TestData/Manual/BafThmutilTesting/precomp.cpp @@ -40,6 +40,8 @@ LExit: } extern "C" void WINAPI BAFunctionsDestroy( + __in const BA_FUNCTIONS_DESTROY_ARGS* /*pArgs*/, + __inout BA_FUNCTIONS_DESTROY_RESULTS* /*pResults*/ ) { BalUninitialize(); diff --git a/src/test/burn/WixToolset.WixBA/WixBA.cs b/src/test/burn/WixToolset.WixBA/WixBA.cs index 68288f2d..60426ca8 100644 --- a/src/test/burn/WixToolset.WixBA/WixBA.cs +++ b/src/test/burn/WixToolset.WixBA/WixBA.cs @@ -179,7 +179,14 @@ namespace WixToolset.WixBA Threading.Dispatcher.Run(); this.PostTelemetry(); - this.Engine.Quit(WixBA.Model.Result); + + var exitCode = WixBA.Model.Result; + if ((exitCode & 0xFFFF0000) == unchecked(0x80070000)) + { + exitCode &= 0xFFFF; // return plain old Win32 error, not HRESULT. + } + + this.Engine.Quit(exitCode); } private void PostTelemetry() diff --git a/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs index ec828f89..52e165b4 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/PrereqBaTests.cs @@ -12,6 +12,8 @@ namespace WixToolsetTest.BurnE2E { public PrereqBaTests(ITestOutputHelper testOutputHelper) : base(testOutputHelper) { } + const int E_PREREQBA_INFINITE_LOOP = -2_114_714_646; + /// /// This bundle purposely provides a .runtimeconfig.json file that requires a version of .NET Core that doesn't exist, /// with an MSI package to represent the prerequisite package. @@ -32,7 +34,7 @@ namespace WixToolsetTest.BurnE2E // Source file should *not* be installed Assert.False(File.Exists(packageASourceCodeInstalled), $"Package A payload should not be there on test start: {packageASourceCodeInstalled}"); - bundleA.Install(); + bundleA.Install(E_PREREQBA_INFINITE_LOOP); // Part of the test is Install actually completing. @@ -63,7 +65,7 @@ namespace WixToolsetTest.BurnE2E // Source file should *not* be installed Assert.False(File.Exists(packageBSourceCodeInstalled), $"Package B payload should not be there on test start: {packageBSourceCodeInstalled}"); - bundleB.Install(); + bundleB.Install(E_PREREQBA_INFINITE_LOOP); // Part of the test is Install actually completing. -- cgit v1.2.3-55-g6feb