Fix and run Burn 64-bit unit tests.
Sean Hall committed
Feb 28, 2022 at 18:41 UTC
3f658fa2b4bd80619fcf89e1e87ae12b48effb7a
8 files changed
+157
-79
src/burn/burn.cmd
+2
-1
@@ -15,7 +15,8 @@ nuget restore || exit /b
15
16
msbuild burn_t.proj -p:Configuration=%_C% -nologo -m -warnaserror -bl:%_L%\burn_build.binlog || exit /b
17
18
-msbuild test\BurnUnitTest -t:Test -p:Configuration=%_C% -nologo -p:CppCliTestResultsFile="%_L%\TestResults\BurnUnitTest.xunit2.xml" || exit /b
18
+msbuild test\BurnUnitTest -t:Test -p:Configuration=%_C% -p:Platform=Win32 -nologo -p:CppCliTestResultsFile="%_L%\TestResults\BurnUnitTest32.xunit2.xml" || exit /b
19
+msbuild test\BurnUnitTest -t:Test -p:Configuration=%_C% -p:Platform=x64 -nologo -p:CppCliTestResultsFile="%_L%\TestResults\BurnUnitTest64.xunit2.xml" || exit /b
20
21
@popd
22
@endlocal
src/burn/burn_t.proj
+1
@@ -1,6 +1,7 @@
1
<Project Sdk="Microsoft.Build.Traversal">
2
<ItemGroup>
3
<ProjectReference Include="test\BurnUnitTest\BurnUnitTest.vcxproj" Properties="Platform=x86" BuildInParallel="false" />
4
+ <ProjectReference Include="test\BurnUnitTest\BurnUnitTest.vcxproj" Properties="Platform=x64" BuildInParallel="false" />
5
6
<ProjectReference Include="stub\stub.vcxproj" Properties="Platform=x86" />
7
<ProjectReference Include="stub\stub.vcxproj" Properties="Platform=x64" />
src/burn/test/BurnUnitTest/RegistrationTest.cpp
+2
-2
@@ -37,8 +37,8 @@ namespace Bootstrapper
37
{
38
this->testRegistry = registryFixture;
39
40
- this->testRunKeyPath = this->testRegistry->GetDirectHkcuPath(gcnew String(REGISTRY_RUN_KEY));
41
- this->testUninstallKeyPath = this->testRegistry->GetDirectHkcuPath(gcnew String(REGISTRY_UNINSTALL_KEY), gcnew String(TEST_BUNDLE_ID));
40
+ this->testRunKeyPath = this->testRegistry->GetDirectHkcuPath(REG_KEY_DEFAULT, gcnew String(REGISTRY_RUN_KEY));
41
+ this->testUninstallKeyPath = this->testRegistry->GetDirectHkcuPath(REG_KEY_DEFAULT, gcnew String(REGISTRY_UNINSTALL_KEY), gcnew String(TEST_BUNDLE_ID));
42
this->testVariableKeyPath = Path::Combine(this->testUninstallKeyPath, gcnew String(L"variables"));
43
}
44
src/burn/test/BurnUnitTest/TestRegistryFixture.cpp
+138
-70
@@ -4,50 +4,108 @@
4
5
#define TEST_REGISTRY_FIXTURE_ROOT_PATH L"SOFTWARE\\WiX_Burn_UnitTest"
6
#define TEST_REGISTRY_FIXTURE_HKLM_PATH TEST_REGISTRY_FIXTURE_ROOT_PATH L"\\HKLM"
7
+#define TEST_REGISTRY_FIXTURE_HKLM32_PATH TEST_REGISTRY_FIXTURE_ROOT_PATH L"\\Wow6432Node\\HKLM"
8
#define TEST_REGISTRY_FIXTURE_HKCU_PATH TEST_REGISTRY_FIXTURE_ROOT_PATH L"\\HKCU"
9
+#define TEST_REGISTRY_FIXTURE_HKCU32_PATH TEST_REGISTRY_FIXTURE_ROOT_PATH L"\\Wow6432Node\\HKCU"
10
9
-static LSTATUS APIENTRY TestRegistryFixture_RegCreateKeyExW(
11
+static REG_KEY_BITNESS GetDesiredBitness(
12
+ __in REGSAM samDesired
13
+ )
14
+{
15
+ REG_KEY_BITNESS desiredBitness = REG_KEY_DEFAULT;
16
+
17
+ switch (KEY_WOW64_RES & samDesired)
18
+ {
19
+ case KEY_WOW64_32KEY:
20
+ desiredBitness = REG_KEY_32BIT;
21
+ break;
22
+ case KEY_WOW64_64KEY:
23
+ desiredBitness = REG_KEY_64BIT;
24
+ break;
25
+ default:
26
+#if defined(_WIN64)
27
+ desiredBitness = REG_KEY_64BIT;
28
+#else
29
+ desiredBitness = REG_KEY_32BIT;
30
+#endif
31
+ break;
32
+ }
33
+
34
+ return desiredBitness;
35
+}
36
+
37
+static LSTATUS GetRootKey(
38
__in HKEY hKey,
11
- __in LPCWSTR lpSubKey,
12
- __reserved DWORD Reserved,
13
- __in_opt LPWSTR lpClass,
14
- __in DWORD dwOptions,
39
__in REGSAM samDesired,
16
- __in_opt CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
17
- __out PHKEY phkResult,
18
- __out_opt LPDWORD lpdwDisposition
19
- )
40
+ __in ACCESS_MASK accessDesired,
41
+ __inout HKEY* phkRoot)
42
{
43
LSTATUS ls = ERROR_SUCCESS;
44
LPCWSTR wzRoot = NULL;
23
- HKEY hkRoot = NULL;
45
46
if (HKEY_LOCAL_MACHINE == hKey)
47
{
27
- wzRoot = TEST_REGISTRY_FIXTURE_HKLM_PATH;
48
+ if (REG_KEY_32BIT == GetDesiredBitness(samDesired))
49
+ {
50
+ wzRoot = TEST_REGISTRY_FIXTURE_HKLM32_PATH;
51
+ }
52
+ else
53
+ {
54
+ wzRoot = TEST_REGISTRY_FIXTURE_HKLM_PATH;
55
+ }
56
}
57
else if (HKEY_CURRENT_USER == hKey)
58
{
31
- wzRoot = TEST_REGISTRY_FIXTURE_HKCU_PATH;
59
+ if (REG_KEY_32BIT == GetDesiredBitness(samDesired))
60
+ {
61
+ wzRoot = TEST_REGISTRY_FIXTURE_HKCU32_PATH;
62
+ }
63
+ else
64
+ {
65
+ wzRoot = TEST_REGISTRY_FIXTURE_HKCU_PATH;
66
+ }
67
+ }
68
+
69
+ if (wzRoot)
70
+ {
71
+ ls = ::RegOpenKeyExW(HKEY_CURRENT_USER, wzRoot, 0, KEY_WRITE | accessDesired, phkRoot);
72
}
73
else
74
{
35
- hkRoot = hKey;
75
+ *phkRoot = hKey;
76
}
77
38
- if (wzRoot)
78
+ return ls;
79
+}
80
+
81
+static LSTATUS APIENTRY TestRegistryFixture_RegCreateKeyExW(
82
+ __in HKEY hKey,
83
+ __in LPCWSTR lpSubKey,
84
+ __reserved DWORD Reserved,
85
+ __in_opt LPWSTR lpClass,
86
+ __in DWORD dwOptions,
87
+ __in REGSAM samDesired,
88
+ __in_opt CONST LPSECURITY_ATTRIBUTES lpSecurityAttributes,
89
+ __out PHKEY phkResult,
90
+ __out_opt LPDWORD lpdwDisposition
91
+ )
92
+{
93
+ LSTATUS ls = ERROR_SUCCESS;
94
+ HKEY hkRoot = NULL;
95
+
96
+ ls = GetRootKey(hKey, samDesired, 0, &hkRoot);
97
+ if (ERROR_SUCCESS != ls)
98
{
40
- ls = ::RegOpenKeyExW(HKEY_CURRENT_USER, wzRoot, 0, KEY_WRITE, &hkRoot);
41
- if (ERROR_SUCCESS != ls)
42
- {
43
- ExitFunction();
44
- }
99
+ ExitFunction();
100
}
101
102
ls = ::RegCreateKeyExW(hkRoot, lpSubKey, Reserved, lpClass, dwOptions, samDesired, lpSecurityAttributes, phkResult, lpdwDisposition);
103
104
LExit:
50
- ReleaseRegKey(hkRoot);
105
+ if (hkRoot != hKey)
106
+ {
107
+ ReleaseRegKey(hkRoot);
108
+ }
109
110
return ls;
111
}
@@ -61,35 +119,21 @@ static LSTATUS APIENTRY TestRegistryFixture_RegOpenKeyExW(
119
)
120
{
121
LSTATUS ls = ERROR_SUCCESS;
64
- LPCWSTR wzRoot = NULL;
122
HKEY hkRoot = NULL;
123
67
- if (HKEY_LOCAL_MACHINE == hKey)
68
- {
69
- wzRoot = TEST_REGISTRY_FIXTURE_HKLM_PATH;
70
- }
71
- else if (HKEY_CURRENT_USER == hKey)
72
- {
73
- wzRoot = TEST_REGISTRY_FIXTURE_HKCU_PATH;
74
- }
75
- else
76
- {
77
- hkRoot = hKey;
78
- }
79
-
80
- if (wzRoot)
124
+ ls = GetRootKey(hKey, samDesired, 0, &hkRoot);
125
+ if (ERROR_SUCCESS != ls)
126
{
82
- ls = ::RegOpenKeyExW(HKEY_CURRENT_USER, wzRoot, 0, KEY_WRITE, &hkRoot);
83
- if (ERROR_SUCCESS != ls)
84
- {
85
- ExitFunction();
86
- }
127
+ ExitFunction();
128
}
129
130
ls = ::RegOpenKeyExW(hkRoot, lpSubKey, ulOptions, samDesired, phkResult);
131
132
LExit:
92
- ReleaseRegKey(hkRoot);
133
+ if (hkRoot != hKey)
134
+ {
135
+ ReleaseRegKey(hkRoot);
136
+ }
137
138
return ls;
139
}
@@ -102,35 +146,21 @@ static LSTATUS APIENTRY TestRegistryFixture_RegDeleteKeyExW(
146
)
147
{
148
LSTATUS ls = ERROR_SUCCESS;
105
- LPCWSTR wzRoot = NULL;
149
HKEY hkRoot = NULL;
150
108
- if (HKEY_LOCAL_MACHINE == hKey)
151
+ ls = GetRootKey(hKey, samDesired, samDesired, &hkRoot);
152
+ if (ERROR_SUCCESS != ls)
153
{
110
- wzRoot = TEST_REGISTRY_FIXTURE_HKLM_PATH;
111
- }
112
- else if (HKEY_CURRENT_USER == hKey)
113
- {
114
- wzRoot = TEST_REGISTRY_FIXTURE_HKCU_PATH;
115
- }
116
- else
117
- {
118
- hkRoot = hKey;
119
- }
120
-
121
- if (wzRoot)
122
- {
123
- ls = ::RegOpenKeyExW(HKEY_CURRENT_USER, wzRoot, 0, KEY_WRITE | samDesired, &hkRoot);
124
- if (ERROR_SUCCESS != ls)
125
- {
126
- ExitFunction();
127
- }
154
+ ExitFunction();
155
}
156
157
ls = ::RegDeleteKeyExW(hkRoot, lpSubKey, samDesired, Reserved);
158
159
LExit:
133
- ReleaseRegKey(hkRoot);
160
+ if (hkRoot != hKey)
161
+ {
162
+ ReleaseRegKey(hkRoot);
163
+ }
164
165
return ls;
166
}
@@ -146,8 +176,6 @@ namespace WixBuildTools
176
TestRegistryFixture::TestRegistryFixture()
177
{
178
this->rootPath = gcnew String(TEST_REGISTRY_FIXTURE_ROOT_PATH);
149
- this->hkcuPath = gcnew String(TEST_REGISTRY_FIXTURE_HKCU_PATH);
150
- this->hklmPath = gcnew String(TEST_REGISTRY_FIXTURE_HKLM_PATH);
179
}
180
181
TestRegistryFixture::~TestRegistryFixture()
@@ -160,8 +188,10 @@ namespace WixBuildTools
188
// set mock API's
189
RegFunctionOverride(TestRegistryFixture_RegCreateKeyExW, TestRegistryFixture_RegOpenKeyExW, TestRegistryFixture_RegDeleteKeyExW, NULL, NULL, NULL, NULL, NULL, NULL);
190
163
- Registry::CurrentUser->CreateSubKey(this->hkcuPath);
164
- Registry::CurrentUser->CreateSubKey(this->hklmPath);
191
+ Registry::CurrentUser->CreateSubKey(TEST_REGISTRY_FIXTURE_HKCU_PATH);
192
+ Registry::CurrentUser->CreateSubKey(TEST_REGISTRY_FIXTURE_HKCU32_PATH);
193
+ Registry::CurrentUser->CreateSubKey(TEST_REGISTRY_FIXTURE_HKLM_PATH);
194
+ Registry::CurrentUser->CreateSubKey(TEST_REGISTRY_FIXTURE_HKLM32_PATH);
195
}
196
197
void TestRegistryFixture::TearDown()
@@ -171,14 +201,52 @@ namespace WixBuildTools
201
RegFunctionOverride(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
202
}
203
174
- String^ TestRegistryFixture::GetDirectHkcuPath(... array<String^>^ paths)
204
+ String^ TestRegistryFixture::GetDirectHkcuPath(REG_KEY_BITNESS bitness, ... array<String^>^ paths)
205
{
176
- return Path::Combine(Registry::CurrentUser->Name, this->hkcuPath, Path::Combine(paths));
206
+ String^ hkcuPath;
207
+
208
+ switch (bitness)
209
+ {
210
+ case REG_KEY_32BIT:
211
+ hkcuPath = TEST_REGISTRY_FIXTURE_HKCU32_PATH;
212
+ break;
213
+ case REG_KEY_64BIT:
214
+ hkcuPath = TEST_REGISTRY_FIXTURE_HKCU_PATH;
215
+ break;
216
+ default:
217
+#if defined(_WIN64)
218
+ hkcuPath = TEST_REGISTRY_FIXTURE_HKCU_PATH;
219
+#else
220
+ hkcuPath = TEST_REGISTRY_FIXTURE_HKCU32_PATH;
221
+#endif
222
+ break;
223
+ }
224
+
225
+ return Path::Combine(Registry::CurrentUser->Name, hkcuPath, Path::Combine(paths));
226
}
227
179
- String^ TestRegistryFixture::GetDirectHklmPath(... array<String^>^ paths)
228
+ String^ TestRegistryFixture::GetDirectHklmPath(REG_KEY_BITNESS bitness, ... array<String^>^ paths)
229
{
181
- return Path::Combine(Registry::CurrentUser->Name, this->hklmPath, Path::Combine(paths));
230
+ String^ hklmPath;
231
+
232
+ switch (bitness)
233
+ {
234
+ case REG_KEY_32BIT:
235
+ hklmPath = TEST_REGISTRY_FIXTURE_HKLM32_PATH;
236
+ break;
237
+ case REG_KEY_64BIT:
238
+ hklmPath = TEST_REGISTRY_FIXTURE_HKLM_PATH;
239
+ break;
240
+ default:
241
+#if defined(_WIN64)
242
+ hklmPath = TEST_REGISTRY_FIXTURE_HKLM_PATH;
243
+#else
244
+ hklmPath = TEST_REGISTRY_FIXTURE_HKLM32_PATH;
245
+#endif
246
+ break;
247
+ }
248
+
249
+ return Path::Combine(Registry::CurrentUser->Name, hklmPath, Path::Combine(paths));
250
}
251
}
252
}
src/burn/test/BurnUnitTest/TestRegistryFixture.h
+2
-4
@@ -11,8 +11,6 @@ namespace TestSupport
11
{
12
private:
13
String^ rootPath;
14
- String^ hkcuPath;
15
- String^ hklmPath;
14
public:
15
TestRegistryFixture();
16
@@ -22,9 +20,9 @@ namespace TestSupport
20
21
void TearDown();
22
25
- String^ GetDirectHkcuPath(... array<String^>^ paths);
23
+ String^ GetDirectHkcuPath(REG_KEY_BITNESS bitness, ... array<String^>^ paths);
24
27
- String^ GetDirectHklmPath(... array<String^>^ paths);
25
+ String^ GetDirectHklmPath(REG_KEY_BITNESS bitness, ... array<String^>^ paths);
26
};
27
}
28
}
src/burn/test/BurnUnitTest/VariableTest.cpp
+8
@@ -497,7 +497,11 @@ namespace Bootstrapper
497
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::ApplicationData) + "\\", VariableGetStringHelper(&variables, L"AppDataFolder"));
498
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::CommonApplicationData) + "\\", VariableGetStringHelper(&variables, L"CommonAppDataFolder"));
499
500
+#if defined(_WIN64)
501
+ Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + "\\", VariableGetStringHelper(&variables, L"ProgramFiles64Folder"));
502
+#else
503
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::ProgramFiles) + "\\", VariableGetStringHelper(&variables, L"ProgramFilesFolder"));
504
+#endif
505
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::DesktopDirectory) + "\\", VariableGetStringHelper(&variables, L"DesktopFolder"));
506
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::Favorites) + "\\", VariableGetStringHelper(&variables, L"FavoritesFolder"));
507
VariableGetStringHelper(&variables, L"FontsFolder");
@@ -514,7 +518,11 @@ namespace Bootstrapper
518
Assert::Equal<String^>(System::IO::Path::GetTempPath(), System::IO::Path::GetFullPath(VariableGetStringHelper(&variables, L"TempFolder")));
519
520
VariableGetStringHelper(&variables, L"AdminToolsFolder");
521
+#if defined(_WIN64)
522
+ Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::CommonProgramFiles) + "\\", VariableGetStringHelper(&variables, L"CommonFiles64Folder"));
523
+#else
524
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::CommonProgramFiles) + "\\", VariableGetStringHelper(&variables, L"CommonFilesFolder"));
525
+#endif
526
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::MyPictures) + "\\", VariableGetStringHelper(&variables, L"MyPicturesFolder"));
527
Assert::Equal<String^>(Environment::GetFolderPath(Environment::SpecialFolder::Templates) + "\\", VariableGetStringHelper(&variables, L"TemplateFolder"));
528
src/internal/WixBuildTools.TestSupport.Native/build/WixBuildTools.TestSupport.Native.targets
+2
-1
@@ -42,7 +42,8 @@
42
<Error Condition="!Exists('$(RootPackagesFolder)xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props')" Text="$([System.String]::Format('$(ErrorText)', '$(RootPackagesFolder)xunit.runner.visualstudio.2.4.1\build\net20\xunit.runner.visualstudio.props'))" />
43
</Target>
44
45
- <UsingTask AssemblyFile="$(RootPackagesFolder)xunit.runner.msbuild.2.4.1\build\net452\xunit.runner.msbuild.net452.dll" TaskName="Xunit.Runner.MSBuild.xunit" Architecture="x86" />
45
+ <UsingTask AssemblyFile="$(RootPackagesFolder)xunit.runner.msbuild.2.4.1\build\net452\xunit.runner.msbuild.net452.dll" TaskName="Xunit.Runner.MSBuild.xunit" Architecture="x86" Condition=" '$(Platform)'!='x64' " />
46
+ <UsingTask AssemblyFile="$(RootPackagesFolder)xunit.runner.msbuild.2.4.1\build\net452\xunit.runner.msbuild.net452.dll" TaskName="Xunit.Runner.MSBuild.xunit" Architecture="x64" Condition=" '$(Platform)'=='x64' " />
47
<Target Name="Test">
48
<!-- https://xunit.net/docs/running-tests-in-msbuild -->
49
<!-- https://github.com/xunit/xunit/issues/2188 -->
src/testresultfilelist.txt
+2
-1
@@ -1,7 +1,8 @@
1
build/logs/TestResults/api_wix.trx
2
build/logs/TestResults/BalUtilUnitTest.xunit2.xml
3
build/logs/TestResults/BextUtilUnitTest.xunit2.xml
4
-build/logs/TestResults/BurnUnitTest.xunit2.xml
4
+build/logs/TestResults/BurnUnitTest32.xunit2.xml
5
+build/logs/TestResults/BurnUnitTest64.xunit2.xml
6
build/logs/TestResults/DutilUnitTest.xunit2.xml
7
build/logs/TestResults/WixToolsetTest.BuildTasks.trx
8
build/logs/TestResults/WixToolsetTest.BurnE2E.trx