From ba7bab476501c16e437b0aee71c1be02c3dda176 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Mon, 3 May 2021 15:55:48 -0700 Subject: Move Bal.wixext into ext --- .../examples/TestEngine/Example.TestEngine.vcxproj | 83 +++++++ .../test/examples/TestEngine/ExampleTestEngine.cpp | 53 +++++ .../Bal/test/examples/TestEngine/ReloadEngine.cpp | 55 +++++ .../Bal/test/examples/TestEngine/ReloadEngine.h | 8 + .../test/examples/TestEngine/ShutdownEngine.cpp | 38 +++ .../Bal/test/examples/TestEngine/ShutdownEngine.h | 8 + .../Bal/test/examples/TestEngine/TestEngine.cpp | 256 +++++++++++++++++++++ src/ext/Bal/test/examples/TestEngine/TestEngine.h | 80 +++++++ .../test/examples/TestEngine/WaitForQuitEngine.cpp | 35 +++ .../test/examples/TestEngine/WaitForQuitEngine.h | 8 + .../Bal/test/examples/TestEngine/packages.config | 7 + src/ext/Bal/test/examples/TestEngine/precomp.cpp | 3 + src/ext/Bal/test/examples/TestEngine/precomp.h | 20 ++ 13 files changed, 654 insertions(+) create mode 100644 src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj create mode 100644 src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/ReloadEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/TestEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/TestEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h create mode 100644 src/ext/Bal/test/examples/TestEngine/packages.config create mode 100644 src/ext/Bal/test/examples/TestEngine/precomp.cpp create mode 100644 src/ext/Bal/test/examples/TestEngine/precomp.h (limited to 'src/ext/Bal/test/examples/TestEngine') diff --git a/src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj b/src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj new file mode 100644 index 00000000..99eb917e --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/Example.TestEngine.vcxproj @@ -0,0 +1,83 @@ + + + + + + + + + Debug + ARM64 + + + Release + ARM64 + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + {3D44B67D-A475-49BA-8310-E39F6C117CC9} + Application + Console + Example.TestEngine + v142 + Unicode + 10.0 + + + + + + + + + + + + + + + Create + + + + + + + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp b/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp new file mode 100644 index 00000000..fc1938fe --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ExampleTestEngine.cpp @@ -0,0 +1,53 @@ +// 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. + +#include "precomp.h" + +int __cdecl wmain(int argc, LPWSTR argv[]) +{ + HRESULT hr = S_OK; + BOOL fComInitialized = FALSE; + BOOL fShowUsage = FALSE; + + // initialize COM + hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED); + ExitOnFailure(hr, "Failed to initialize COM."); + fComInitialized = TRUE; + + ConsoleInitialize(); + + if (argc != 4) + { + fShowUsage = TRUE; + } + else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"reload", -1)) + { + hr = RunReloadEngine(argv[2], argv[3]); + } + else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"shutdown", -1)) + { + hr = RunShutdownEngine(argv[2], argv[3]); + } + else if (CSTR_EQUAL == ::CompareString(LOCALE_INVARIANT, NORM_IGNORECASE, argv[1], -1, L"waitforquit", -1)) + { + hr = RunWaitForQuitEngine(argv[2], argv[3]); + } + else + { + fShowUsage = TRUE; + } + + if (fShowUsage) + { + ConsoleWriteError(hr = E_INVALIDARG, CONSOLE_COLOR_RED, "Usage: Example.TestEngine.exe {reload|shutdown|waitforquit} Bundle.exe BA.dll"); + } + + ConsoleUninitialize(); + +LExit: + if (fComInitialized) + { + ::CoUninitialize(); + } + + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp new file mode 100644 index 00000000..46fd9afa --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.cpp @@ -0,0 +1,55 @@ +// 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. + +#include "precomp.h" + +HRESULT RunReloadEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + TestEngine* pTestEngine = NULL; + + pTestEngine = new TestEngine(); + ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); + + hr = pTestEngine->Initialize(wzBundleFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->SimulateQuit(0); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->SimulateQuit(0); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RESTART); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + +LExit: + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/ReloadEngine.h b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.h new file mode 100644 index 00000000..0e8456af --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ReloadEngine.h @@ -0,0 +1,8 @@ +#pragma once +// 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. + + +HRESULT RunReloadEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ); diff --git a/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp new file mode 100644 index 00000000..3b876e4e --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.cpp @@ -0,0 +1,38 @@ +// 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. + +#include "precomp.h" + +HRESULT RunShutdownEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + TestEngine* pTestEngine = NULL; + + pTestEngine = new TestEngine(); + ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); + + hr = pTestEngine->Initialize(wzBundleFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->SimulateQuit(0); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to simulate quit."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + +LExit: + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h new file mode 100644 index 00000000..0cfa147a --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/ShutdownEngine.h @@ -0,0 +1,8 @@ +#pragma once +// 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. + + +HRESULT RunShutdownEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ); diff --git a/src/ext/Bal/test/examples/TestEngine/TestEngine.cpp b/src/ext/Bal/test/examples/TestEngine/TestEngine.cpp new file mode 100644 index 00000000..4c7ec1c3 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/TestEngine.cpp @@ -0,0 +1,256 @@ +// 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. + +#include "precomp.h" + +HRESULT TestEngine::Initialize( + __in LPCWSTR wzBundleFilePath + ) +{ + HRESULT hr = S_OK; + MSG msg = { }; + + LogInitialize(::GetModuleHandleW(NULL)); + + hr = LogOpen(NULL, PathFile(wzBundleFilePath), NULL, L"txt", FALSE, FALSE, NULL); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to open log."); + + ::PeekMessageW(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); + +LExit: + return hr; +} + +HRESULT TestEngine::LoadBA( + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + BOOTSTRAPPER_COMMAND command = { }; + BOOTSTRAPPER_CREATE_ARGS args = { }; + PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; + + if (m_pCreateResults || m_hBAModule) + { + ExitFunction1(hr = E_INVALIDSTATE); + } + + m_pCreateResults = static_cast(MemAlloc(sizeof(BOOTSTRAPPER_CREATE_RESULTS), TRUE)); + + command.cbSize = sizeof(BOOTSTRAPPER_COMMAND); + + hr = PathGetDirectory(wzBAFilePath, &command.wzBootstrapperWorkingFolder); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to allocate wzBootstrapperWorkingFolder"); + + hr = PathConcat(command.wzBootstrapperWorkingFolder, L"BootstrapperApplicationData.xml", &command.wzBootstrapperApplicationDataPath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to allocate wzBootstrapperApplicationDataPath"); + + args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); + args.pCommand = &command; + args.pfnBootstrapperEngineProc = TestEngine::EngineProc; + args.pvBootstrapperEngineProcContext = this; + args.qwEngineAPIVersion = MAKEQWORDVERSION(0, 0, 0, 1); + + m_pCreateResults->cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); + + m_hBAModule = ::LoadLibraryExW(wzBAFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); + ConsoleExitOnNullWithLastError(m_hBAModule, hr, CONSOLE_COLOR_RED, "Failed to load BA dll."); + + pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(m_hBAModule, "BootstrapperApplicationCreate"); + ConsoleExitOnNull(pfnCreate, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to get address for BootstrapperApplicationCreate."); + + hr = pfnCreate(&args, m_pCreateResults); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure on BootstrapperApplicationCreate."); + +LExit: + ReleaseStr(command.wzBootstrapperApplicationDataPath); + ReleaseStr(command.wzBootstrapperWorkingFolder); + + return hr; +} + +HRESULT TestEngine::Log( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in LPCWSTR wzMessage + ) +{ + switch (level) + { + case BOOTSTRAPPER_LOG_LEVEL_NONE: + case BOOTSTRAPPER_LOG_LEVEL_DEBUG: + return S_OK; + default: + LogStringLine(REPORT_STANDARD, "%ls", wzMessage); + return ConsoleWriteLine(CONSOLE_COLOR_NORMAL, "%ls", wzMessage); + } +} + +HRESULT TestEngine::RunApplication() +{ + HRESULT hr = S_OK; + MSG msg = { }; + BOOL fRet = FALSE; + + // Enter the message pump. + while (0 != (fRet = ::GetMessageW(&msg, NULL, 0, 0))) + { + if (-1 == fRet) + { + ConsoleExitOnFailure(hr = E_UNEXPECTED, CONSOLE_COLOR_RED, "Unexpected return value from message pump."); + } + else + { + ProcessBAMessage(&msg); + } + } + +LExit: + return hr; +} + +HRESULT TestEngine::SendShutdownEvent( + __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction + ) +{ + HRESULT hr = S_OK; + BA_ONSHUTDOWN_ARGS shutdownArgs = { }; + BA_ONSHUTDOWN_RESULTS shutdownResults = { }; + shutdownArgs.cbSize = sizeof(BA_ONSHUTDOWN_ARGS); + shutdownResults.action = defaultAction; + shutdownResults.cbSize = sizeof(BA_ONSHUTDOWN_RESULTS); + hr = m_pCreateResults->pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &shutdownArgs, &shutdownResults, m_pCreateResults->pvBootstrapperApplicationProcContext); + return hr; +} + +HRESULT TestEngine::SendStartupEvent() +{ + HRESULT hr = S_OK; + BA_ONSTARTUP_ARGS startupArgs = { }; + BA_ONSTARTUP_RESULTS startupResults = { }; + startupArgs.cbSize = sizeof(BA_ONSTARTUP_ARGS); + startupResults.cbSize = sizeof(BA_ONSTARTUP_RESULTS); + hr = m_pCreateResults->pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSTARTUP, &startupArgs, &startupResults, m_pCreateResults->pvBootstrapperApplicationProcContext); + return hr; +} + +HRESULT TestEngine::SimulateQuit( + __in DWORD dwExitCode + ) +{ + BAENGINE_QUIT_ARGS args = { }; + BAENGINE_QUIT_RESULTS results = { }; + + args.cbSize = sizeof(BAENGINE_QUIT_ARGS); + args.dwExitCode = dwExitCode; + + results.cbSize = sizeof(BAENGINE_QUIT_RESULTS); + + return BAEngineQuit(&args, &results); +} + +void TestEngine::UnloadBA() +{ + PFN_BOOTSTRAPPER_APPLICATION_DESTROY pfnDestroy = NULL; + BOOL fDisableUnloading = m_pCreateResults && m_pCreateResults->fDisableUnloading; + + ReleaseNullMem(m_pCreateResults); + + pfnDestroy = (PFN_BOOTSTRAPPER_APPLICATION_DESTROY)::GetProcAddress(m_hBAModule, "BootstrapperApplicationDestroy"); + + if (pfnDestroy) + { + pfnDestroy(); + } + + if (m_hBAModule) + { + if (!fDisableUnloading) + { + ::FreeLibrary(m_hBAModule); + } + + m_hBAModule = NULL; + } +} + +HRESULT TestEngine::BAEngineLog( + __in BAENGINE_LOG_ARGS* pArgs, + __in BAENGINE_LOG_RESULTS* /*pResults*/ + ) +{ + return Log(pArgs->level, pArgs->wzMessage); +} + +HRESULT TestEngine::BAEngineQuit( + __in BAENGINE_QUIT_ARGS* pArgs, + __in BAENGINE_QUIT_RESULTS* /*pResults*/ + ) +{ + HRESULT hr = S_OK; + + if (!::PostThreadMessageW(m_dwThreadId, WM_TESTENG_QUIT, static_cast(pArgs->dwExitCode), 0)) + { + ConsoleExitWithLastError(hr, CONSOLE_COLOR_RED, "Failed to post shutdown message."); + } + +LExit: + return hr; +} + +HRESULT WINAPI TestEngine::EngineProc( + __in BOOTSTRAPPER_ENGINE_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ) +{ + HRESULT hr = S_OK; + TestEngine* pContext = (TestEngine*)pvContext; + + if (!pContext || !pvArgs || !pvResults) + { + ExitFunction1(hr = E_INVALIDARG); + } + + switch (message) + { + case BOOTSTRAPPER_ENGINE_MESSAGE_LOG: + hr = pContext->BAEngineLog(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + break; + case BOOTSTRAPPER_ENGINE_MESSAGE_QUIT: + hr = pContext->BAEngineQuit(reinterpret_cast(pvArgs), reinterpret_cast(pvResults)); + default: + hr = E_NOTIMPL; + break; + } + +LExit: + return hr; +} + +HRESULT TestEngine::ProcessBAMessage( + __in const MSG* pmsg + ) +{ + HRESULT hr = S_OK; + + switch (pmsg->message) + { + case WM_TESTENG_QUIT: + ::PostQuitMessage(static_cast(pmsg->wParam)); // go bye-bye. + break; + } + + return hr; +} + +TestEngine::TestEngine() +{ + m_hBAModule = NULL; + m_pCreateResults = NULL; + m_dwThreadId = ::GetCurrentThreadId(); +} + +TestEngine::~TestEngine() +{ + ReleaseMem(m_pCreateResults); +} diff --git a/src/ext/Bal/test/examples/TestEngine/TestEngine.h b/src/ext/Bal/test/examples/TestEngine/TestEngine.h new file mode 100644 index 00000000..44e813bd --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/TestEngine.h @@ -0,0 +1,80 @@ +#pragma once +// 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. + + +enum WM_TESTENG +{ + WM_TESTENG_FIRST = WM_APP + 0xFFF, // this enum value must always be first. + + WM_TESTENG_DETECT, + WM_TESTENG_PLAN, + WM_TESTENG_ELEVATE, + WM_TESTENG_APPLY, + WM_TESTENG_LAUNCH_APPROVED_EXE, + WM_TESTENG_QUIT, + + WM_TESTENG_LAST, // this enum value must always be last. +}; + +class TestEngine +{ +public: + HRESULT Initialize( + __in LPCWSTR wzBundleFilePath + ); + + HRESULT LoadBA( + __in LPCWSTR wzBAFilePath + ); + + HRESULT Log( + __in BOOTSTRAPPER_LOG_LEVEL level, + __in LPCWSTR wzMessage + ); + + HRESULT RunApplication(); + + HRESULT SendShutdownEvent( + __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction + ); + + HRESULT SendStartupEvent(); + + HRESULT SimulateQuit( + __in DWORD dwExitCode + ); + + void UnloadBA(); + +private: + HRESULT BAEngineLog( + __in BAENGINE_LOG_ARGS* pArgs, + __in BAENGINE_LOG_RESULTS* pResults + ); + + HRESULT BAEngineQuit( + __in BAENGINE_QUIT_ARGS* pArgs, + __in BAENGINE_QUIT_RESULTS* pResults + ); + + static HRESULT WINAPI EngineProc( + __in BOOTSTRAPPER_ENGINE_MESSAGE message, + __in const LPVOID pvArgs, + __inout LPVOID pvResults, + __in_opt LPVOID pvContext + ); + + HRESULT ProcessBAMessage( + __in const MSG* pmsg + ); + +public: + TestEngine(); + + ~TestEngine(); + +private: + HMODULE m_hBAModule; + BOOTSTRAPPER_CREATE_RESULTS* m_pCreateResults; + DWORD m_dwThreadId; +}; \ No newline at end of file diff --git a/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp new file mode 100644 index 00000000..2f80ba75 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.cpp @@ -0,0 +1,35 @@ +// 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. + +#include "precomp.h" + +HRESULT RunWaitForQuitEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ) +{ + HRESULT hr = S_OK; + TestEngine* pTestEngine = NULL; + + pTestEngine = new TestEngine(); + ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); + + hr = pTestEngine->Initialize(wzBundleFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to initialize engine."); + + hr = pTestEngine->LoadBA(wzBAFilePath); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); + + hr = pTestEngine->SendStartupEvent(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnStartup."); + + hr = pTestEngine->RunApplication(); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to run engine."); + + hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); + ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); + + pTestEngine->UnloadBA(); + +LExit: + return hr; +} diff --git a/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h new file mode 100644 index 00000000..99e3f63c --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/WaitForQuitEngine.h @@ -0,0 +1,8 @@ +#pragma once +// 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. + + +HRESULT RunWaitForQuitEngine( + __in LPCWSTR wzBundleFilePath, + __in LPCWSTR wzBAFilePath + ); diff --git a/src/ext/Bal/test/examples/TestEngine/packages.config b/src/ext/Bal/test/examples/TestEngine/packages.config new file mode 100644 index 00000000..548ddb48 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/packages.config @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/src/ext/Bal/test/examples/TestEngine/precomp.cpp b/src/ext/Bal/test/examples/TestEngine/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/precomp.cpp @@ -0,0 +1,3 @@ +// 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. + +#include "precomp.h" diff --git a/src/ext/Bal/test/examples/TestEngine/precomp.h b/src/ext/Bal/test/examples/TestEngine/precomp.h new file mode 100644 index 00000000..f943f420 --- /dev/null +++ b/src/ext/Bal/test/examples/TestEngine/precomp.h @@ -0,0 +1,20 @@ +#pragma once +// 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. + +#include +#include + +#include "dutil.h" +#include "conutil.h" +#include "logutil.h" +#include "memutil.h" +#include "pathutil.h" +#include "strutil.h" + +#include "BootstrapperEngine.h" +#include "BootstrapperApplication.h" + +#include "TestEngine.h" +#include "ReloadEngine.h" +#include "ShutdownEngine.h" +#include "WaitForQuitEngine.h" -- cgit v1.2.3-55-g6feb