diff options
Diffstat (limited to 'src/burn/test')
-rw-r--r-- | src/burn/test/BurnUnitTest/PlanTest.cpp | 133 |
1 files changed, 132 insertions, 1 deletions
diff --git a/src/burn/test/BurnUnitTest/PlanTest.cpp b/src/burn/test/BurnUnitTest/PlanTest.cpp index 7e704c23..fc2b8472 100644 --- a/src/burn/test/BurnUnitTest/PlanTest.cpp +++ b/src/burn/test/BurnUnitTest/PlanTest.cpp | |||
@@ -288,6 +288,74 @@ namespace Bootstrapper | |||
288 | } | 288 | } |
289 | 289 | ||
290 | [Fact] | 290 | [Fact] |
291 | void OrphanCompatiblePackageTest() | ||
292 | { | ||
293 | HRESULT hr = S_OK; | ||
294 | BURN_ENGINE_STATE engineState = { }; | ||
295 | BURN_ENGINE_STATE* pEngineState = &engineState; | ||
296 | BURN_PLAN* pPlan = &engineState.plan; | ||
297 | |||
298 | InitializeEngineStateForCorePlan(wzSingleMsiManifestFileName, pEngineState); | ||
299 | DetectPackagesAsAbsent(pEngineState); | ||
300 | DetectCompatibleMsiPackage(pEngineState->packages.rgPackages, L"{C24F3903-38E7-4D44-8037-D9856B3C5046}", L"2.0.0.0"); | ||
301 | |||
302 | hr = CorePlan(pEngineState, BOOTSTRAPPER_ACTION_UNINSTALL); | ||
303 | NativeAssert::Succeeded(hr, "CorePlan failed"); | ||
304 | |||
305 | Assert::Equal<DWORD>(BOOTSTRAPPER_ACTION_UNINSTALL, pPlan->action); | ||
306 | Assert::Equal<BOOL>(TRUE, pPlan->fPerMachine); | ||
307 | Assert::Equal<BOOL>(FALSE, pPlan->fDisableRollback); | ||
308 | |||
309 | BOOL fRollback = FALSE; | ||
310 | DWORD dwIndex = 0; | ||
311 | Assert::Equal(dwIndex, pPlan->cCacheActions); | ||
312 | |||
313 | fRollback = TRUE; | ||
314 | dwIndex = 0; | ||
315 | Assert::Equal(dwIndex, pPlan->cRollbackCacheActions); | ||
316 | |||
317 | Assert::Equal(0ull, pPlan->qwEstimatedSize); | ||
318 | Assert::Equal(0ull, pPlan->qwCacheSizeTotal); | ||
319 | |||
320 | fRollback = FALSE; | ||
321 | dwIndex = 0; | ||
322 | DWORD dwExecuteCheckpointId = 1; | ||
323 | ValidateExecuteRollbackBoundaryStart(pPlan, fRollback, dwIndex++, L"WixDefaultBoundary", TRUE, FALSE); | ||
324 | ValidateExecutePackageDependency(pPlan, fRollback, dwIndex++, L"PackageA", L"{A6F0CBF7-1578-450C-B9D7-9CF2EEC40002}", BURN_DEPENDENCY_ACTION_UNREGISTER); | ||
325 | ValidateExecutePackageProvider(pPlan, fRollback, dwIndex++, L"PackageA", BURN_DEPENDENCY_ACTION_UNREGISTER); | ||
326 | ValidateUninstallMsiCompatiblePackage(pPlan, fRollback, dwIndex++, L"PackageA", 0); | ||
327 | ValidateExecuteCheckpoint(pPlan, fRollback, dwIndex++, dwExecuteCheckpointId++); | ||
328 | ValidateExecuteCheckpoint(pPlan, fRollback, dwIndex++, dwExecuteCheckpointId++); | ||
329 | ValidateExecuteRollbackBoundaryEnd(pPlan, fRollback, dwIndex++); | ||
330 | Assert::Equal(dwIndex, pPlan->cExecuteActions); | ||
331 | |||
332 | fRollback = TRUE; | ||
333 | dwIndex = 0; | ||
334 | dwExecuteCheckpointId = 1; | ||
335 | ValidateExecuteRollbackBoundaryStart(pPlan, fRollback, dwIndex++, L"WixDefaultBoundary", TRUE, FALSE); | ||
336 | ValidateExecuteCheckpoint(pPlan, fRollback, dwIndex++, dwExecuteCheckpointId++); | ||
337 | ValidateExecuteCheckpoint(pPlan, fRollback, dwIndex++, dwExecuteCheckpointId++); | ||
338 | ValidateExecuteRollbackBoundaryEnd(pPlan, fRollback, dwIndex++); | ||
339 | Assert::Equal(dwIndex, pPlan->cRollbackActions); | ||
340 | |||
341 | Assert::Equal(1ul, pPlan->cExecutePackagesTotal); | ||
342 | Assert::Equal(1ul, pPlan->cOverallProgressTicksTotal); | ||
343 | |||
344 | dwIndex = 0; | ||
345 | ValidateCleanAction(pPlan, dwIndex++, L"PackageA"); | ||
346 | ValidateCleanCompatibleAction(pPlan, dwIndex++, L"PackageA"); | ||
347 | Assert::Equal(dwIndex, pPlan->cCleanActions); | ||
348 | |||
349 | UINT uIndex = 0; | ||
350 | ValidatePlannedProvider(pPlan, uIndex++, L"{A6F0CBF7-1578-450C-B9D7-9CF2EEC40002}", NULL); | ||
351 | ValidatePlannedProvider(pPlan, uIndex++, L"{64633047-D172-4BBB-B202-64337D15C952}", NULL); | ||
352 | Assert::Equal(uIndex, pPlan->cPlannedProviders); | ||
353 | |||
354 | Assert::Equal(1ul, pEngineState->packages.cPackages); | ||
355 | ValidateNonPermanentPackageExpectedStates(&pEngineState->packages.rgPackages[0], L"PackageA", BURN_PACKAGE_REGISTRATION_STATE_ABSENT, BURN_PACKAGE_REGISTRATION_STATE_ABSENT); | ||
356 | } | ||
357 | |||
358 | [Fact] | ||
291 | void RelatedBundleMissingFromCacheTest() | 359 | void RelatedBundleMissingFromCacheTest() |
292 | { | 360 | { |
293 | HRESULT hr = S_OK; | 361 | HRESULT hr = S_OK; |
@@ -1026,6 +1094,36 @@ namespace Bootstrapper | |||
1026 | } | 1094 | } |
1027 | } | 1095 | } |
1028 | 1096 | ||
1097 | void DetectCompatibleMsiPackage(BURN_PACKAGE* pPackage, LPCWSTR wzProductCode, LPCWSTR wzVersion) | ||
1098 | { | ||
1099 | HRESULT hr = S_OK; | ||
1100 | Assert(BOOTSTRAPPER_PACKAGE_STATE_PRESENT > pPackage->currentState); | ||
1101 | Assert(0 < pPackage->cDependencyProviders); | ||
1102 | BURN_DEPENDENCY_PROVIDER* pProvider = pPackage->rgDependencyProviders; | ||
1103 | BURN_COMPATIBLE_PACKAGE* pCompatiblePackage = &pPackage->compatiblePackage; | ||
1104 | pCompatiblePackage->fDetected = TRUE; | ||
1105 | pCompatiblePackage->fPlannable = TRUE; | ||
1106 | pCompatiblePackage->type = BURN_PACKAGE_TYPE_MSI; | ||
1107 | |||
1108 | hr = StrAllocFormatted(&pCompatiblePackage->sczCacheId, L"%lsv%ls", wzProductCode, wzVersion); | ||
1109 | NativeAssert::Succeeded(hr, "Failed to format cache id"); | ||
1110 | |||
1111 | hr = StrAllocString(&pCompatiblePackage->Msi.sczVersion, wzVersion, 0); | ||
1112 | NativeAssert::Succeeded(hr, "Failed to copy MSI version"); | ||
1113 | |||
1114 | hr = VerParseVersion(wzVersion, 0, FALSE, &pCompatiblePackage->Msi.pVersion); | ||
1115 | NativeAssert::Succeeded(hr, "Failed to parse MSI version"); | ||
1116 | |||
1117 | hr = StrAllocString(&pCompatiblePackage->compatibleEntry.sczId, wzProductCode, 0); | ||
1118 | NativeAssert::Succeeded(hr, "Failed to copy product code"); | ||
1119 | |||
1120 | hr = StrAllocString(&pCompatiblePackage->compatibleEntry.sczVersion, wzVersion, 0); | ||
1121 | NativeAssert::Succeeded(hr, "Failed to copy version"); | ||
1122 | |||
1123 | hr = StrAllocString(&pCompatiblePackage->compatibleEntry.sczProviderKey, pProvider->sczKey, 0); | ||
1124 | NativeAssert::Succeeded(hr, "Failed to copy provider key"); | ||
1125 | } | ||
1126 | |||
1029 | void DetectPackageAsAbsent(BURN_PACKAGE* pPackage) | 1127 | void DetectPackageAsAbsent(BURN_PACKAGE* pPackage) |
1030 | { | 1128 | { |
1031 | pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT; | 1129 | pPackage->currentState = BOOTSTRAPPER_PACKAGE_STATE_ABSENT; |
@@ -1262,9 +1360,26 @@ namespace Bootstrapper | |||
1262 | __in LPCWSTR wzPackageId | 1360 | __in LPCWSTR wzPackageId |
1263 | ) | 1361 | ) |
1264 | { | 1362 | { |
1363 | BURN_CLEAN_ACTION* pCleanAction = ValidateCleanActionExists(pPlan, dwIndex); | ||
1364 | Assert::Equal<DWORD>(BURN_CLEAN_ACTION_TYPE_PACKAGE, pCleanAction->type); | ||
1365 | Assert::NotEqual((DWORD_PTR)0, (DWORD_PTR)pCleanAction->pPackage); | ||
1366 | NativeAssert::StringEqual(wzPackageId, pCleanAction->pPackage->sczId); | ||
1367 | } | ||
1368 | |||
1369 | BURN_CLEAN_ACTION* ValidateCleanActionExists(BURN_PLAN* pPlan, DWORD dwIndex) | ||
1370 | { | ||
1265 | Assert::InRange(dwIndex + 1ul, 1ul, pPlan->cCleanActions); | 1371 | Assert::InRange(dwIndex + 1ul, 1ul, pPlan->cCleanActions); |
1372 | return pPlan->rgCleanActions + dwIndex; | ||
1373 | } | ||
1266 | 1374 | ||
1267 | BURN_CLEAN_ACTION* pCleanAction = pPlan->rgCleanActions + dwIndex; | 1375 | void ValidateCleanCompatibleAction( |
1376 | __in BURN_PLAN* pPlan, | ||
1377 | __in DWORD dwIndex, | ||
1378 | __in LPCWSTR wzPackageId | ||
1379 | ) | ||
1380 | { | ||
1381 | BURN_CLEAN_ACTION* pCleanAction = ValidateCleanActionExists(pPlan, dwIndex); | ||
1382 | Assert::Equal<DWORD>(BURN_CLEAN_ACTION_TYPE_COMPATIBLE_PACKAGE, pCleanAction->type); | ||
1268 | Assert::NotEqual((DWORD_PTR)0, (DWORD_PTR)pCleanAction->pPackage); | 1383 | Assert::NotEqual((DWORD_PTR)0, (DWORD_PTR)pCleanAction->pPackage); |
1269 | NativeAssert::StringEqual(wzPackageId, pCleanAction->pPackage->sczId); | 1384 | NativeAssert::StringEqual(wzPackageId, pCleanAction->pPackage->sczId); |
1270 | } | 1385 | } |
@@ -1537,6 +1652,22 @@ namespace Bootstrapper | |||
1537 | NativeAssert::StringEqual(wzKey, pProvider->sczKey); | 1652 | NativeAssert::StringEqual(wzKey, pProvider->sczKey); |
1538 | NativeAssert::StringEqual(wzName, pProvider->sczName); | 1653 | NativeAssert::StringEqual(wzName, pProvider->sczName); |
1539 | } | 1654 | } |
1655 | |||
1656 | void ValidateUninstallMsiCompatiblePackage( | ||
1657 | __in BURN_PLAN* pPlan, | ||
1658 | __in BOOL fRollback, | ||
1659 | __in DWORD dwIndex, | ||
1660 | __in_z LPCWSTR wzPackageId, | ||
1661 | __in DWORD dwLoggingAttributes | ||
1662 | ) | ||
1663 | { | ||
1664 | BURN_EXECUTE_ACTION* pAction = ValidateExecuteActionExists(pPlan, fRollback, dwIndex); | ||
1665 | Assert::Equal<DWORD>(BURN_EXECUTE_ACTION_TYPE_UNINSTALL_MSI_COMPATIBLE_PACKAGE, pAction->type); | ||
1666 | NativeAssert::StringEqual(wzPackageId, pAction->uninstallMsiCompatiblePackage.pParentPackage->sczId); | ||
1667 | NativeAssert::NotNull(pAction->msiPackage.sczLogPath); | ||
1668 | Assert::Equal<DWORD>(dwLoggingAttributes, pAction->uninstallMsiCompatiblePackage.dwLoggingAttributes); | ||
1669 | Assert::Equal<BOOL>(FALSE, pAction->fDeleted); | ||
1670 | } | ||
1540 | }; | 1671 | }; |
1541 | } | 1672 | } |
1542 | } | 1673 | } |