aboutsummaryrefslogtreecommitdiff
path: root/src/test/examples/TestEngine
diff options
context:
space:
mode:
authorSean Hall <r.sean.hall@gmail.com>2020-04-23 12:17:32 +1000
committerSean Hall <r.sean.hall@gmail.com>2020-04-23 12:43:38 +1000
commitbd3ee565f342bc0bb015594f303d13b67285a958 (patch)
tree1994e37e385851a7cfdd69b3f7cf03b3bfaa8a7b /src/test/examples/TestEngine
parent05edba00dc08b74a6d9b32b4e56f4da6ef90c638 (diff)
downloadwix-bd3ee565f342bc0bb015594f303d13b67285a958.tar.gz
wix-bd3ee565f342bc0bb015594f303d13b67285a958.tar.bz2
wix-bd3ee565f342bc0bb015594f303d13b67285a958.zip
Update ManagedHost tests to run off of a bundle.
Diffstat (limited to 'src/test/examples/TestEngine')
-rw-r--r--src/test/examples/TestEngine/ExampleTestEngine.cpp8
-rw-r--r--src/test/examples/TestEngine/ShutdownEngine.cpp8
-rw-r--r--src/test/examples/TestEngine/TestEngine.cpp34
-rw-r--r--src/test/examples/TestEngine/TestEngine.h6
-rw-r--r--src/test/examples/TestEngine/precomp.h2
5 files changed, 48 insertions, 10 deletions
diff --git a/src/test/examples/TestEngine/ExampleTestEngine.cpp b/src/test/examples/TestEngine/ExampleTestEngine.cpp
index 9f051875..848b385c 100644
--- a/src/test/examples/TestEngine/ExampleTestEngine.cpp
+++ b/src/test/examples/TestEngine/ExampleTestEngine.cpp
@@ -8,15 +8,15 @@ int __cdecl wmain(int argc, LPWSTR argv[])
8 8
9 ConsoleInitialize(); 9 ConsoleInitialize();
10 10
11 if (argc != 2) 11 if (argc != 3)
12 { 12 {
13 ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Usage: Example.TestEngine.exe BA.dll"); 13 ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Usage: Example.TestEngine.exe Bundle.exe BA.dll");
14 } 14 }
15 else 15 else
16 { 16 {
17 hr = RunShutdownEngine(argv[1]); 17 hr = RunShutdownEngine(argv[1], argv[2]);
18 } 18 }
19 19
20 ConsoleUninitialize(); 20 ConsoleUninitialize();
21 return HRESULT_CODE(hr); 21 return hr;
22} 22}
diff --git a/src/test/examples/TestEngine/ShutdownEngine.cpp b/src/test/examples/TestEngine/ShutdownEngine.cpp
index 69321d91..912d36ba 100644
--- a/src/test/examples/TestEngine/ShutdownEngine.cpp
+++ b/src/test/examples/TestEngine/ShutdownEngine.cpp
@@ -3,6 +3,7 @@
3#include "precomp.h" 3#include "precomp.h"
4 4
5HRESULT RunShutdownEngine( 5HRESULT RunShutdownEngine(
6 __in LPCWSTR wzBundleFilePath,
6 __in LPCWSTR wzBAFilePath 7 __in LPCWSTR wzBAFilePath
7 ) 8 )
8{ 9{
@@ -12,12 +13,17 @@ HRESULT RunShutdownEngine(
12 pTestEngine = new TestEngine(); 13 pTestEngine = new TestEngine();
13 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.");
14 15
15 hr = pTestEngine->LoadBA(wzBAFilePath); 16 hr = pTestEngine->LoadBA(wzBundleFilePath, wzBAFilePath);
16 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); 17 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA.");
17 18
19 hr = pTestEngine->SendStartupEvent();
20 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup.");
21
18 hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); 22 hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER);
19 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); 23 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown.");
20 24
25 pTestEngine->UnloadBA();
26
21LExit: 27LExit:
22 return hr; 28 return hr;
23} 29}
diff --git a/src/test/examples/TestEngine/TestEngine.cpp b/src/test/examples/TestEngine/TestEngine.cpp
index c0a62eda..9d8f8638 100644
--- a/src/test/examples/TestEngine/TestEngine.cpp
+++ b/src/test/examples/TestEngine/TestEngine.cpp
@@ -3,13 +3,13 @@
3#include "precomp.h" 3#include "precomp.h"
4 4
5HRESULT TestEngine::LoadBA( 5HRESULT TestEngine::LoadBA(
6 __in LPCWSTR wzBundleFilePath,
6 __in LPCWSTR wzBAFilePath 7 __in LPCWSTR wzBAFilePath
7 ) 8 )
8{ 9{
9 HRESULT hr = S_OK; 10 HRESULT hr = S_OK;
10 BOOTSTRAPPER_COMMAND command = { }; 11 BOOTSTRAPPER_COMMAND command = { };
11 BOOTSTRAPPER_CREATE_ARGS args = { }; 12 BOOTSTRAPPER_CREATE_ARGS args = { };
12 HMODULE hBAModule = NULL;
13 PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; 13 PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL;
14 14
15 if (m_pCreateResults) 15 if (m_pCreateResults)
@@ -19,7 +19,7 @@ HRESULT TestEngine::LoadBA(
19 19
20 LogInitialize(::GetModuleHandleW(NULL)); 20 LogInitialize(::GetModuleHandleW(NULL));
21 21
22 hr = LogOpen(NULL, L"ExampleTestEngine", NULL, L"txt", FALSE, FALSE, NULL); 22 hr = LogOpen(NULL, PathFile(wzBundleFilePath), NULL, L"txt", FALSE, FALSE, NULL);
23 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log."); 23 ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log.");
24 24
25 m_pCreateResults = static_cast<BOOTSTRAPPER_CREATE_RESULTS*>(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE)); 25 m_pCreateResults = static_cast<BOOTSTRAPPER_CREATE_RESULTS*>(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE));
@@ -34,10 +34,10 @@ HRESULT TestEngine::LoadBA(
34 34
35 m_pCreateResults->cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); 35 m_pCreateResults->cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS);
36 36
37 hBAModule = ::LoadLibraryExW(wzBAFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); 37 m_hBAModule = ::LoadLibraryExW(wzBAFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
38 ExitOnNullWithLastError(hBAModule, hr, "Failed to load BA dll."); 38 ExitOnNullWithLastError(m_hBAModule, hr, "Failed to load BA dll.");
39 39
40 pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(hBAModule, "BootstrapperApplicationCreate"); 40 pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(m_hBAModule, "BootstrapperApplicationCreate");
41 ConsoleExitOnNull(pfnCreate, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to get address for BootstrapperApplicationCreate."); 41 ConsoleExitOnNull(pfnCreate, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to get address for BootstrapperApplicationCreate.");
42 42
43 hr = pfnCreate(&args, m_pCreateResults); 43 hr = pfnCreate(&args, m_pCreateResults);
@@ -68,6 +68,29 @@ HRESULT TestEngine::SendShutdownEvent(
68 return hr; 68 return hr;
69} 69}
70 70
71HRESULT TestEngine::SendStartupEvent()
72{
73 HRESULT hr = S_OK;
74 BA_ONSTARTUP_ARGS startupArgs = { };
75 BA_ONSTARTUP_RESULTS startupResults = { };
76 startupArgs.cbSize = sizeof(BA_ONSTARTUP_ARGS);
77 startupResults.cbSize = sizeof(BA_ONSTARTUP_RESULTS);
78 hr = m_pCreateResults->pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &startupArgs, &startupResults, m_pCreateResults->pvBootstrapperApplicationProcContext);
79 return hr;
80}
81
82void TestEngine::UnloadBA()
83{
84 PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL;
85
86 pfnDestroy = (PFN_BOOTSTRAPPER_APPLICATION_DESTROY)::GetProcAddress(m_hBAModule, "BootstrapperApplicationDestroy");
87
88 if (pfnDestroy)
89 {
90 pfnDestroy();
91 }
92}
93
71HRESULT TestEngine::BAEngineLog( 94HRESULT TestEngine::BAEngineLog(
72 __in TestEngine* pContext, 95 __in TestEngine* pContext,
73 __in BAENGINE_LOG_ARGS* pArgs, 96 __in BAENGINE_LOG_ARGS* pArgs,
@@ -108,6 +131,7 @@ LExit:
108 131
109TestEngine::TestEngine() 132TestEngine::TestEngine()
110{ 133{
134 m_hBAModule = NULL;
111 m_pCreateResults = NULL; 135 m_pCreateResults = NULL;
112} 136}
113 137
diff --git a/src/test/examples/TestEngine/TestEngine.h b/src/test/examples/TestEngine/TestEngine.h
index 52872100..e5db9480 100644
--- a/src/test/examples/TestEngine/TestEngine.h
+++ b/src/test/examples/TestEngine/TestEngine.h
@@ -7,6 +7,7 @@ class TestEngine
7{ 7{
8public: 8public:
9 HRESULT LoadBA( 9 HRESULT LoadBA(
10 __in LPCWSTR wzBundleFilePath,
10 __in LPCWSTR wzBAFilePath 11 __in LPCWSTR wzBAFilePath
11 ); 12 );
12 13
@@ -18,6 +19,10 @@ public:
18 __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction 19 __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction
19 ); 20 );
20 21
22 HRESULT SendStartupEvent();
23
24 void UnloadBA();
25
21private: 26private:
22 static HRESULT BAEngineLog( 27 static HRESULT BAEngineLog(
23 __in TestEngine* pContext, 28 __in TestEngine* pContext,
@@ -38,5 +43,6 @@ public:
38 ~TestEngine(); 43 ~TestEngine();
39 44
40private: 45private:
46 HMODULE m_hBAModule;
41 BOOTSTRAPPER_CREATE_RESULTS* m_pCreateResults; 47 BOOTSTRAPPER_CREATE_RESULTS* m_pCreateResults;
42}; \ No newline at end of file 48}; \ No newline at end of file
diff --git a/src/test/examples/TestEngine/precomp.h b/src/test/examples/TestEngine/precomp.h
index 6e867e89..d0068747 100644
--- a/src/test/examples/TestEngine/precomp.h
+++ b/src/test/examples/TestEngine/precomp.h
@@ -8,6 +8,7 @@
8#include "conutil.h" 8#include "conutil.h"
9#include "logutil.h" 9#include "logutil.h"
10#include "memutil.h" 10#include "memutil.h"
11#include "pathutil.h"
11 12
12#include "BootstrapperEngine.h" 13#include "BootstrapperEngine.h"
13#include "BootstrapperApplication.h" 14#include "BootstrapperApplication.h"
@@ -15,5 +16,6 @@
15#include "TestEngine.h" 16#include "TestEngine.h"
16 17
17HRESULT RunShutdownEngine( 18HRESULT RunShutdownEngine(
19 __in LPCWSTR wzBundleFilePath,
18 __in LPCWSTR wzBAFilePath 20 __in LPCWSTR wzBAFilePath
19 ); 21 );