aboutsummaryrefslogtreecommitdiff
path: root/src/test/examples/TestEngine
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-04-23 12:26:07 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-04-23 12:43:38 +1000
commitab495395492055c8c016e54ab0b1f7af2e9f164c (patch)
treef7f86e82cb463303c5bf2e501065ea09a9b62af0 /src/test/examples/TestEngine
parentbd3ee565f342bc0bb015594f303d13b67285a958 (diff)
downloadwix-ab495395492055c8c016e54ab0b1f7af2e9f164c.tar.gz
wix-ab495395492055c8c016e54ab0b1f7af2e9f164c.tar.bz2
wix-ab495395492055c8c016e54ab0b1f7af2e9f164c.zip
Add reload engine and test.
Diffstat (limited to '')
-rw-r--r--src/test/examples/TestEngine/Example.TestEngine.vcxproj3
-rw-r--r--src/test/examples/TestEngine/ExampleTestEngine.cpp20
-rw-r--r--src/test/examples/TestEngine/ReloadEngine.cpp43
-rw-r--r--src/test/examples/TestEngine/ReloadEngine.h8
-rw-r--r--src/test/examples/TestEngine/ShutdownEngine.cpp5
-rw-r--r--src/test/examples/TestEngine/ShutdownEngine.h8
-rw-r--r--src/test/examples/TestEngine/TestEngine.cpp32
-rw-r--r--src/test/examples/TestEngine/TestEngine.h6
-rw-r--r--src/test/examples/TestEngine/precomp.h7
9 files changed, 114 insertions, 18 deletions
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 @@
5int __cdecl wmain(int argc, LPWSTR argv[]) 5int __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
5HRESULT 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
41LExit:
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
5HRESULT 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
5HRESULT 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
5HRESULT 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
16LExit:
17 return hr;
18}
19
5HRESULT TestEngine::LoadBA( 20HRESULT 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
94HRESULT TestEngine::BAEngineLog( 112HRESULT 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
6class TestEngine 5class TestEngine
7{ 6{
8public: 7public:
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"
18HRESULT RunShutdownEngine( 18#include "ShutdownEngine.h"
19 __in LPCWSTR wzBundleFilePath,
20 __in LPCWSTR wzBAFilePath
21 );