aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2022-09-02 16:12:26 -0500
committerSean Hall <r.sean.hall@gmail.com>2022-09-03 15:29:26 -0500
commit7728e34e48a4fdb710ecc92dd8dca833bff3993f (patch)
tree83d9a6a5068985670dc47121d400fc7c491c23ec /src/test
parenteea6121f388197435529922b3cb13d3631afb9a8 (diff)
downloadwix-7728e34e48a4fdb710ecc92dd8dca833bff3993f.tar.gz
wix-7728e34e48a4fdb710ecc92dd8dca833bff3993f.tar.bz2
wix-7728e34e48a4fdb710ecc92dd8dca833bff3993f.zip
Use elevated engine to make the restart request when it is available.
Fixes 6145
Diffstat (limited to 'src/test')
-rw-r--r--src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp33
-rw-r--r--src/test/burn/TestData/Manual/BundleA/BundleA.wixproj4
-rw-r--r--src/test/burn/TestData/Manual/BundleA/BundleA.wxs5
-rw-r--r--src/test/burn/TestData/Manual/BundleA/ManualTests.txt110
4 files changed, 119 insertions, 33 deletions
diff --git a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp
index ce74534d..c619dbd6 100644
--- a/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp
+++ b/src/test/burn/TestData/Manual/BafThmutilTesting/BafThmUtilTesting.cpp
@@ -89,39 +89,6 @@ public: // IBAFunctions
89 return hr; 89 return hr;
90 } 90 }
91 91
92 virtual STDMETHODIMP WndProc(
93 __in HWND hWnd,
94 __in UINT uMsg,
95 __in WPARAM /*wParam*/,
96 __in LPARAM lParam,
97 __inout BOOL* pfProcessed,
98 __inout LRESULT* plResult
99 )
100 {
101 switch (uMsg)
102 {
103 case WM_QUERYENDSESSION:
104 if (BOOTSTRAPPER_DISPLAY_FULL <= m_command.display)
105 {
106 DWORD dwEndSession = static_cast<DWORD>(lParam);
107 if (ENDSESSION_CRITICAL & dwEndSession)
108 {
109 // Return false to get the WM_ENDSESSION message so that critical shutdowns can be delayed.
110 *plResult = FALSE;
111 *pfProcessed = TRUE;
112 }
113 }
114 break;
115 case WM_ENDSESSION:
116 if (BOOTSTRAPPER_DISPLAY_FULL <= m_command.display)
117 {
118 ::MessageBoxW(hWnd, L"WM_ENDSESSION", L"BAFunctions WndProc", MB_OK);
119 }
120 break;
121 }
122 return S_OK;
123 }
124
125public: //IBootstrapperApplication 92public: //IBootstrapperApplication
126 virtual STDMETHODIMP OnExecuteBegin( 93 virtual STDMETHODIMP OnExecuteBegin(
127 __in DWORD /*cExecutingPackages*/, 94 __in DWORD /*cExecutingPackages*/,
diff --git a/src/test/burn/TestData/Manual/BundleA/BundleA.wixproj b/src/test/burn/TestData/Manual/BundleA/BundleA.wixproj
index 907b85c9..225664b9 100644
--- a/src/test/burn/TestData/Manual/BundleA/BundleA.wixproj
+++ b/src/test/burn/TestData/Manual/BundleA/BundleA.wixproj
@@ -11,8 +11,12 @@
11 <ItemGroup> 11 <ItemGroup>
12 <ProjectReference Include="..\BafThmUtilTesting\BafThmUtilTesting.vcxproj" Properties="Platform=x86" ReferenceOutputAssembly="false" /> 12 <ProjectReference Include="..\BafThmUtilTesting\BafThmUtilTesting.vcxproj" Properties="Platform=x86" ReferenceOutputAssembly="false" />
13 <ProjectReference Include="..\PackageA\PackageA.wixproj" /> 13 <ProjectReference Include="..\PackageA\PackageA.wixproj" />
14 <ProjectReference Include="..\..\TestBA\TestBAWixlib\testbawixlib.wixproj" />
14 </ItemGroup> 15 </ItemGroup>
15 <ItemGroup> 16 <ItemGroup>
16 <PackageReference Include="WixToolset.Bal.wixext" /> 17 <PackageReference Include="WixToolset.Bal.wixext" />
17 </ItemGroup> 18 </ItemGroup>
19 <Target Name="CopyManualInstructions" AfterTargets="AfterBuild">
20 <Copy SourceFiles="ManualTests.txt" DestinationFiles="$(OutputPath)ManualTests.txt" />
21 </Target>
18</Project> \ No newline at end of file 22</Project> \ No newline at end of file
diff --git a/src/test/burn/TestData/Manual/BundleA/BundleA.wxs b/src/test/burn/TestData/Manual/BundleA/BundleA.wxs
index 44abc645..20b68a91 100644
--- a/src/test/burn/TestData/Manual/BundleA/BundleA.wxs
+++ b/src/test/burn/TestData/Manual/BundleA/BundleA.wxs
@@ -11,7 +11,12 @@
11 <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)"> 11 <MsiPackage Id="PackageA" SourceFile="$(var.PackageA.TargetPath)">
12 <MsiProperty Name="FORCERESTARTCA" Value="[FORCERESTARTCA]" /> 12 <MsiProperty Name="FORCERESTARTCA" Value="[FORCERESTARTCA]" />
13 </MsiPackage> 13 </MsiPackage>
14 <ExePackage Id="ExeA" Cache="remove" PerMachine="yes"
15 DetectCondition="" Permanent="yes" InstallArguments="/ec [EXEEXITCODE]">
16 <PayloadGroupRef Id="TestExePayloads" />
17 </ExePackage>
14 </PackageGroup> 18 </PackageGroup>
19 <Variable Name="EXEEXITCODE" bal:Overridable="yes" Value="0" />
15 <Variable Name="FORCERESTARTCA" bal:Overridable="yes" /> 20 <Variable Name="FORCERESTARTCA" bal:Overridable="yes" />
16 </Fragment> 21 </Fragment>
17</Wix> 22</Wix>
diff --git a/src/test/burn/TestData/Manual/BundleA/ManualTests.txt b/src/test/burn/TestData/Manual/BundleA/ManualTests.txt
new file mode 100644
index 00000000..d432f94a
--- /dev/null
+++ b/src/test/burn/TestData/Manual/BundleA/ManualTests.txt
@@ -0,0 +1,110 @@
1VariousWixstdbaAndBAFunctionsAndThmutilFunctionality
21. Run BundleA.exe unelevated.
32. Click Test.
43. Verify that the BafThmUtilTestingTheme window comes up and click Start.
54. There are several pages. Follow the instructions on each page before clicking Next.
65. Click ThemeClose to close the BafThmUtilTestingTheme window.
76. Click the Options button.
87. Click the Browse button.
98. Type in "C:\Program Files (x86)\mytest".
109. Click the Select Folder button.
1110. Verify the Install location textbox was populated with "C:\Program Files (x86)\mytest".
1211. Click OK.
1312. Verify the caption of the window is "~Manual - BundleA Setup" and the text is "~Manual - BundleA".
1413. Verify the Install button has the UAC shield and then click it (accept elevation).
1514. Click OK on the OnExecuteBegin message box.
1615. After it finishes, verify the window text is "Installation Successfully Completed".
1716. Click Close.
1817. Verify in the bundle log that the variable InstallFolder was set to "C:\Program Files (x86)\mytest".
1918. Run BundleA.exe again.
2019. Click Uninstall (accept elevation).
2120. Click OK on the OnExecuteBegin message box.
2221. After it finishes, verify the window text is "Uninstallation Successfully Completed".
2322. Click Close.
24
25CanBlockShutdownDuringApply
261. Run BundleA.exe unelevated.
272. Click Install (accept elevation).
283. Verify the OnExecuteBegin message box comes up with the message "Shutdown requests should be denied right now." and leave it up.
294. Use the Windows UI to try to restart the machine.
305. On current versions of Windows, full screen UI will display that the bundle is blocking restart. Click Cancel to stop the restart.
316. Click OK on the message box from step 3 to allow installation to continue.
327. Verify that the installation was successful and then close the bundle.
338. Look in the bundle log and verify that the restart request didn't cause any errors, and that it logged messages that look like:
34
35i400: Received system request to shut down the process: allowed: No, elevated: No, critical: No, logoff: No, close app: No
36i400: Received system request to shut down the process: allowed: No, elevated: Yes, critical: No, logoff: No, close app: No
37i401: Received result of system request to shut down the process: closing: No, elevated: No, critical: No, logoff: No, close app: No
38i401: Received result of system request to shut down the process: closing: No, elevated: Yes, critical: No, logoff: No, close app: No
39
40(9. Uninstall the bundle)
41
42CanLogRestartFailure
43
44 Note: this test requires special setup. Change the User Rights Assignment such that no one has the shutdown privilege. Logout and log back in after making changes to make them take effect.
45 (mmc.exe -> Group Policy Object Editor -> Local Computer Policy -> Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> User Rights Assignment -> Shut down the system)
46
471. Run BundleA.exe elevated with the command line EXEEXITCODE=3010.
482. Click Install.
493. Click OK on the OnExecuteBegin message box.
504. Click Restart.
515. Look in the bundle log and verify that the restart request failure was logged with messages that look like:
52
53w005: Restarting computer...
54e000: Error 0x80070005: Failed to schedule restart.
55e023: The restart request failed, error: 0x80070005. The machine will need to be manually restarted.
56
57(5. Uninstall the bundle)
58
59CanGracefullyCutApplyShortInResponseToCriticalShutdown
60
61 Note: Requires different User Rights Assignment settings from CanLogRestartFailure - Administrators need to have the shutdown privilege.
62
631. Run BundleA.exe FORCERESTARTCA=1.
642. Click Install (accept elevation).
653. Click OK on the OnExecuteBegin message box.
664. Verify the machine automatically restarts with no chance to cancel it (because the MSI forces a restart).
675. Login to the machine.
686. Verify that the bundle automatically started running again.
697. Click OK on the OnExecuteBegin message box.
708. Verify that the installation was successful and then close the bundle.
719. Look in the bundle log and verify that the restart request didn't cause any errors, and that it logged messages that look like:
72
73i301: Applying execute package: PackageA, action: Install, path: C:\ProgramData\Package Cache\{1C6F49C0-B4BA-438D-871D-2B5E91C0EED5}v1.0.0.0\PackageA.msi, arguments: ' FORCERESTARTCA="1" ARPSYSTEMCOMPONENT="1" MSIFASTINSTALL="7" BURNMSIINSTALL=1 REINSTALLMODE="muso" REBOOT=ReallySuppress'
74...
75i400: Received system request to shut down the process: allowed: No, elevated: No, critical: Yes, logoff: No, close app: No
76i400: Received system request to shut down the process: allowed: No, elevated: Yes, critical: Yes, logoff: No, close app: No
77i401: Received result of system request to shut down the process: closing: Yes, elevated: No, critical: Yes, logoff: No, close app: No
78i401: Received result of system request to shut down the process: closing: Yes, elevated: Yes, critical: Yes, logoff: No, close app: No
79...
80i319: Applied execute package: PackageA, result: 0x0, restart: Initiated
81...
82i420: Resuming automatic updates.
83i421: Resumed automatic updates.
84=======================================
85i001: Burn x86 v4.0.0.525, Windows v10.0 x64 (Build 19041: Service Pack 0), path: C:\ProgramData\Package Cache\{30D63455-CD23-4AC3-81CC-4695434F848A}\BundleA.exe
86
87(10. Uninstall the bundle)
88
89CanRestartFromUnelevatedPerMachineBundleWithoutShutdownPrivilege
90
91 Note: Requires different User Rights Assignment settings from CanLogRestartFailure - Only Administrators should have the shutdown privilege. Users should not have it.
92
931. Run BundleA.exe unelevated with the command line EXEEXITCODE=3010.
942. Click Install.
953. Verify that the UAC prompt came up and accept elevation.
964. Click OK on the OnExecuteBegin message box.
975. Click Restart.
986. The machine should restart.
997. Login to the machine.
1008. Verify that the bundle did not automatically start running.
1019. Look in the bundle log and verify that the restart request didn't cause any errors, and that it logged messages that look like (the process id for w005 must match the elevated i400 and i401):
102
103[0DDC:0448]w005: Restarting computer...
104[1228:18CC]i400: Received system request to shut down the process: allowed: Yes, elevated: No, critical: No, logoff: No, close app: No
105[1228:18CC]i401: Received result of system request to shut down the process: closing: Yes, elevated: No, critical: No, logoff: No, close app: No
106[0DDC:0954]i400: Received system request to shut down the process: allowed: Yes, elevated: Yes, critical: No, logoff: No, close app: No
107[0DDC:0954]i401: Received result of system request to shut down the process: closing: Yes, elevated: Yes, critical: No, logoff: No, close app: No
108=======================================
109
110(10. Uninstall the bundle)