From edccb203c421d2bd820062024088c6698424d9ee Mon Sep 17 00:00:00 2001 From: Bob Arnson Date: Wed, 4 Feb 2026 20:47:04 -0500 Subject: Support dual-purpose packages in Burn. Fixes https://github.com/wixtoolset/issues/issues/8958 --- src/burn/test/BurnUnitTest/ApprovedExeTest.cpp | 8 +- src/burn/test/BurnUnitTest/BurnTestException.h | 14 +- src/burn/test/BurnUnitTest/BurnTestFixture.h | 8 +- src/burn/test/BurnUnitTest/BurnUnitTest.h | 8 +- src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj | 19 +- .../test/BurnUnitTest/BurnUnitTest.vcxproj.filters | 18 +- src/burn/test/BurnUnitTest/CacheTest.cpp | 10 +- src/burn/test/BurnUnitTest/ElevationTest.cpp | 8 +- src/burn/test/BurnUnitTest/EmbeddedTest.cpp | 8 +- src/burn/test/BurnUnitTest/ExitCodeTest.cpp | 12 +- src/burn/test/BurnUnitTest/LoggingTest.cpp | 8 +- src/burn/test/BurnUnitTest/ManifestHelpers.cpp | 8 +- src/burn/test/BurnUnitTest/ManifestHelpers.h | 8 +- src/burn/test/BurnUnitTest/ManifestTest.cpp | 10 +- src/burn/test/BurnUnitTest/PlanTest.cpp | 393 ++++++++++++++++++--- src/burn/test/BurnUnitTest/RegistrationTest.cpp | 56 ++- src/burn/test/BurnUnitTest/RelatedBundleTest.cpp | 14 +- src/burn/test/BurnUnitTest/SearchTest.cpp | 8 +- .../TestData/PlanTest/AllPmouBundle_manifest.xml | 46 +++ .../TestData/PlanTest/AllPuomBundle_manifest.xml | 46 +++ .../BasicFunctionality_BundleA_manifest.xml | 4 +- .../PlanTest/BundlePackage_Multiple_manifest.xml | 8 +- .../ExePackage_PerUserArpEntry_manifest.xml | 6 +- .../TestData/PlanTest/Failure_BundleD_manifest.xml | 6 +- .../PlanTest/MsiTransaction_BundleAv1_manifest.xml | 8 +- .../PlanTest/MsuPackageFixture_manifest.xml | 4 +- .../PlanTest/PerMachineBundle_manifest.xml | 33 ++ .../TestData/PlanTest/PerUserBundle_manifest.xml | 33 ++ .../TestData/PlanTest/PmPmouBundle_manifest.xml | 59 ++++ .../TestData/PlanTest/PmPuPmouBundle_manifest.xml | 72 ++++ .../TestData/PlanTest/PmPuPuomBundle_manifest.xml | 72 ++++ .../TestData/PlanTest/PmPuomBundle_manifest.xml | 59 ++++ .../TestData/PlanTest/PuPmouBundle_manifest.xml | 59 ++++ .../TestData/PlanTest/PuPuomBundle_manifest.xml | 59 ++++ .../PlanTest/PuomBundlePackage_manifest.xml | 26 ++ .../PlanTest/Slipstream_BundleA_manifest.xml | 8 +- .../Slipstream_BundleA_modified_manifest.xml | 6 +- src/burn/test/BurnUnitTest/VariableHelpers.cpp | 8 +- src/burn/test/BurnUnitTest/VariableHelpers.h | 8 +- src/burn/test/BurnUnitTest/VariableTest.cpp | 8 +- src/burn/test/BurnUnitTest/VariantTest.cpp | 8 +- 41 files changed, 1041 insertions(+), 223 deletions(-) create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/AllPmouBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/AllPuomBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PerMachineBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PerUserBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PmPmouBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PmPuPmouBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PmPuPuomBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PmPuomBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PuPmouBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PuPuomBundle_manifest.xml create mode 100644 src/burn/test/BurnUnitTest/TestData/PlanTest/PuomBundlePackage_manifest.xml (limited to 'src/burn/test/BurnUnitTest') diff --git a/src/burn/test/BurnUnitTest/ApprovedExeTest.cpp b/src/burn/test/BurnUnitTest/ApprovedExeTest.cpp index da51f1f8..6798d3cb 100644 --- a/src/burn/test/BurnUnitTest/ApprovedExeTest.cpp +++ b/src/burn/test/BurnUnitTest/ApprovedExeTest.cpp @@ -2,11 +2,7 @@ #include "precomp.h" -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -308,5 +304,3 @@ namespace Bootstrapper } } } -} -} diff --git a/src/burn/test/BurnUnitTest/BurnTestException.h b/src/burn/test/BurnUnitTest/BurnTestException.h index b9467926..b6055041 100644 --- a/src/burn/test/BurnUnitTest/BurnTestException.h +++ b/src/burn/test/BurnUnitTest/BurnTestException.h @@ -2,11 +2,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -35,8 +31,6 @@ namespace Bootstrapper } } } -} -} // this class is used by __TestThrowOnFailure_Format() below to deallocate // the string created after the function call has returned @@ -83,6 +77,6 @@ LExit: } #pragma warning (pop) -#define TestThrowOnFailure(hr, s) if (FAILED(hr)) { throw gcnew Microsoft::Tools::WindowsInstallerXml::Test::Bootstrapper::BurnTestException(hr, gcnew System::String(s)); } -#define TestThrowOnFailure1(hr, s, p) if (FAILED(hr)) { throw gcnew Microsoft::Tools::WindowsInstallerXml::Test::Bootstrapper::BurnTestException(hr, gcnew System::String(__TestThrowOnFailure_Format(s, p))); } -#define TestThrowOnFailure2(hr, s, p1, p2) if (FAILED(hr)) { throw gcnew Microsoft::Tools::WindowsInstallerXml::Test::Bootstrapper::BurnTestException(hr, gcnew System::String(__TestThrowOnFailure_Format(s, p1, p2))); } +#define TestThrowOnFailure(hr, s) if (FAILED(hr)) { throw gcnew WixToolset::Test::Bootstrapper::BurnTestException(hr, gcnew System::String(s)); } +#define TestThrowOnFailure1(hr, s, p) if (FAILED(hr)) { throw gcnew WixToolset::Test::Bootstrapper::BurnTestException(hr, gcnew System::String(__TestThrowOnFailure_Format(s, p))); } +#define TestThrowOnFailure2(hr, s, p1, p2) if (FAILED(hr)) { throw gcnew WixToolset::Test::Bootstrapper::BurnTestException(hr, gcnew System::String(__TestThrowOnFailure_Format(s, p1, p2))); } diff --git a/src/burn/test/BurnUnitTest/BurnTestFixture.h b/src/burn/test/BurnUnitTest/BurnTestFixture.h index 35acba67..95fd6fe5 100644 --- a/src/burn/test/BurnUnitTest/BurnTestFixture.h +++ b/src/burn/test/BurnUnitTest/BurnTestFixture.h @@ -2,11 +2,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -71,5 +67,3 @@ namespace Bootstrapper } } } -} -} diff --git a/src/burn/test/BurnUnitTest/BurnUnitTest.h b/src/burn/test/BurnUnitTest/BurnUnitTest.h index ed1d2956..33cfe46d 100644 --- a/src/burn/test/BurnUnitTest/BurnUnitTest.h +++ b/src/burn/test/BurnUnitTest/BurnUnitTest.h @@ -2,11 +2,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -44,5 +40,3 @@ namespace Bootstrapper } } } -} -} diff --git a/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj b/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj index 9704efa5..c741789e 100644 --- a/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj +++ b/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj @@ -22,7 +22,6 @@ x64 - {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942} {9D1F1BA3-9393-4833-87A3-D5F1FC08EF67} @@ -34,15 +33,12 @@ false true - - $(ProjectAdditionalIncludeDirectories);$(BurnGeneratedHeaderDirectory);..\..\engine;..\..\..\api\burn\inc;..\..\..\libs\dutil\WixToolset.Dutil\inc cabinet.lib;crypt32.lib;msi.lib;rpcrt4.lib;shlwapi.lib;userenv.lib;wininet.lib;wintrust.lib;$(RootBuildFolder)libs\$(Configuration)\$(WixNativeSdkLibraryToolset)\$(PlatformTarget)\dutil.lib;engine.res - @@ -76,11 +72,9 @@ - - @@ -91,14 +85,23 @@ + + + + + + + + + + + - {8119537D-E1D9-6591-D51A-49770A2F9C37} - diff --git a/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj.filters b/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj.filters index aac5ab8b..0c458f48 100644 --- a/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj.filters +++ b/src/burn/test/BurnUnitTest/BurnUnitTest.vcxproj.filters @@ -98,4 +98,20 @@ Resource Files - + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/burn/test/BurnUnitTest/CacheTest.cpp b/src/burn/test/BurnUnitTest/CacheTest.cpp index 8e3660b2..c142e673 100644 --- a/src/burn/test/BurnUnitTest/CacheTest.cpp +++ b/src/burn/test/BurnUnitTest/CacheTest.cpp @@ -23,11 +23,7 @@ typedef struct _CACHE_TEST_CONTEXT { } CACHE_TEST_CONTEXT; -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -158,7 +154,7 @@ namespace Bootstrapper hr = StrAllocHexDecode(L"25e61cd83485062b70713aebddd3fe4992826cb121466fddc8de3eacb1e42f39d4bdd8455d95eec8c9529ced4c0296ab861931fe2c86df2f2b4e8d259a6d9223", &pb, &cb); Assert::Equal(S_OK, hr); - package.fPerMachine = FALSE; + package.scope = BOOTSTRAPPER_PACKAGE_SCOPE_PER_USER; package.sczCacheId = L"Bootstrapper.CacheTest.CacheSignatureTest"; payload.sczKey = L"CacheSignatureTest.PayloadKey"; payload.sczFilePath = L"CacheSignatureTest.File"; @@ -192,8 +188,6 @@ namespace Bootstrapper } } } -} -} static HRESULT CALLBACK CacheTestEventRoutine( __in BURN_CACHE_MESSAGE* /*pMessage*/, diff --git a/src/burn/test/BurnUnitTest/ElevationTest.cpp b/src/burn/test/BurnUnitTest/ElevationTest.cpp index 81e9f93e..feacdb7c 100644 --- a/src/burn/test/BurnUnitTest/ElevationTest.cpp +++ b/src/burn/test/BurnUnitTest/ElevationTest.cpp @@ -25,11 +25,7 @@ static HRESULT ProcessChildMessages( __out DWORD* pdwResult ); -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -92,8 +88,6 @@ namespace Bootstrapper } } } -} -} static BOOL STDAPICALLTYPE ElevateTest_ShellExecuteExW( diff --git a/src/burn/test/BurnUnitTest/EmbeddedTest.cpp b/src/burn/test/BurnUnitTest/EmbeddedTest.cpp index a19790ad..33f03282 100644 --- a/src/burn/test/BurnUnitTest/EmbeddedTest.cpp +++ b/src/burn/test/BurnUnitTest/EmbeddedTest.cpp @@ -33,11 +33,7 @@ static int EmbeddedTest_GenericMessageHandler( __in LPVOID pvContext ); -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -84,8 +80,6 @@ namespace Bootstrapper } } } -} -} static BOOL STDAPICALLTYPE EmbeddedTest_CreateProcessW( diff --git a/src/burn/test/BurnUnitTest/ExitCodeTest.cpp b/src/burn/test/BurnUnitTest/ExitCodeTest.cpp index 9b66f4c0..0529fa45 100644 --- a/src/burn/test/BurnUnitTest/ExitCodeTest.cpp +++ b/src/burn/test/BurnUnitTest/ExitCodeTest.cpp @@ -2,11 +2,7 @@ #include "precomp.h" -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -328,7 +324,7 @@ static void LoadEngineState( L"" L" " L" " - L" " + L" " L" " L" " L" " @@ -349,7 +345,7 @@ static void LoadEngineState( L" " L" " L" " - L" " + L" " L" " L" " L" " @@ -376,5 +372,3 @@ static void LoadEngineState( } } } -} -} diff --git a/src/burn/test/BurnUnitTest/LoggingTest.cpp b/src/burn/test/BurnUnitTest/LoggingTest.cpp index ed74c875..7619b913 100644 --- a/src/burn/test/BurnUnitTest/LoggingTest.cpp +++ b/src/burn/test/BurnUnitTest/LoggingTest.cpp @@ -2,11 +2,7 @@ #include "precomp.h" -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -64,5 +60,3 @@ namespace Bootstrapper } } } -} -} diff --git a/src/burn/test/BurnUnitTest/ManifestHelpers.cpp b/src/burn/test/BurnUnitTest/ManifestHelpers.cpp index 96d5fab4..b68504aa 100644 --- a/src/burn/test/BurnUnitTest/ManifestHelpers.cpp +++ b/src/burn/test/BurnUnitTest/ManifestHelpers.cpp @@ -7,11 +7,7 @@ using namespace System; using namespace Xunit; -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -37,5 +33,3 @@ namespace Bootstrapper } } } -} -} diff --git a/src/burn/test/BurnUnitTest/ManifestHelpers.h b/src/burn/test/BurnUnitTest/ManifestHelpers.h index e3e57555..e3c97c64 100644 --- a/src/burn/test/BurnUnitTest/ManifestHelpers.h +++ b/src/burn/test/BurnUnitTest/ManifestHelpers.h @@ -2,11 +2,7 @@ // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -20,5 +16,3 @@ void LoadBundleXmlHelper(LPCWSTR wzDocument, IXMLDOMElement** ppixeBundle); } } } -} -} diff --git a/src/burn/test/BurnUnitTest/ManifestTest.cpp b/src/burn/test/BurnUnitTest/ManifestTest.cpp index 4959cee0..4e6bac24 100644 --- a/src/burn/test/BurnUnitTest/ManifestTest.cpp +++ b/src/burn/test/BurnUnitTest/ManifestTest.cpp @@ -2,11 +2,7 @@ #include "precomp.h" -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -40,7 +36,7 @@ namespace Bootstrapper " " " " " " - " " + " " " "; @@ -67,5 +63,3 @@ namespace Bootstrapper } } } -} -} diff --git a/src/burn/test/BurnUnitTest/PlanTest.cpp b/src/burn/test/BurnUnitTest/PlanTest.cpp index e2850a62..7e7d84cc 100644 --- a/src/burn/test/BurnUnitTest/PlanTest.cpp +++ b/src/burn/test/BurnUnitTest/PlanTest.cpp @@ -2,12 +2,20 @@ #include "precomp.h" +#if TODO_REIMPLEMENT static HRESULT WINAPI PlanTestBAProc( __in BOOTSTRAPPER_APPLICATION_MESSAGE message, __in const LPVOID pvArgs, __inout LPVOID pvResults, __in_opt LPVOID pvContext ); +#endif + +struct REDIRECTED_LOGGING_CONTEXT +{ + LPSTR pszBuffer; +}; + static LPCWSTR wzArpEntryExeManifestFileName = L"ExePackage_PerUserArpEntry_manifest.xml"; static LPCWSTR wzMsiTransactionManifestFileName = L"MsiTransaction_BundleAv1_manifest.xml"; @@ -28,11 +36,7 @@ static BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE vRelatedBundlePlanType = BOOTSTRAPP static BURN_DEPENDENCY_ACTION registerActions1[] = { BURN_DEPENDENCY_ACTION_REGISTER }; static BURN_DEPENDENCY_ACTION unregisterActions1[] = { BURN_DEPENDENCY_ACTION_UNREGISTER }; -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -43,11 +47,313 @@ namespace Bootstrapper public ref class PlanTest : BurnUnitTest { + private: + void ScopeTest( + LPCWSTR wzManifestFileName, + BOOL fDefaultPlanPerMachine, + BOOL fDefaultRegistrationPerMachine, + BOOL fPerUserPlanPerMachine, + BOOL fPerUserRegistrationPerMachine, + BOOL fPerMachinePlanPerMachine, + BOOL fPerMachineRegistrationPerMachine + ) + { + HRESULT hr = S_OK; + BURN_ENGINE_STATE engineState = { }; + BURN_ENGINE_STATE* pEngineState = &engineState; + BURN_PLAN* pPlan = &engineState.plan; + + InitializeEngineStateForCorePlan(wzManifestFileName, pEngineState); + DetectAttachedContainerAsAttached(pEngineState); + DetectPermanentPackagesAsPresentAndCached(pEngineState); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); + NativeAssert::Succeeded(hr, "CorePlan default failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_DEFAULT, pPlan->plannedScope); + Assert::Equal(fDefaultPlanPerMachine, pPlan->fPerMachine); + Assert::Equal(fDefaultRegistrationPerMachine, engineState.registration.fPerMachine); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_PER_USER); + NativeAssert::Succeeded(hr, "CorePlan per-user failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_USER, pPlan->plannedScope); + Assert::Equal(fPerUserPlanPerMachine, pPlan->fPerMachine); + Assert::Equal(fPerUserRegistrationPerMachine, engineState.registration.fPerMachine); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_PER_MACHINE); + NativeAssert::Succeeded(hr, "CorePlan per-machine failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_MACHINE, pPlan->plannedScope); + Assert::Equal(fPerMachinePlanPerMachine, pPlan->fPerMachine); + Assert::Equal(fPerMachineRegistrationPerMachine, engineState.registration.fPerMachine); + } + public: PlanTest(BurnTestFixture^ fixture) : BurnUnitTest(fixture) { } + [Fact] + void CommandLineScopeTestNoop() + { + HRESULT hr = S_OK; + BURN_ENGINE_STATE engineState = { }; + BURN_ENGINE_STATE* pEngineState = &engineState; + BURN_PLAN* pPlan = &engineState.plan; + + engineState.command.commandLineScope = BOOTSTRAPPER_SCOPE_PER_MACHINE; + + InitializeEngineStateForCorePlan(L"AllPmouBundle_manifest.xml", pEngineState); + DetectAttachedContainerAsAttached(pEngineState); + DetectPermanentPackagesAsPresentAndCached(pEngineState); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_PER_USER); + NativeAssert::Succeeded(hr, "CorePlan default failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_USER, pPlan->plannedScope); + Assert::Equal(FALSE, pPlan->fPerMachine); + Assert::Equal(FALSE, engineState.registration.fPerMachine); + } + + [Fact] + void CommandLineScopePerUserTest() + { + HRESULT hr = S_OK; + BURN_ENGINE_STATE engineState = { }; + BURN_ENGINE_STATE* pEngineState = &engineState; + BURN_PLAN* pPlan = &engineState.plan; + + engineState.command.commandLineScope = BOOTSTRAPPER_SCOPE_PER_USER; + + InitializeEngineStateForCorePlan(L"AllPmouBundle_manifest.xml", pEngineState); + DetectAttachedContainerAsAttached(pEngineState); + DetectPermanentPackagesAsPresentAndCached(pEngineState); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); + NativeAssert::Succeeded(hr, "CorePlan default failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_USER, pPlan->plannedScope); + Assert::Equal(FALSE, pPlan->fPerMachine); + Assert::Equal(FALSE, engineState.registration.fPerMachine); + } + + [Fact] + void CommandLineScopePerMachineTest() + { + HRESULT hr = S_OK; + BURN_ENGINE_STATE engineState = { }; + BURN_ENGINE_STATE* pEngineState = &engineState; + BURN_PLAN* pPlan = &engineState.plan; + + engineState.command.commandLineScope = BOOTSTRAPPER_SCOPE_PER_MACHINE; + + InitializeEngineStateForCorePlan(L"AllPmouBundle_manifest.xml", pEngineState); + DetectAttachedContainerAsAttached(pEngineState); + DetectPermanentPackagesAsPresentAndCached(pEngineState); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); + NativeAssert::Succeeded(hr, "CorePlan default failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_MACHINE, pPlan->plannedScope); + Assert::Equal(TRUE, pPlan->fPerMachine); + Assert::Equal(TRUE, engineState.registration.fPerMachine); + } + + [Fact] + void BundlePackageScopeTestNoop() + { + HRESULT hr = S_OK; + BURN_ENGINE_STATE engineState = { }; + BURN_ENGINE_STATE* pEngineState = &engineState; + BURN_PLAN* pPlan = &engineState.plan; + + engineState.command.commandLineScope = BOOTSTRAPPER_SCOPE_PER_MACHINE; + + InitializeEngineStateForCorePlan(L"PuomBundlePackage_manifest.xml", pEngineState); + DetectAttachedContainerAsAttached(pEngineState); + DetectPermanentPackagesAsPresentAndCached(pEngineState); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_PER_USER); + NativeAssert::Succeeded(hr, "CorePlan default failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_USER, pPlan->plannedScope); + Assert::Equal(BOOTSTRAPPER_SCOPE_DEFAULT, engineState.packages.rgPackages[0].fPerMachine); + Assert::Equal(FALSE, pPlan->fPerMachine); + Assert::Equal(FALSE, engineState.registration.fPerMachine); + } + + [Fact] + void BundlePackageScopeTestSucceeds() + { + HRESULT hr = S_OK; + BURN_ENGINE_STATE engineState = { }; + BURN_ENGINE_STATE* pEngineState = &engineState; + BURN_PLAN* pPlan = &engineState.plan; + + engineState.command.commandLineScope = BOOTSTRAPPER_SCOPE_PER_MACHINE; + + InitializeEngineStateForCorePlan(L"PuomBundlePackage_manifest.xml", pEngineState); + DetectAttachedContainerAsAttached(pEngineState); + DetectPermanentPackagesAsPresentAndCached(pEngineState); + + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); + NativeAssert::Succeeded(hr, "CorePlan default failed"); + + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_MACHINE, pPlan->plannedScope); + Assert::Equal(BOOTSTRAPPER_SCOPE_PER_MACHINE, engineState.packages.rgPackages[0].fPerMachine); + Assert::Equal(TRUE, pPlan->fPerMachine); + Assert::Equal(TRUE, engineState.registration.fPerMachine); + } + + [Fact] + void AllPerUserScopeTest() + { + ScopeTest( + L"PerUserBundle_manifest.xml", + FALSE /*fDefaultPlanPerMachine*/, + FALSE /*fDefaultRegistrationPerMachine*/, + FALSE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + FALSE /*fPerMachinePlanPerMachine*/, + FALSE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void AllPerMachineScopeTest() + { + ScopeTest( + L"PerMachineBundle_manifest.xml", + TRUE /*fDefaultPlanPerMachine*/, + TRUE /*fDefaultRegistrationPerMachine*/, + TRUE /*fPerUserPlanPerMachine*/, + TRUE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + TRUE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void AllPerMachineOrUserPackagesScopeTest() + { + ScopeTest( + L"AllPmouBundle_manifest.xml", + TRUE /*fDefaultPlanPerMachine*/, + TRUE /*fDefaultRegistrationPerMachine*/, + FALSE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + TRUE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void AllPerUserOrMachinePackagesScopeTest() + { + ScopeTest( + L"AllPuomBundle_manifest.xml", + FALSE /*fDefaultPlanPerMachine*/, + FALSE /*fDefaultRegistrationPerMachine*/, + FALSE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + TRUE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void PerMachineAndPerMachineOrUserScopeTest() + { + ScopeTest( + L"PmPmouBundle_manifest.xml", + TRUE /*fDefaultPlanPerMachine*/, + TRUE /*fDefaultRegistrationPerMachine*/, + TRUE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + TRUE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void PerMachineAndPerUserOrMachineScopeTest() + { + ScopeTest( + L"PmPuomBundle_manifest.xml", + TRUE /*fDefaultPlanPerMachine*/, + FALSE /*fDefaultRegistrationPerMachine*/, + TRUE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + TRUE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void PerMachineAndPerUserAndPerMachineOrUserScopeTest() + { + ScopeTest( + L"PmPuPmouBundle_manifest.xml", + TRUE /*fDefaultPlanPerMachine*/, + FALSE /*fDefaultRegistrationPerMachine*/, + TRUE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + FALSE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void PerMachineAndPerUserAndPerUserOrMachineScopeTest() + { + ScopeTest( + L"PmPuPuomBundle_manifest.xml", + TRUE /*fDefaultPlanPerMachine*/, + FALSE /*fDefaultRegistrationPerMachine*/, + TRUE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + FALSE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void PerUserAndPerMachineOrUserScopeTest() + { + ScopeTest( + L"PuPmouBundle_manifest.xml", + TRUE /*fDefaultPlanPerMachine*/, + FALSE /*fDefaultRegistrationPerMachine*/, + FALSE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + FALSE /*fPerMachineRegistrationPerMachine*/ + ); + } + + [Fact] + void PerUserAndPerUserOrMachineScopeTest() + { + ScopeTest( + L"PuPuomBundle_manifest.xml", + FALSE /*fDefaultPlanPerMachine*/, + FALSE /*fDefaultRegistrationPerMachine*/, + FALSE /*fPerUserPlanPerMachine*/, + FALSE /*fPerUserRegistrationPerMachine*/, + TRUE /*fPerMachinePlanPerMachine*/, + FALSE /*fPerMachineRegistrationPerMachine*/ + ); + } + [Fact] void ArpEntryExeInstallTest() { @@ -60,7 +366,7 @@ namespace Bootstrapper DetectAttachedContainerAsAttached(pEngineState); DetectPermanentPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -154,12 +460,13 @@ namespace Bootstrapper pEngineState->packages.rgPackages[1].currentState = BOOTSTRAPPER_PACKAGE_STATE_OBSOLETE; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); NativeAssert::StringEqual(L"{9C459DAD-0E64-40C8-8C9F-4F68E46AB223}", pPlan->wzBundleCode); NativeAssert::StringEqual(L"{9C459DAD-0E64-40C8-8C9F-4F68E46AB223}", pPlan->wzBundleProviderKey); + Assert::Equal(FALSE, pPlan->fEnabledForwardCompatibleBundle); Assert::Equal(FALSE, pPlan->fPerMachine); Assert::Equal(TRUE, pPlan->fCanAffectMachineState); @@ -233,7 +540,7 @@ namespace Bootstrapper InitializeEngineStateForCorePlan(wzArpEntryExeManifestFileName, pEngineState); DetectPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -326,9 +633,11 @@ namespace Bootstrapper DetectPackagesAsAbsent(pEngineState); DetectRelatedBundle(pEngineState, L"{FD9920AD-DBCA-4C6C-8CD5-B47431CE8D21}", L"1.0.0.0", BOOTSTRAPPER_RELATION_UPGRADE); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); + PlanDump(pPlan); + Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); NativeAssert::StringEqual(L"{E6469F05-BDC8-4EB8-B218-67412543EFAA}", pPlan->wzBundleCode); NativeAssert::StringEqual(L"{E6469F05-BDC8-4EB8-B218-67412543EFAA}", pPlan->wzBundleProviderKey); @@ -486,7 +795,7 @@ namespace Bootstrapper InitializeEngineStateForCorePlan(wzMsiTransactionManifestFileName, pEngineState); DetectPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -627,7 +936,7 @@ namespace Bootstrapper DetectAttachedContainerAsAttached(pEngineState); DetectPermanentPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -742,7 +1051,7 @@ namespace Bootstrapper DetectAttachedContainerAsAttached(pEngineState); DetectPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_REPAIR); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_REPAIR, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_REPAIR, pPlan->action); @@ -836,7 +1145,7 @@ namespace Bootstrapper DetectAttachedContainerAsAttached(pEngineState); DetectPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -955,7 +1264,7 @@ namespace Bootstrapper DetectPackagesAsAbsent(pEngineState); DetectCompatibleMsiPackage(pEngineState, pEngineState->packages.rgPackages, L"{C24F3903-38E7-4D44-8037-D9856B3C5046}", L"2.0.0.0"); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -1055,7 +1364,7 @@ namespace Bootstrapper vfUseRelatedBundlePlanType = TRUE; vRelatedBundlePlanType = BOOTSTRAPPER_RELATED_BUNDLE_PLAN_TYPE_UPGRADE; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -1174,7 +1483,7 @@ namespace Bootstrapper BURN_RELATED_BUNDLE* pRelatedBundle = DetectRelatedBundle(pEngineState, L"{FD9920AD-DBCA-4C6C-8CD5-B47431CE8D21}", L"0.9.0.0", BOOTSTRAPPER_RELATION_UPGRADE); pRelatedBundle->fPlannable = FALSE; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -1276,7 +1585,7 @@ namespace Bootstrapper DetectAttachedContainerAsAttached(pEngineState); DetectPermanentPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -1369,7 +1678,7 @@ namespace Bootstrapper DetectAttachedContainerAsAttached(pEngineState); DetectPermanentPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_LAYOUT); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_LAYOUT, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_LAYOUT, pPlan->action); @@ -1452,7 +1761,7 @@ namespace Bootstrapper DetectPackagesAsAbsent(pEngineState); DetectRelatedBundle(pEngineState, L"{FD9920AD-DBCA-4C6C-8CD5-B47431CE8D21}", L"0.9.0.0", BOOTSTRAPPER_RELATION_UPGRADE); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_CACHE); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_CACHE, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_CACHE, pPlan->action); @@ -1541,7 +1850,7 @@ namespace Bootstrapper DetectPackagesAsAbsent(pEngineState); DetectRelatedBundle(pEngineState, L"{AF8355C9-CCDD-4D61-BF5F-EA5F948D8F01}", L"1.1.0.0", BOOTSTRAPPER_RELATION_UPGRADE); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -1616,7 +1925,7 @@ namespace Bootstrapper vfUseRelatedBundleRequestState = TRUE; vRelatedBundleRequestState = BOOTSTRAPPER_REQUEST_STATE_FORCE_ABSENT; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -1705,7 +2014,7 @@ namespace Bootstrapper vfUseRelatedBundleRequestState = TRUE; vRelatedBundleRequestState = BOOTSTRAPPER_REQUEST_STATE_FORCE_PRESENT; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -1798,7 +2107,7 @@ namespace Bootstrapper DetectPackagesAsAbsent(pEngineState); DetectRelatedBundle(pEngineState, L"{FD9920AD-DBCA-4C6C-8CD5-B47431CE8D21}", L"0.9.0.0", BOOTSTRAPPER_RELATION_UPGRADE); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -1904,7 +2213,7 @@ namespace Bootstrapper pEngineState->registration.detectedRegistrationType = BOOTSTRAPPER_REGISTRATION_TYPE_FULL; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_MODIFY); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_MODIFY, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_MODIFY, pPlan->action); @@ -1983,7 +2292,7 @@ namespace Bootstrapper InitializeEngineStateForCorePlan(wzSingleMsiManifestFileName, pEngineState); DetectPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -2084,7 +2393,7 @@ namespace Bootstrapper DetectPackagesAsPresentAndCached(pEngineState); DetectBundleDependent(pEngineState, L"{29855EB1-724D-4285-A89C-5D37D8549DCD}"); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -2154,7 +2463,7 @@ namespace Bootstrapper InitializeEngineStateForCorePlan(wzSingleMsiManifestFileName, pEngineState); DetectAsRelatedUpgradeBundle(&engineState, L"{02940F3E-C83E-452D-BFCF-C943777ACEAE}", L"2.0.0.0"); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -2240,7 +2549,7 @@ namespace Bootstrapper pEngineState->packages.rgPackages[0].currentState = BOOTSTRAPPER_PACKAGE_STATE_SUPERSEDED; pEngineState->packages.rgPackages[0].Msi.operation = BOOTSTRAPPER_RELATED_OPERATION_DOWNGRADE; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -2328,7 +2637,7 @@ namespace Bootstrapper InitializeEngineStateForCorePlan(wzSingleMsiManifestFileName, pEngineState); DetectPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNSAFE_UNINSTALL, pPlan->action); @@ -2430,7 +2739,7 @@ namespace Bootstrapper DetectAttachedContainerAsAttached(pEngineState); DetectPackagesAsAbsent(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); llPlannedAction = VariableGetNumericHelper(&engineState.variables, BURN_BUNDLE_ACTION); @@ -2523,7 +2832,7 @@ namespace Bootstrapper DetectPermanentPackagesAsPresentAndCached(pEngineState); PlanTestDetectPatchInitialize(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -2587,8 +2896,14 @@ namespace Bootstrapper ValidateExecutePackageDependency(pPlan, fRollback, dwIndex++, L"PackageA", L"{22D1DDBA-284D-40A7-BD14-95EA07906F21}", registerActions1, 1); ValidateExecuteCheckpoint(pPlan, fRollback, dwIndex++, dwExecuteCheckpointId++); ValidateExecuteCheckpoint(pPlan, fRollback, dwIndex++, dwExecuteCheckpointId++); + + ValidateExecutePackageProvider(pPlan, fRollback, dwIndex++, L"PatchA", registerActions1, 1); + + pExecuteAction = ValidateDeletedExecuteMspTarget(pPlan, fRollback, dwIndex++, L"PatchA", BOOTSTRAPPER_ACTION_STATE_INSTALL, L"{5FF7F534-3FFC-41E0-80CD-E6361E5E7B7B}", TRUE, BURN_MSI_PROPERTY_INSTALL, INSTALLUILEVEL_NONE, FALSE, BOOTSTRAPPER_MSI_FILE_VERSIONING_MISSING_OR_OLDER, TRUE); + + ValidateExecuteMspTargetPatch(pExecuteAction, 0, L"PatchA"); ValidateExecuteCheckpoint(pPlan, fRollback, dwIndex++, dwExecuteCheckpointId++); ValidateExecutePackageDependency(pPlan, fRollback, dwIndex++, L"PatchA", L"{22D1DDBA-284D-40A7-BD14-95EA07906F21}", registerActions1, 1); @@ -2654,7 +2969,7 @@ namespace Bootstrapper InitializeEngineStateForCorePlan(wzSlipstreamManifestFileName, pEngineState); DetectPackagesAsPresentAndCached(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -2784,7 +3099,7 @@ namespace Bootstrapper vfUsePackageRequestState = TRUE; vPackageRequestState = BOOTSTRAPPER_REQUEST_STATE_FORCE_ABSENT; - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); @@ -2885,7 +3200,7 @@ namespace Bootstrapper InitializeEngineStateForCorePlan(wzSlipstreamModifiedManifestFileName, pEngineState); DetectPackagesAsAbsent(pEngineState); - hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL); + hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_INSTALL, BOOTSTRAPPER_SCOPE_DEFAULT); NativeAssert::Succeeded(hr, "CorePlan failed"); Assert::Equal(BOOTSTRAPPER_ACTION_INSTALL, pPlan->action); @@ -3031,7 +3346,7 @@ namespace Bootstrapper Assert::True(FileExistsEx(sczFilePath, NULL), "Test file does not exist."); hr = ManifestLoadXmlFromFile(sczFilePath, pEngineState); - NativeAssert::Succeeded(hr, "Failed to load manifest."); + NativeAssert::Succeeded(hr, "Failed to load test manifest."); } finally { @@ -3222,7 +3537,7 @@ namespace Bootstrapper for (DWORD j = 0; j < pPackage->Msi.cSlipstreamMspPackages; ++j) { BURN_PACKAGE* pMspPackage = pPackage->Msi.rgSlipstreamMsps[j].pMspPackage; - MspEngineAddDetectedTargetProduct(&pEngineState->packages, pMspPackage, j, pPackage->Msi.sczProductCode, pPackage->fPerMachine ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED); + MspEngineAddDetectedTargetProduct(&pEngineState->packages, pMspPackage, j, pPackage->Msi.sczProductCode, pPackage->scope == BOOTSTRAPPER_PACKAGE_SCOPE_PER_MACHINE ? MSIINSTALLCONTEXT_MACHINE : MSIINSTALLCONTEXT_USERUNMANAGED); BURN_MSPTARGETPRODUCT* pTargetProduct = pMspPackage->Msp.rgTargetProducts + (pMspPackage->Msp.cTargetProductCodes - 1); pTargetProduct->patchPackageState = BOOTSTRAPPER_PACKAGE_STATE_PRESENT; @@ -3759,8 +4074,8 @@ namespace Bootstrapper void ValidatePlannedProvider( __in BURN_PLAN* pPlan, __in UINT uIndex, - __in LPCWSTR wzKey, - __in LPCWSTR wzName + __in_z LPCWSTR wzKey, + __in_z_opt LPCWSTR wzName ) { Assert::InRange(uIndex + 1u, 1u, pPlan->cPlannedProviders); @@ -3811,8 +4126,6 @@ namespace Bootstrapper } } } -} -} #if TODO_REIMPLEMENT diff --git a/src/burn/test/BurnUnitTest/RegistrationTest.cpp b/src/burn/test/BurnUnitTest/RegistrationTest.cpp index 3068eb6a..1c43c442 100644 --- a/src/burn/test/BurnUnitTest/RegistrationTest.cpp +++ b/src/burn/test/BurnUnitTest/RegistrationTest.cpp @@ -9,11 +9,7 @@ #define TEST_BUNDLE_UPGRADE_CODE L"{89FDAE1F-8CC1-48B9-B930-3945E0D3E7F0}" -namespace Microsoft -{ -namespace Tools -{ -namespace WindowsInstallerXml +namespace WixToolset { namespace Test { @@ -73,7 +69,7 @@ namespace Bootstrapper L" " L" " L" " - L" " + L" " L" " L" " L""; @@ -93,6 +89,12 @@ namespace Bootstrapper hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); + hr = RegistrationSetPaths(®istration, &cache); + TestThrowOnFailure(hr, "Failed to set registration paths."); + + hr = RegistrationPlanInitialize(®istration); + TestThrowOnFailure(hr, "Failed to initialize registration for the plan."); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; plan.pCommand = &command; plan.pInternalCommand = &internalCommand; @@ -173,7 +175,7 @@ namespace Bootstrapper L" " L" " L" " - L" " + L" " L" " L" " L""; @@ -193,6 +195,12 @@ namespace Bootstrapper hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); + hr = RegistrationSetPaths(®istration, &cache); + TestThrowOnFailure(hr, "Failed to set registration paths."); + + hr = RegistrationPlanInitialize(®istration); + TestThrowOnFailure(hr, "Failed to initialize registration for the plan."); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; plan.pCommand = &command; plan.pInternalCommand = &internalCommand; @@ -294,7 +302,7 @@ namespace Bootstrapper L" " L" " L" " - L" " + L" " L" " L" " L""; @@ -314,6 +322,12 @@ namespace Bootstrapper hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); + hr = RegistrationSetPaths(®istration, &cache); + TestThrowOnFailure(hr, "Failed to set registration paths."); + + hr = RegistrationPlanInitialize(®istration); + TestThrowOnFailure(hr, "Failed to initialize registration for the plan."); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; plan.pCommand = &command; plan.pInternalCommand = &internalCommand; @@ -415,7 +429,7 @@ namespace Bootstrapper L" " L" " L" " - L" " + L" " L" " @@ -437,6 +451,12 @@ namespace Bootstrapper hr = RegistrationParseFromXml(®istration, &cache, pixeBundle); TestThrowOnFailure(hr, L"Failed to parse registration from XML."); + hr = RegistrationSetPaths(®istration, &cache); + TestThrowOnFailure(hr, "Failed to set registration paths."); + + hr = RegistrationPlanInitialize(®istration); + TestThrowOnFailure(hr, "Failed to initialize registration for the plan."); + plan.action = BOOTSTRAPPER_ACTION_INSTALL; plan.pCommand = &command; plan.pInternalCommand = &internalCommand; @@ -554,7 +574,7 @@ namespace Bootstrapper L" " L" " L" " - L" " + L" " L" " L" " L"