From 95e8b1be902cce3b5a394066a62e0c32d0688261 Mon Sep 17 00:00:00 2001 From: Sean Hall Date: Thu, 15 Sep 2022 12:17:07 -0500 Subject: Add more burn E2E tests. Fix bug where first splash screen wasn't closed. Fix bug where billboard only started the first time. Fix bug where the restart status was lost when the exit code was an error. Fix bug where the hash byte array length was compared to the hash string length (string is twice as long). Fix bug where Burn didn't give update hash if the first byte was 0. --- src/burn/engine/apply.cpp | 23 ++++++++- src/burn/engine/detect.cpp | 11 +++-- src/burn/engine/engine.mc | 2 +- src/burn/engine/externalengine.cpp | 2 +- src/burn/engine/splashscreen.cpp | 6 +++ src/libs/dutil/WixToolset.DUtil/thmutil.cpp | 2 - .../CustomExitCodeExePackage.wixproj | 17 +++++++ .../CustomExitCodeExePackage.wxs | 34 ++++++++++++++ .../theme/BafThmUtilTestingTheme.xml | 2 +- .../theme/BafThmUtilTestingThemeLoose.xml | 2 +- .../burn/TestData/Manual/BundleA/ManualTests.txt | 10 ++++ .../BundleBv1/FeedBv2.0_wronghash.xml | 54 ++++++++++++++++++++++ src/test/burn/WixTestTools/MSIExec.cs | 8 +++- .../burn/WixToolsetTest.BurnE2E/ExePackageTests.cs | 26 +++++++++++ .../WixToolsetTest.BurnE2E/UpdateBundleTests.cs | 36 +++++++++++++++ 15 files changed, 223 insertions(+), 12 deletions(-) create mode 100644 src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wixproj create mode 100644 src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wxs create mode 100644 src/test/burn/TestData/UpdateBundleTests/BundleBv1/FeedBv2.0_wronghash.xml diff --git a/src/burn/engine/apply.cpp b/src/burn/engine/apply.cpp index e67208b4..8fbaa76e 100644 --- a/src/burn/engine/apply.cpp +++ b/src/burn/engine/apply.cpp @@ -2547,6 +2547,11 @@ static HRESULT DoExecuteAction( } while (fRetry && *pRestart < BOOTSTRAPPER_APPLY_RESTART_INITIATED); LExit: + if (*pRestart < restart) + { + *pRestart = restart; + } + return hr; } @@ -2561,6 +2566,7 @@ static HRESULT DoRollbackActions( DWORD iCheckpoint = 0; BOOL fRetryIgnored = FALSE; BOOL fSuspendIgnored = FALSE; + BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE; pContext->fRollback = TRUE; @@ -2598,7 +2604,8 @@ static HRESULT DoRollbackActions( continue; } - BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE; + restart = BOOTSTRAPPER_APPLY_RESTART_NONE; + switch (pRollbackAction->type) { case BURN_EXECUTE_ACTION_TYPE_CHECKPOINT: @@ -2674,6 +2681,11 @@ static HRESULT DoRollbackActions( } LExit: + if (*pRestart < restart) + { + *pRestart = restart; + } + return hr; } @@ -2791,6 +2803,7 @@ static HRESULT DoRestoreRelatedBundleActions( HRESULT hr = S_OK; BOOL fRetryIgnored = FALSE; BOOL fSuspendIgnored = FALSE; + BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE; // execute restore related bundle actions for (DWORD i = 0; i < pEngineState->plan.cRestoreRelatedBundleActions; ++i) @@ -2804,7 +2817,8 @@ static HRESULT DoRestoreRelatedBundleActions( pContext->wzExecutingPackageId = NULL; pContext->fAbandonedProcess = FALSE; - BOOTSTRAPPER_APPLY_RESTART restart = BOOTSTRAPPER_APPLY_RESTART_NONE; + restart = BOOTSTRAPPER_APPLY_RESTART_NONE; + switch (pRestoreRelatedBundleAction->type) { case BURN_EXECUTE_ACTION_TYPE_RELATED_BUNDLE: @@ -2824,6 +2838,11 @@ static HRESULT DoRestoreRelatedBundleActions( } LExit: + if (*pRestart < restart) + { + *pRestart = restart; + } + return hr; } diff --git a/src/burn/engine/detect.cpp b/src/burn/engine/detect.cpp index fcd1c966..f573e259 100644 --- a/src/burn/engine/detect.cpp +++ b/src/burn/engine/detect.cpp @@ -399,18 +399,23 @@ static HRESULT DetectAtomFeedUpdate( { APPLICATION_UPDATE_ENTRY* pAppUpdateEntry = &pApupChain->rgEntries[i]; APPLICATION_UPDATE_ENCLOSURE* pEnclosure = pAppUpdateEntry->rgEnclosures; + LPCWSTR wzHash = L""; + BOOTSTRAPPER_UPDATE_HASH_TYPE hashType = BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE; - if (pEnclosure && pEnclosure->rgbDigest && *pEnclosure->rgbDigest) + if (pEnclosure && pEnclosure->rgbDigest && APUP_HASH_ALGORITHM_SHA512 == pEnclosure->digestAlgorithm) { hr = StrAllocHexEncode(pEnclosure->rgbDigest, pEnclosure->cbDigest, &sczHash); ExitOnFailure(hr, "Failed to encode hash as string."); + + wzHash = sczHash; + hashType = BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512; } hr = UserExperienceOnDetectUpdate(pUX, pEnclosure ? pEnclosure->wzUrl : NULL, pEnclosure ? pEnclosure->dw64Size : 0, - sczHash ? sczHash : L"", - pEnclosure ? pEnclosure->digestAlgorithm == APUP_HASH_ALGORITHM_SHA512 ? BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 : BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE : BOOTSTRAPPER_UPDATE_HASH_TYPE_NONE, + wzHash, + hashType, pAppUpdateEntry->pVersion, pAppUpdateEntry->wzTitle, pAppUpdateEntry->wzSummary, diff --git a/src/burn/engine/engine.mc b/src/burn/engine/engine.mc index d965d4ad..cebd1325 100644 --- a/src/burn/engine/engine.mc +++ b/src/burn/engine/engine.mc @@ -1006,7 +1006,7 @@ MessageId=366 Severity=Success SymbolicName=MSG_EXECUTE_PACKAGE_PROCESS_EXITED Language=English -The process for package: %1!ls! exited with code: %2!u!. The exit code has been translated to type: %3!hs! and restart: %4!hs!. +The process for package: %1!ls! exited with code: 0x%2!x!. The exit code has been translated to type: %3!hs! and restart: %4!hs!. . MessageId=370 diff --git a/src/burn/engine/externalengine.cpp b/src/burn/engine/externalengine.cpp index e18b9486..5e540c2a 100644 --- a/src/burn/engine/externalengine.cpp +++ b/src/burn/engine/externalengine.cpp @@ -296,7 +296,7 @@ HRESULT ExternalEngineSetUpdate( { ExitFunction1(hr = E_INVALIDARG); } - else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (!wzHash || !*wzHash || SHA512_HASH_LEN != lstrlenW(wzHash))) + else if (BOOTSTRAPPER_UPDATE_HASH_TYPE_SHA512 == hashType && (!wzHash || !*wzHash || SHA512_HASH_LEN * 2 != lstrlenW(wzHash))) { ExitFunction1(hr = E_INVALIDARG); } diff --git a/src/burn/engine/splashscreen.cpp b/src/burn/engine/splashscreen.cpp index d8618feb..b9dc9f55 100644 --- a/src/burn/engine/splashscreen.cpp +++ b/src/burn/engine/splashscreen.cpp @@ -221,6 +221,11 @@ LExit: ::DeleteObject(splashScreenInfo.hBitmap); } + if (splashScreenInfo.hwndPrevious) + { + ::PostMessageW(splashScreenInfo.hwndPrevious, WM_CLOSE, 0, 0); + } + return hr; } @@ -261,6 +266,7 @@ static LRESULT CALLBACK WndProc( return 1; case WM_ENTERIDLE: + case WM_MOVING: lres = ::DefWindowProcW(hWnd, uMsg, wParam, lParam); // We had to create our own splash screen so that Windows would automatically transfer focus from the other process's splash screen. diff --git a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp index 2341025c..05f7c098 100644 --- a/src/libs/dutil/WixToolset.DUtil/thmutil.cpp +++ b/src/libs/dutil/WixToolset.DUtil/thmutil.cpp @@ -4287,8 +4287,6 @@ static HRESULT StopBillboard( if (THEME_CONTROL_TYPE_BILLBOARD == pControl->type) { - ThemeControlEnable(pControl, FALSE); - if (::KillTimer(pTheme->hwndParent, idEvent)) { hr = S_OK; diff --git a/src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wixproj b/src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wixproj new file mode 100644 index 00000000..403f3320 --- /dev/null +++ b/src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wixproj @@ -0,0 +1,17 @@ + + + + Bundle + {9BB4F6D3-4EE3-40BF-879F-90E78440EAE8} + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wxs b/src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wxs new file mode 100644 index 00000000..a02e48d1 --- /dev/null +++ b/src/test/burn/TestData/ExePackageTests/CustomExitCodeExePackage/CustomExitCodeExePackage.wxs @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingTheme.xml b/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingTheme.xml index 4c117506..c890d7df 100644 --- a/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingTheme.xml +++ b/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingTheme.xml @@ -132,7 +132,7 @@ There are currently four states for a button: default, focus, hover, and selecte diff --git a/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingThemeLoose.xml b/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingThemeLoose.xml index b2b0dcb3..37757e64 100644 --- a/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingThemeLoose.xml +++ b/src/test/burn/TestData/Manual/BafThmutilTesting/theme/BafThmUtilTestingThemeLoose.xml @@ -132,7 +132,7 @@ There are currently four states for a button: default, focus, hover, and selecte diff --git a/src/test/burn/TestData/Manual/BundleA/ManualTests.txt b/src/test/burn/TestData/Manual/BundleA/ManualTests.txt index b8c6e74d..351f2c1f 100644 --- a/src/test/burn/TestData/Manual/BundleA/ManualTests.txt +++ b/src/test/burn/TestData/Manual/BundleA/ManualTests.txt @@ -152,3 +152,13 @@ CanRestartFromUnelevatedPerUserBundleWithShutdownPrivilege ======================================= (10. Uninstall the bundle) + +CanShowSplashScreenQuicklyAndCacheThousandsOfFilesInLinearTime + +1. Run BundleB.exe. +2. The splash screen should come up immediately (less than 1 second). +3. After the wixstdba UI comes up, make sure the splash screen was closed (it might be hiding underneath windows). +4. Click Install (accept elevation). +5. This bundle contains 10000 loose files which needs to be cached, which used to take over 30 minutes. The exact timing can be different on different machines, but it should be closer to 30 seconds. +6. Click Close. +(7. Uninstall the bundle) diff --git a/src/test/burn/TestData/UpdateBundleTests/BundleBv1/FeedBv2.0_wronghash.xml b/src/test/burn/TestData/UpdateBundleTests/BundleBv1/FeedBv2.0_wronghash.xml new file mode 100644 index 00000000..82ce6837 --- /dev/null +++ b/src/test/burn/TestData/UpdateBundleTests/BundleBv1/FeedBv2.0_wronghash.xml @@ -0,0 +1,54 @@ + + + + + + BundleB v2.0 + Bundle Subtitle. + 1116353B-7C6E-4C29-BFA1-D4A972CD421D + 2014-07-14T12:39:00.000Z + http://localhost:9999/e2e/BundleB/feed + + manual build + + Bundle v2.0 + v2.0 + + Bundle_Author + http://mycompany.com/software + Bundle_Author@mycompany.com + + + + this hash is supposed to be wrong but has a tiny chance of actually being right + 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 + + + <p>Change list:</p><ul> + <li>Updated release.</li> + </ul> + + + 2.0.0.0 + 2014-11-10T12:39:00.000Z + + + Bundle v1.0 + v1.0 + + Bundle_Author + http://mycompany.com/software + Bundle_Author@mycompany.com + + + + + <p>Change list:</p><ul> + <li>Initial release.</li> + </ul> + + + 1.0.0.0 + 2014-11-09T12:39:00.000Z + + diff --git a/src/test/burn/WixTestTools/MSIExec.cs b/src/test/burn/WixTestTools/MSIExec.cs index 5f57da7b..a905ec5a 100644 --- a/src/test/burn/WixTestTools/MSIExec.cs +++ b/src/test/burn/WixTestTools/MSIExec.cs @@ -666,7 +666,13 @@ namespace WixTestTools /// A restart is required to complete the install. This message is indicative of a success. /// This does not include installs where the ForceReboot action is run. /// - ERROR_SUCCESS_REBOOT_REQUIRED = 3010 + ERROR_SUCCESS_REBOOT_REQUIRED = 3010, + + /// + /// ERROR_SUCCESS_REBOOT_REQUIRED 3017 + /// The requested operation failed. A system reboot is required to roll back changes made. + /// + ERROR_FAIL_REBOOT_REQUIRED = 3017, } /// diff --git a/src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs index e76461f3..42301f30 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/ExePackageTests.cs @@ -142,6 +142,32 @@ namespace WixToolsetTest.BurnE2E Assert.True(LogVerifier.MessageInLogFile(installLogPath, $"testexe.exe\" /regd HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{arpId}")); } + [RuntimeFact] + public void CanUseLargeCustomExitCode() + { + var customExitCodeExePackageBundle = this.CreateBundleInstaller(@"CustomExitCodeExePackage"); + + var installLogPath = customExitCodeExePackageBundle.Install(5, "EXEEXITCODE=-2147024891"); + customExitCodeExePackageBundle.VerifyUnregisteredAndRemovedFromPackageCache(); + + Assert.True(LogVerifier.MessageInLogFile(installLogPath, "TestExe.exe\" /ec -2147024891")); + Assert.True(LogVerifier.MessageInLogFile(installLogPath, "The process for package: TestExe exited with code: 0x80070005. The exit code has been translated to type: ErrorScheduleReboot and restart: Required.")); + Assert.True(LogVerifier.MessageInLogFile(installLogPath, "Applied execute package: TestExe, result: 0x80070005, restart: Required")); + Assert.True(LogVerifier.MessageInLogFile(installLogPath, "Apply complete, result: 0x80070005, restart: Required, ba requested restart: No")); + } + + [RuntimeFact] + public void CanUseWildcardCustomExitCode() + { + var customExitCodeExePackageBundle = this.CreateBundleInstaller(@"CustomExitCodeExePackage"); + + var installLogPath = customExitCodeExePackageBundle.Install((int)MSIExec.MSIExecReturnCode.SUCCESS, "EXEEXITCODE=1"); + customExitCodeExePackageBundle.VerifyUnregisteredAndRemovedFromPackageCache(); + + Assert.True(LogVerifier.MessageInLogFile(installLogPath, "TestExe.exe\" /ec 1")); + Assert.True(LogVerifier.MessageInLogFile(installLogPath, "The process for package: TestExe exited with code: 0x1. The exit code has been translated to type: Success and restart: None.")); + } + [RuntimeFact] public void CanInstallAndUninstallPerUserArpEntryExePackage() { diff --git a/src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs b/src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs index df666833..f7ec8647 100644 --- a/src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs +++ b/src/test/burn/WixToolsetTest.BurnE2E/UpdateBundleTests.cs @@ -242,5 +242,41 @@ namespace WixToolsetTest.BurnE2E packageBv1.VerifyInstalled(false); packageBv2.VerifyInstalled(false); } + + // Installs bundle Bv1.0 then attempts an update to bundle Bv2.0 during modify (server exists, v2.0 feed with wrong hash). + [RuntimeFact] + public void CanBlockWrongUpdateBundleFromDownloadInsteadOfModify() + { + var packageBv1 = this.CreatePackageInstaller("PackageBv1"); + var packageBv2 = this.CreatePackageInstaller("PackageBv2"); + var bundleBv1 = this.CreateBundleInstaller("BundleBv1"); + var bundleBv2 = this.CreateBundleInstaller("BundleBv2"); + var webServer = this.CreateWebServer(); + + webServer.AddFiles(new Dictionary + { + { "/BundleB/feed", Path.Combine(this.TestContext.TestDataFolder, "FeedBv2.0_wronghash.xml") }, + { "/BundleB/2.0/BundleB.exe", bundleBv2.Bundle }, + }); + webServer.Start(); + + packageBv1.VerifyInstalled(false); + packageBv2.VerifyInstalled(false); + + bundleBv1.Install(); + bundleBv1.VerifyRegisteredAndInPackageCache(); + + packageBv1.VerifyInstalled(true); + packageBv2.VerifyInstalled(false); + + // Run the v1 bundle requesting an update bundle. + bundleBv1.Modify(unchecked((int)0x80091007), arguments: "-checkupdate"); + + bundleBv1.VerifyRegisteredAndInPackageCache(); + bundleBv2.VerifyUnregisteredAndRemovedFromPackageCache(); + + packageBv1.VerifyInstalled(true); + packageBv2.VerifyInstalled(false); + } } } -- cgit v1.2.3-55-g6feb