diff options
Diffstat (limited to 'src/test/examples/TestEngine/TestEngine.cpp')
| -rw-r--r-- | src/test/examples/TestEngine/TestEngine.cpp | 32 |
1 files changed, 25 insertions, 7 deletions
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( |
