diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs | 78 | ||||
| -rw-r--r-- | src/test/WixToolsetTest.ManagedHost/TestEngine.cs | 11 | ||||
| -rw-r--r-- | src/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs | 7 | ||||
| -rw-r--r-- | src/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs | 7 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/Example.TestEngine.vcxproj | 3 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/ExampleTestEngine.cpp | 20 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/ReloadEngine.cpp | 43 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/ReloadEngine.h | 8 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/ShutdownEngine.cpp | 5 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/ShutdownEngine.h | 8 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/TestEngine.cpp | 32 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/TestEngine.h | 6 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/precomp.h | 7 |
13 files changed, 217 insertions, 18 deletions
diff --git a/src/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs b/src/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs index 8ef0320e..8b0a3691 100644 --- a/src/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs +++ b/src/test/WixToolsetTest.ManagedHost/MbaHostFixture.cs | |||
| @@ -78,5 +78,83 @@ namespace WixToolsetTest.ManagedHost | |||
| 78 | Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); | 78 | Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); |
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | |||
| 82 | [Fact] | ||
| 83 | public void CanReloadFullFramework2MBA() | ||
| 84 | { | ||
| 85 | using (var fs = new DisposableFileSystem()) | ||
| 86 | { | ||
| 87 | var baseFolder = fs.GetFolder(); | ||
| 88 | var binFolder = Path.Combine(baseFolder, "bin"); | ||
| 89 | var bundleFile = Path.Combine(binFolder, "FullFramework2MBA.exe"); | ||
| 90 | var baSourceFolder = TestData.Get(@"..\examples"); | ||
| 91 | var bundleSourceFolder = TestData.Get(@"TestData\FullFramework2MBA"); | ||
| 92 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 93 | |||
| 94 | var compileResult = WixRunner.Execute(new[] | ||
| 95 | { | ||
| 96 | "build", | ||
| 97 | Path.Combine(bundleSourceFolder, "Bundle.wxs"), | ||
| 98 | "-ext", TestData.Get(@"WixToolset.Bal.wixext.dll"), | ||
| 99 | "-ext", TestData.Get(@"WixToolset.NetFx.wixext.dll"), | ||
| 100 | "-intermediateFolder", intermediateFolder, | ||
| 101 | "-bindpath", baSourceFolder, | ||
| 102 | "-burnStub", TestEngine.BurnStubFile, | ||
| 103 | "-o", bundleFile, | ||
| 104 | }); | ||
| 105 | compileResult.AssertSuccess(); | ||
| 106 | var testEngine = new TestEngine(); | ||
| 107 | |||
| 108 | var result = testEngine.RunReloadEngine(bundleFile, baseFolder); | ||
| 109 | var logMessages = result.Output; | ||
| 110 | Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); | ||
| 111 | Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); | ||
| 112 | Assert.Equal("FullFramework2BA", logMessages[2]); | ||
| 113 | Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); | ||
| 114 | Assert.Equal("Loading managed bootstrapper application.", logMessages[4]); | ||
| 115 | Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]); | ||
| 116 | Assert.Equal("FullFramework2BA", logMessages[6]); | ||
| 117 | Assert.Equal("Shutdown,Restart,0", logMessages[7]); | ||
| 118 | } | ||
| 119 | } | ||
| 120 | |||
| 121 | [Fact] | ||
| 122 | public void CanReloadFullFramework4MBA() | ||
| 123 | { | ||
| 124 | using (var fs = new DisposableFileSystem()) | ||
| 125 | { | ||
| 126 | var baseFolder = fs.GetFolder(); | ||
| 127 | var binFolder = Path.Combine(baseFolder, "bin"); | ||
| 128 | var bundleFile = Path.Combine(binFolder, "FullFramework4MBA.exe"); | ||
| 129 | var baSourceFolder = TestData.Get(@"..\examples"); | ||
| 130 | var bundleSourceFolder = TestData.Get(@"TestData\FullFramework4MBA"); | ||
| 131 | var intermediateFolder = Path.Combine(baseFolder, "obj"); | ||
| 132 | |||
| 133 | var compileResult = WixRunner.Execute(new[] | ||
| 134 | { | ||
| 135 | "build", | ||
| 136 | Path.Combine(bundleSourceFolder, "Bundle.wxs"), | ||
| 137 | "-ext", TestData.Get(@"WixToolset.Bal.wixext.dll"), | ||
| 138 | "-ext", TestData.Get(@"WixToolset.NetFx.wixext.dll"), | ||
| 139 | "-intermediateFolder", intermediateFolder, | ||
| 140 | "-bindpath", baSourceFolder, | ||
| 141 | "-burnStub", TestEngine.BurnStubFile, | ||
| 142 | "-o", bundleFile, | ||
| 143 | }); | ||
| 144 | compileResult.AssertSuccess(); | ||
| 145 | var testEngine = new TestEngine(); | ||
| 146 | |||
| 147 | var result = testEngine.RunReloadEngine(bundleFile, baseFolder); | ||
| 148 | var logMessages = result.Output; | ||
| 149 | Assert.Equal("Loading managed bootstrapper application.", logMessages[0]); | ||
| 150 | Assert.Equal("Creating BA thread to run asynchronously.", logMessages[1]); | ||
| 151 | Assert.Equal("FullFramework4BA", logMessages[2]); | ||
| 152 | Assert.Equal("Shutdown,ReloadBootstrapper,0", logMessages[3]); | ||
| 153 | Assert.Equal("Loading managed bootstrapper application.", logMessages[4]); | ||
| 154 | Assert.Equal("Creating BA thread to run asynchronously.", logMessages[5]); | ||
| 155 | Assert.Equal("FullFramework4BA", logMessages[6]); | ||
| 156 | Assert.Equal("Shutdown,Restart,0", logMessages[7]); | ||
| 157 | } | ||
| 158 | } | ||
| 81 | } | 159 | } |
| 82 | } | 160 | } |
diff --git a/src/test/WixToolsetTest.ManagedHost/TestEngine.cs b/src/test/WixToolsetTest.ManagedHost/TestEngine.cs index 751ed59c..cda32895 100644 --- a/src/test/WixToolsetTest.ManagedHost/TestEngine.cs +++ b/src/test/WixToolsetTest.ManagedHost/TestEngine.cs | |||
| @@ -13,14 +13,25 @@ namespace WixToolsetTest.ManagedHost | |||
| 13 | private static readonly string TestEngineFile = TestData.Get(@"..\Win32\examples\Example.TestEngine\Example.TestEngine.exe"); | 13 | private static readonly string TestEngineFile = TestData.Get(@"..\Win32\examples\Example.TestEngine\Example.TestEngine.exe"); |
| 14 | public static readonly string BurnStubFile = TestData.Get(@"runtimes\win-x86\native\burn.x86.exe"); | 14 | public static readonly string BurnStubFile = TestData.Get(@"runtimes\win-x86\native\burn.x86.exe"); |
| 15 | 15 | ||
| 16 | public TestEngineResult RunReloadEngine(string bundleFilePath, string tempFolderPath) | ||
| 17 | { | ||
| 18 | return this.RunTestEngine("reload", bundleFilePath, tempFolderPath); | ||
| 19 | } | ||
| 20 | |||
| 16 | public TestEngineResult RunShutdownEngine(string bundleFilePath, string tempFolderPath) | 21 | public TestEngineResult RunShutdownEngine(string bundleFilePath, string tempFolderPath) |
| 17 | { | 22 | { |
| 23 | return this.RunTestEngine("shutdown", bundleFilePath, tempFolderPath); | ||
| 24 | } | ||
| 25 | |||
| 26 | private TestEngineResult RunTestEngine(string engineMode, string bundleFilePath, string tempFolderPath) | ||
| 27 | { | ||
| 18 | var baFolderPath = Path.Combine(tempFolderPath, "ba"); | 28 | var baFolderPath = Path.Combine(tempFolderPath, "ba"); |
| 19 | var extractFolderPath = Path.Combine(tempFolderPath, "extract"); | 29 | var extractFolderPath = Path.Combine(tempFolderPath, "extract"); |
| 20 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFilePath, baFolderPath, extractFolderPath); | 30 | var extractResult = BundleExtractor.ExtractBAContainer(null, bundleFilePath, baFolderPath, extractFolderPath); |
| 21 | extractResult.AssertSuccess(); | 31 | extractResult.AssertSuccess(); |
| 22 | 32 | ||
| 23 | var args = new string[] { | 33 | var args = new string[] { |
| 34 | engineMode, | ||
| 24 | '"' + bundleFilePath + '"', | 35 | '"' + bundleFilePath + '"', |
| 25 | '"' + extractResult.GetBAFilePath(baFolderPath) + '"', | 36 | '"' + extractResult.GetBAFilePath(baFolderPath) + '"', |
| 26 | }; | 37 | }; |
diff --git a/src/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs b/src/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs index d3cafc70..40cff30f 100644 --- a/src/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs +++ b/src/test/examples/FullFramework2MBA/FullFramework2BAFactory.cs | |||
| @@ -6,8 +6,15 @@ namespace Example.FullFramework2MBA | |||
| 6 | 6 | ||
| 7 | public class FullFramework2BAFactory : BaseBootstrapperApplicationFactory | 7 | public class FullFramework2BAFactory : BaseBootstrapperApplicationFactory |
| 8 | { | 8 | { |
| 9 | private static int loadCount = 0; | ||
| 10 | |||
| 9 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) | 11 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) |
| 10 | { | 12 | { |
| 13 | if (loadCount > 0) | ||
| 14 | { | ||
| 15 | engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); | ||
| 16 | } | ||
| 17 | ++loadCount; | ||
| 11 | return new FullFramework2BA(engine); | 18 | return new FullFramework2BA(engine); |
| 12 | } | 19 | } |
| 13 | } | 20 | } |
diff --git a/src/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs b/src/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs index b7c8750d..6a571a54 100644 --- a/src/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs +++ b/src/test/examples/FullFramework4MBA/FullFramework4BAFactory.cs | |||
| @@ -7,8 +7,15 @@ namespace Example.FullFramework4MBA | |||
| 7 | 7 | ||
| 8 | public class FullFramework4BAFactory : BaseBootstrapperApplicationFactory | 8 | public class FullFramework4BAFactory : BaseBootstrapperApplicationFactory |
| 9 | { | 9 | { |
| 10 | private static int loadCount = 0; | ||
| 11 | |||
| 10 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) | 12 | protected override IBootstrapperApplication Create(IEngine engine, IBootstrapperCommand bootstrapperCommand) |
| 11 | { | 13 | { |
| 14 | if (loadCount > 0) | ||
| 15 | { | ||
| 16 | engine.Log(LogLevel.Standard, $"Reloaded {loadCount} time(s)"); | ||
| 17 | } | ||
| 18 | ++loadCount; | ||
| 12 | return new FullFramework4BA(engine); | 19 | return new FullFramework4BA(engine); |
| 13 | } | 20 | } |
| 14 | } | 21 | } |
diff --git a/src/test/examples/TestEngine/Example.TestEngine.vcxproj b/src/test/examples/TestEngine/Example.TestEngine.vcxproj index 554d54f6..56a536b4 100644 --- a/src/test/examples/TestEngine/Example.TestEngine.vcxproj +++ b/src/test/examples/TestEngine/Example.TestEngine.vcxproj | |||
| @@ -46,12 +46,15 @@ | |||
| 46 | <ClCompile Include="precomp.cpp"> | 46 | <ClCompile Include="precomp.cpp"> |
| 47 | <PrecompiledHeader>Create</PrecompiledHeader> | 47 | <PrecompiledHeader>Create</PrecompiledHeader> |
| 48 | </ClCompile> | 48 | </ClCompile> |
| 49 | <ClCompile Include="ReloadEngine.cpp" /> | ||
| 49 | <ClCompile Include="ShutdownEngine.cpp" /> | 50 | <ClCompile Include="ShutdownEngine.cpp" /> |
| 50 | <ClCompile Include="ExampleTestEngine.cpp" /> | 51 | <ClCompile Include="ExampleTestEngine.cpp" /> |
| 51 | <ClCompile Include="TestEngine.cpp" /> | 52 | <ClCompile Include="TestEngine.cpp" /> |
| 52 | </ItemGroup> | 53 | </ItemGroup> |
| 53 | <ItemGroup> | 54 | <ItemGroup> |
| 54 | <ClInclude Include="precomp.h" /> | 55 | <ClInclude Include="precomp.h" /> |
| 56 | <ClInclude Include="ReloadEngine.h" /> | ||
| 57 | <ClInclude Include="ShutdownEngine.h" /> | ||
| 55 | <ClInclude Include="TestEngine.h" /> | 58 | <ClInclude Include="TestEngine.h" /> |
| 56 | </ItemGroup> | 59 | </ItemGroup> |
| 57 | <ItemGroup> | 60 | <ItemGroup> |
diff --git a/src/test/examples/TestEngine/ExampleTestEngine.cpp b/src/test/examples/TestEngine/ExampleTestEngine.cpp index 848b385c..a378c9a3 100644 --- a/src/test/examples/TestEngine/ExampleTestEngine.cpp +++ b/src/test/examples/TestEngine/ExampleTestEngine.cpp | |||
| @@ -5,16 +5,30 @@ | |||
| 5 | int __cdecl wmain(int argc, LPWSTR argv[]) | 5 | int __cdecl wmain(int argc, LPWSTR argv[]) |
| 6 | { | 6 | { |
| 7 | HRESULT hr = E_INVALIDARG; | 7 | HRESULT hr = E_INVALIDARG; |
| 8 | BOOL fShowUsage = FALSE; | ||
| 8 | 9 | ||
| 9 | ConsoleInitialize(); | 10 | ConsoleInitialize(); |
| 10 | 11 | ||
| 11 | if (argc != 3) | 12 | if (argc != 4) |
| 12 | { | 13 | { |
| 13 | ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Usage: Example.TestEngine.exe Bundle.exe BA.dll"); | 14 | fShowUsage = TRUE; |
| 15 | } | ||
| 16 | else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"reload", -1)) | ||
| 17 | { | ||
| 18 | hr = RunReloadEngine(argv[2], argv[3]); | ||
| 19 | } | ||
| 20 | else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"shutdown", -1)) | ||
| 21 | { | ||
| 22 | hr = RunShutdownEngine(argv[2], argv[3]); | ||
| 14 | } | 23 | } |
| 15 | else | 24 | else |
| 16 | { | 25 | { |
| 17 | hr = RunShutdownEngine(argv[1], argv[2]); | 26 | fShowUsage = TRUE; |
| 27 | } | ||
| 28 | |||
| 29 | if (fShowUsage) | ||
| 30 | { | ||
| 31 | ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Usage: {reload|shutdown} Example.TestEngine.exe Bundle.exe BA.dll"); | ||
| 18 | } | 32 | } |
| 19 | 33 | ||
| 20 | ConsoleUninitialize(); | 34 | ConsoleUninitialize(); |
diff --git a/src/test/examples/TestEngine/ReloadEngine.cpp b/src/test/examples/TestEngine/ReloadEngine.cpp new file mode 100644 index 00000000..83541672 --- /dev/null +++ b/src/test/examples/TestEngine/ReloadEngine.cpp | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | // 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. | ||
| 2 | |||
| 3 | #include "precomp.h" | ||
| 4 | |||
| 5 | HRESULT RunReloadEngine( | ||
| 6 | __in LPCWSTR wzBundleFilePath, | ||
| 7 | __in LPCWSTR wzBAFilePath | ||
| 8 | ) | ||
| 9 | { | ||
| 10 | HRESULT hr = S_OK; | ||
| 11 | TestEngine* pTestEngine = NULL; | ||
| 12 | |||
| 13 | pTestEngine = new TestEngine(); | ||
| 14 | ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); | ||
| 15 | |||
| 16 | hr = pTestEngine->Initialize(wzBundleFilePath); | ||
| 17 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); | ||
| 18 | |||
| 19 | hr = pTestEngine->LoadBA(wzBAFilePath); | ||
| 20 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); | ||
| 21 | |||
| 22 | hr = pTestEngine->SendStartupEvent(); | ||
| 23 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); | ||
| 24 | |||
| 25 | hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); | ||
| 26 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); | ||
| 27 | |||
| 28 | pTestEngine->UnloadBA(); | ||
| 29 | |||
| 30 | hr = pTestEngine->LoadBA(wzBAFilePath); | ||
| 31 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); | ||
| 32 | |||
| 33 | hr = pTestEngine->SendStartupEvent(); | ||
| 34 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); | ||
| 35 | |||
| 36 | hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART); | ||
| 37 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); | ||
| 38 | |||
| 39 | pTestEngine->UnloadBA(); | ||
| 40 | |||
| 41 | LExit: | ||
| 42 | return hr; | ||
| 43 | } | ||
diff --git a/src/test/examples/TestEngine/ReloadEngine.h b/src/test/examples/TestEngine/ReloadEngine.h new file mode 100644 index 00000000..0e8456af --- /dev/null +++ b/src/test/examples/TestEngine/ReloadEngine.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #pragma once | ||
| 2 | // 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. | ||
| 3 | |||
| 4 | |||
| 5 | HRESULT RunReloadEngine( | ||
| 6 | __in LPCWSTR wzBundleFilePath, | ||
| 7 | __in LPCWSTR wzBAFilePath | ||
| 8 | ); | ||
diff --git a/src/test/examples/TestEngine/ShutdownEngine.cpp b/src/test/examples/TestEngine/ShutdownEngine.cpp index 912d36ba..0dfbb429 100644 --- a/src/test/examples/TestEngine/ShutdownEngine.cpp +++ b/src/test/examples/TestEngine/ShutdownEngine.cpp | |||
| @@ -13,7 +13,10 @@ HRESULT RunShutdownEngine( | |||
| 13 | pTestEngine = new TestEngine(); | 13 | pTestEngine = new TestEngine(); |
| 14 | ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); | 14 | ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); |
| 15 | 15 | ||
| 16 | hr = pTestEngine->LoadBA(wzBundleFilePath, wzBAFilePath); | 16 | hr = pTestEngine->Initialize(wzBundleFilePath); |
| 17 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); | ||
| 18 | |||
| 19 | hr = pTestEngine->LoadBA(wzBAFilePath); | ||
| 17 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); | 20 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); |
| 18 | 21 | ||
| 19 | hr = pTestEngine->SendStartupEvent(); | 22 | hr = pTestEngine->SendStartupEvent(); |
diff --git a/src/test/examples/TestEngine/ShutdownEngine.h b/src/test/examples/TestEngine/ShutdownEngine.h new file mode 100644 index 00000000..0cfa147a --- /dev/null +++ b/src/test/examples/TestEngine/ShutdownEngine.h | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | #pragma once | ||
| 2 | // 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. | ||
| 3 | |||
| 4 | |||
| 5 | HRESULT RunShutdownEngine( | ||
| 6 | __in LPCWSTR wzBundleFilePath, | ||
| 7 | __in LPCWSTR wzBAFilePath | ||
| 8 | ); | ||
diff --git a/src/test/examples/TestEngine/TestEngine.cpp b/src/test/examples/TestEngine/TestEngine.cpp index 9d8f8638..203df115 100644 --- a/src/test/examples/TestEngine/TestEngine.cpp +++ b/src/test/examples/TestEngine/TestEngine.cpp | |||
| @@ -2,8 +2,22 @@ | |||
| 2 | 2 | ||
| 3 | #include "precomp.h" | 3 | #include "precomp.h" |
| 4 | 4 | ||
| 5 | HRESULT TestEngine::Initialize( | ||
| 6 | __in LPCWSTR wzBundleFilePath | ||
| 7 | ) | ||
| 8 | { | ||
| 9 | HRESULT hr = S_OK; | ||
| 10 | |||
| 11 | LogInitialize(::GetModuleHandleW(NULL)); | ||
| 12 | |||
| 13 | hr = LogOpen(NULL, PathFile(wzBundleFilePath), NULL, L"txt", FALSE, FALSE, NULL); | ||
| 14 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log."); | ||
| 15 | |||
| 16 | LExit: | ||
| 17 | return hr; | ||
| 18 | } | ||
| 19 | |||
| 5 | HRESULT TestEngine::LoadBA( | 20 | HRESULT TestEngine::LoadBA( |
| 6 | __in LPCWSTR wzBundleFilePath, | ||
| 7 | __in LPCWSTR wzBAFilePath | 21 | __in LPCWSTR wzBAFilePath |
| 8 | ) | 22 | ) |
| 9 | { | 23 | { |
| @@ -12,16 +26,11 @@ HRESULT TestEngine::LoadBA( | |||
| 12 | BOOTSTRAPPER_CREATE_ARGS args = { }; | 26 | BOOTSTRAPPER_CREATE_ARGS args = { }; |
| 13 | PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; | 27 | PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; |
| 14 | 28 | ||
| 15 | if (m_pCreateResults) | 29 | if (m_pCreateResults || m_hBAModule) |
| 16 | { | 30 | { |
| 17 | ExitFunction1(hr = E_INVALIDSTATE); | 31 | ExitFunction1(hr = E_INVALIDSTATE); |
| 18 | } | 32 | } |
| 19 | 33 | ||
| 20 | LogInitialize(::GetModuleHandleW(NULL)); | ||
| 21 | |||
| 22 | hr = LogOpen(NULL, PathFile(wzBundleFilePath), NULL, L"txt", FALSE, FALSE, NULL); | ||
| 23 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log."); | ||
| 24 | |||
| 25 | m_pCreateResults = static_cast<BOOTSTRAPPER_CREATE_RESULTS*>(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE)); | 34 | m_pCreateResults = static_cast<BOOTSTRAPPER_CREATE_RESULTS*>(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE)); |
| 26 | 35 | ||
| 27 | command.cbSize = sizeof(BOOTSTRAPPER_COMMAND); | 36 | command.cbSize = sizeof(BOOTSTRAPPER_COMMAND); |
| @@ -51,6 +60,7 @@ HRESULT TestEngine::Log( | |||
| 51 | __in LPCWSTR wzMessage | 60 | __in LPCWSTR wzMessage |
| 52 | ) | 61 | ) |
| 53 | { | 62 | { |
| 63 | LogStringLine(REPORT_STANDARD, "%ls", wzMessage); | ||
| 54 | return ConsoleWriteLine(CONSOLE_COLOR_NORMAL, "%ls", wzMessage); | 64 | return ConsoleWriteLine(CONSOLE_COLOR_NORMAL, "%ls", wzMessage); |
| 55 | } | 65 | } |
| 56 | 66 | ||
| @@ -83,12 +93,20 @@ void TestEngine::UnloadBA() | |||
| 83 | { | 93 | { |
| 84 | PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL; | 94 | PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL; |
| 85 | 95 | ||
| 96 | ReleaseNullMem(m_pCreateResults); | ||
| 97 | |||
| 86 | pfnDestroy = (PFN_BOOTSTRAPPER_APPLICATION_DESTROY)::GetProcAddress(m_hBAModule, "BootstrapperApplicationDestroy"); | 98 | pfnDestroy = (PFN_BOOTSTRAPPER_APPLICATION_DESTROY)::GetProcAddress(m_hBAModule, "BootstrapperApplicationDestroy"); |
| 87 | 99 | ||
| 88 | if (pfnDestroy) | 100 | if (pfnDestroy) |
| 89 | { | 101 | { |
| 90 | pfnDestroy(); | 102 | pfnDestroy(); |
| 91 | } | 103 | } |
| 104 | |||
| 105 | if (m_hBAModule) | ||
| 106 | { | ||
| 107 | ::FreeLibrary(m_hBAModule); | ||
| 108 | m_hBAModule = NULL; | ||
| 109 | } | ||
| 92 | } | 110 | } |
| 93 | 111 | ||
| 94 | HRESULT TestEngine::BAEngineLog( | 112 | HRESULT TestEngine::BAEngineLog( |
diff --git a/src/test/examples/TestEngine/TestEngine.h b/src/test/examples/TestEngine/TestEngine.h index e5db9480..cf1c8aac 100644 --- a/src/test/examples/TestEngine/TestEngine.h +++ b/src/test/examples/TestEngine/TestEngine.h | |||
| @@ -1,13 +1,15 @@ | |||
| 1 | #pragma once | 1 | #pragma once |
| 2 | // 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. | 2 | // 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. |
| 3 | 3 | ||
| 4 | #include "precomp.h" | ||
| 5 | 4 | ||
| 6 | class TestEngine | 5 | class TestEngine |
| 7 | { | 6 | { |
| 8 | public: | 7 | public: |
| 8 | HRESULT Initialize( | ||
| 9 | __in LPCWSTR wzBundleFilePath | ||
| 10 | ); | ||
| 11 | |||
| 9 | HRESULT LoadBA( | 12 | HRESULT LoadBA( |
| 10 | __in LPCWSTR wzBundleFilePath, | ||
| 11 | __in LPCWSTR wzBAFilePath | 13 | __in LPCWSTR wzBAFilePath |
| 12 | ); | 14 | ); |
| 13 | 15 | ||
diff --git a/src/test/examples/TestEngine/precomp.h b/src/test/examples/TestEngine/precomp.h index d0068747..0d2afb06 100644 --- a/src/test/examples/TestEngine/precomp.h +++ b/src/test/examples/TestEngine/precomp.h | |||
| @@ -14,8 +14,5 @@ | |||
| 14 | #include "BootstrapperApplication.h" | 14 | #include "BootstrapperApplication.h" |
| 15 | 15 | ||
| 16 | #include "TestEngine.h" | 16 | #include "TestEngine.h" |
| 17 | 17 | #include "ReloadEngine.h" | |
| 18 | HRESULT RunShutdownEngine( | 18 | #include "ShutdownEngine.h" |
| 19 | __in LPCWSTR wzBundleFilePath, | ||
| 20 | __in LPCWSTR wzBAFilePath | ||
| 21 | ); | ||
