diff options
Diffstat (limited to 'src/test/examples/TestEngine')
| -rw-r--r-- | src/test/examples/TestEngine/Example.TestEngine.vcxproj | 70 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/ExampleTestEngine.cpp | 22 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/ShutdownEngine.cpp | 23 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/TestEngine.cpp | 117 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/TestEngine.h | 42 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/packages.config | 7 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/precomp.cpp | 3 | ||||
| -rw-r--r-- | src/test/examples/TestEngine/precomp.h | 19 |
8 files changed, 303 insertions, 0 deletions
diff --git a/src/test/examples/TestEngine/Example.TestEngine.vcxproj b/src/test/examples/TestEngine/Example.TestEngine.vcxproj new file mode 100644 index 00000000..ab79dacc --- /dev/null +++ b/src/test/examples/TestEngine/Example.TestEngine.vcxproj | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 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 | <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| 4 | <Import Project="..\..\..\..\packages\WixToolset.BalUtil.4.0.12\build\WixToolset.BalUtil.props" Condition="Exists('..\..\..\..\packages\WixToolset.BalUtil.4.0.12\build\WixToolset.BalUtil.props')" /> | ||
| 5 | <Import Project="..\..\..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props" Condition="Exists('..\..\..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props')" /> | ||
| 6 | <Import Project="..\..\..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props" Condition="Exists('..\..\..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" /> | ||
| 7 | <ItemGroup Label="ProjectConfigurations"> | ||
| 8 | <ProjectConfiguration Include="Debug|Win32"> | ||
| 9 | <Configuration>Debug</Configuration> | ||
| 10 | <Platform>Win32</Platform> | ||
| 11 | </ProjectConfiguration> | ||
| 12 | <ProjectConfiguration Include="Release|Win32"> | ||
| 13 | <Configuration>Release</Configuration> | ||
| 14 | <Platform>Win32</Platform> | ||
| 15 | </ProjectConfiguration> | ||
| 16 | <ProjectConfiguration Include="Debug|x64"> | ||
| 17 | <Configuration>Debug</Configuration> | ||
| 18 | <Platform>x64</Platform> | ||
| 19 | </ProjectConfiguration> | ||
| 20 | <ProjectConfiguration Include="Release|x64"> | ||
| 21 | <Configuration>Release</Configuration> | ||
| 22 | <Platform>x64</Platform> | ||
| 23 | </ProjectConfiguration> | ||
| 24 | </ItemGroup> | ||
| 25 | <PropertyGroup Label="Globals"> | ||
| 26 | <ProjectGuid>{3D44B67D-A475-49BA-8310-E39F6C117CC9}</ProjectGuid> | ||
| 27 | <ConfigurationType>Application</ConfigurationType> | ||
| 28 | <ProjectSubSystem>Console</ProjectSubSystem> | ||
| 29 | <TargetName>Example.TestEngine</TargetName> | ||
| 30 | <PlatformToolset>v141</PlatformToolset> | ||
| 31 | <CharacterSet>Unicode</CharacterSet> | ||
| 32 | <WindowsTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion> | ||
| 33 | </PropertyGroup> | ||
| 34 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
| 35 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
| 36 | <ImportGroup Label="ExtensionSettings"> | ||
| 37 | </ImportGroup> | ||
| 38 | <ImportGroup Label="Shared"> | ||
| 39 | <Import Project="..\..\..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets" Condition="Exists('..\..\..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" /> | ||
| 40 | </ImportGroup> | ||
| 41 | <PropertyGroup> | ||
| 42 | <ProjectAdditionalLinkLibraries> | ||
| 43 | </ProjectAdditionalLinkLibraries> | ||
| 44 | </PropertyGroup> | ||
| 45 | <ItemGroup> | ||
| 46 | <ClCompile Include="precomp.cpp"> | ||
| 47 | <PrecompiledHeader>Create</PrecompiledHeader> | ||
| 48 | </ClCompile> | ||
| 49 | <ClCompile Include="ShutdownEngine.cpp" /> | ||
| 50 | <ClCompile Include="ExampleTestEngine.cpp" /> | ||
| 51 | <ClCompile Include="TestEngine.cpp" /> | ||
| 52 | </ItemGroup> | ||
| 53 | <ItemGroup> | ||
| 54 | <ClInclude Include="precomp.h" /> | ||
| 55 | <ClInclude Include="TestEngine.h" /> | ||
| 56 | </ItemGroup> | ||
| 57 | <ItemGroup> | ||
| 58 | <None Include="packages.config" /> | ||
| 59 | </ItemGroup> | ||
| 60 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
| 61 | <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> | ||
| 62 | <PropertyGroup> | ||
| 63 | <ErrorText>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}.</ErrorText> | ||
| 64 | </PropertyGroup> | ||
| 65 | <Error Condition="!Exists('..\..\..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\Nerdbank.GitVersioning.2.1.65\build\Nerdbank.GitVersioning.targets'))" /> | ||
| 66 | <Error Condition="!Exists('..\..\..\..\packages\WixToolset.BalUtil.4.0.12\build\WixToolset.BalUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\WixToolset.BalUtil.4.0.12\build\WixToolset.BalUtil.props'))" /> | ||
| 67 | <Error Condition="!Exists('..\..\..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\WixToolset.BootstrapperCore.Native.4.0.10\build\WixToolset.BootstrapperCore.Native.props'))" /> | ||
| 68 | <Error Condition="!Exists('..\..\..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\packages\WixToolset.DUtil.4.0.18\build\WixToolset.DUtil.props'))" /> | ||
| 69 | </Target> | ||
| 70 | </Project> \ No newline at end of file | ||
diff --git a/src/test/examples/TestEngine/ExampleTestEngine.cpp b/src/test/examples/TestEngine/ExampleTestEngine.cpp new file mode 100644 index 00000000..9f051875 --- /dev/null +++ b/src/test/examples/TestEngine/ExampleTestEngine.cpp | |||
| @@ -0,0 +1,22 @@ | |||
| 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 | int __cdecl wmain(int argc, LPWSTR argv[]) | ||
| 6 | { | ||
| 7 | HRESULT hr = E_INVALIDARG; | ||
| 8 | |||
| 9 | ConsoleInitialize(); | ||
| 10 | |||
| 11 | if (argc != 2) | ||
| 12 | { | ||
| 13 | ConsoleWriteError(hr, CONSOLE_COLOR_RED, "Usage: Example.TestEngine.exe BA.dll"); | ||
| 14 | } | ||
| 15 | else | ||
| 16 | { | ||
| 17 | hr = RunShutdownEngine(argv[1]); | ||
| 18 | } | ||
| 19 | |||
| 20 | ConsoleUninitialize(); | ||
| 21 | return HRESULT_CODE(hr); | ||
| 22 | } | ||
diff --git a/src/test/examples/TestEngine/ShutdownEngine.cpp b/src/test/examples/TestEngine/ShutdownEngine.cpp new file mode 100644 index 00000000..69321d91 --- /dev/null +++ b/src/test/examples/TestEngine/ShutdownEngine.cpp | |||
| @@ -0,0 +1,23 @@ | |||
| 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 RunShutdownEngine( | ||
| 6 | __in LPCWSTR wzBAFilePath | ||
| 7 | ) | ||
| 8 | { | ||
| 9 | HRESULT hr = S_OK; | ||
| 10 | TestEngine* pTestEngine = NULL; | ||
| 11 | |||
| 12 | pTestEngine = new TestEngine(); | ||
| 13 | ConsoleExitOnNull(pTestEngine, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to create new test engine."); | ||
| 14 | |||
| 15 | hr = pTestEngine->LoadBA(wzBAFilePath); | ||
| 16 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "Failed to load BA."); | ||
| 17 | |||
| 18 | hr = pTestEngine->SendShutdownEvent(BOOTSTRAPPER_SHUTDOWN_ACTION_RELOAD_BOOTSTRAPPER); | ||
| 19 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure for OnShutdown."); | ||
| 20 | |||
| 21 | LExit: | ||
| 22 | return hr; | ||
| 23 | } | ||
diff --git a/src/test/examples/TestEngine/TestEngine.cpp b/src/test/examples/TestEngine/TestEngine.cpp new file mode 100644 index 00000000..c0a62eda --- /dev/null +++ b/src/test/examples/TestEngine/TestEngine.cpp | |||
| @@ -0,0 +1,117 @@ | |||
| 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 TestEngine::LoadBA( | ||
| 6 | __in LPCWSTR wzBAFilePath | ||
| 7 | ) | ||
| 8 | { | ||
| 9 | HRESULT hr = S_OK; | ||
| 10 | BOOTSTRAPPER_COMMAND command = { }; | ||
| 11 | BOOTSTRAPPER_CREATE_ARGS args = { }; | ||
| 12 | HMODULE hBAModule = NULL; | ||
| 13 | PFN_BOOTSTRAPPER_APPLICATION_CREATE pfnCreate = NULL; | ||
| 14 | |||
| 15 | if (m_pCreateResults) | ||
| 16 | { | ||
| 17 | ExitFunction1(hr = E_INVALIDSTATE); | ||
| 18 | } | ||
| 19 | |||
| 20 | LogInitialize(::GetModuleHandleW(NULL)); | ||
| 21 | |||
| 22 | hr = LogOpen(NULL, L"ExampleTestEngine", 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)); | ||
| 26 | |||
| 27 | command.cbSize = sizeof(BOOTSTRAPPER_COMMAND); | ||
| 28 | |||
| 29 | args.cbSize = sizeof(BOOTSTRAPPER_CREATE_ARGS); | ||
| 30 | args.pCommand = &command; | ||
| 31 | args.pfnBootstrapperEngineProc = TestEngine::EngineProc; | ||
| 32 | args.pvBootstrapperEngineProcContext = this; | ||
| 33 | args.qwEngineAPIVersion = MAKEQWORDVERSION(0, 0, 0, 1); | ||
| 34 | |||
| 35 | m_pCreateResults->cbSize = sizeof(BOOTSTRAPPER_CREATE_RESULTS); | ||
| 36 | |||
| 37 | hBAModule = ::LoadLibraryExW(wzBAFilePath, NULL, LOAD_WITH_ALTERED_SEARCH_PATH); | ||
| 38 | ExitOnNullWithLastError(hBAModule, hr, "Failed to load BA dll."); | ||
| 39 | |||
| 40 | pfnCreate = (PFN_BOOTSTRAPPER_APPLICATION_CREATE)::GetProcAddress(hBAModule, "BootstrapperApplicationCreate"); | ||
| 41 | ConsoleExitOnNull(pfnCreate, hr, E_OUTOFMEMORY, CONSOLE_COLOR_RED, "Failed to get address for BootstrapperApplicationCreate."); | ||
| 42 | |||
| 43 | hr = pfnCreate(&args, m_pCreateResults); | ||
| 44 | ConsoleExitOnFailure(hr, CONSOLE_COLOR_RED, "BA returned failure on BootstrapperApplicationCreate."); | ||
| 45 | |||
| 46 | LExit: | ||
| 47 | return hr; | ||
| 48 | } | ||
| 49 | |||
| 50 | HRESULT TestEngine::Log( | ||
| 51 | __in LPCWSTR wzMessage | ||
| 52 | ) | ||
| 53 | { | ||
| 54 | return ConsoleWriteLine(CONSOLE_COLOR_NORMAL, "%ls", wzMessage); | ||
| 55 | } | ||
| 56 | |||
| 57 | HRESULT TestEngine::SendShutdownEvent( | ||
| 58 | __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction | ||
| 59 | ) | ||
| 60 | { | ||
| 61 | HRESULT hr = S_OK; | ||
| 62 | BA_ONSHUTDOWN_ARGS shutdownArgs = { }; | ||
| 63 | BA_ONSHUTDOWN_RESULTS shutdownResults = { }; | ||
| 64 | shutdownArgs.cbSize = sizeof(BA_ONSHUTDOWN_ARGS); | ||
| 65 | shutdownResults.action = defaultAction; | ||
| 66 | shutdownResults.cbSize = sizeof(BA_ONSHUTDOWN_RESULTS); | ||
| 67 | hr = m_pCreateResults->pfnBootstrapperApplicationProc(BOOTSTRAPPER_APPLICATION_MESSAGE_ONSHUTDOWN, &shutdownArgs, &shutdownResults, m_pCreateResults->pvBootstrapperApplicationProcContext); | ||
| 68 | return hr; | ||
| 69 | } | ||
| 70 | |||
| 71 | HRESULT TestEngine::BAEngineLog( | ||
| 72 | __in TestEngine* pContext, | ||
| 73 | __in BAENGINE_LOG_ARGS* pArgs, | ||
| 74 | __in BAENGINE_LOG_RESULTS* /*pResults*/ | ||
| 75 | ) | ||
| 76 | { | ||
| 77 | return pContext->Log(pArgs->wzMessage); | ||
| 78 | } | ||
| 79 | |||
| 80 | HRESULT WINAPI TestEngine::EngineProc( | ||
| 81 | __in BOOTSTRAPPER_ENGINE_MESSAGE message, | ||
| 82 | __in const LPVOID pvArgs, | ||
| 83 | __inout LPVOID pvResults, | ||
| 84 | __in_opt LPVOID pvContext | ||
| 85 | ) | ||
| 86 | { | ||
| 87 | HRESULT hr = S_OK; | ||
| 88 | TestEngine* pContext = (TestEngine*)pvContext; | ||
| 89 | |||
| 90 | if (!pContext || !pvArgs || !pvResults) | ||
| 91 | { | ||
| 92 | ExitFunction1(hr = E_INVALIDARG); | ||
| 93 | } | ||
| 94 | |||
| 95 | switch (message) | ||
| 96 | { | ||
| 97 | case BOOTSTRAPPER_ENGINE_MESSAGE_LOG: | ||
| 98 | hr = BAEngineLog(pContext, reinterpret_cast<BAENGINE_LOG_ARGS*>(pvArgs), reinterpret_cast<BAENGINE_LOG_RESULTS*>(pvResults)); | ||
| 99 | break; | ||
| 100 | default: | ||
| 101 | hr = E_NOTIMPL; | ||
| 102 | break; | ||
| 103 | } | ||
| 104 | |||
| 105 | LExit: | ||
| 106 | return hr; | ||
| 107 | } | ||
| 108 | |||
| 109 | TestEngine::TestEngine() | ||
| 110 | { | ||
| 111 | m_pCreateResults = NULL; | ||
| 112 | } | ||
| 113 | |||
| 114 | TestEngine::~TestEngine() | ||
| 115 | { | ||
| 116 | ReleaseMem(m_pCreateResults); | ||
| 117 | } \ No newline at end of file | ||
diff --git a/src/test/examples/TestEngine/TestEngine.h b/src/test/examples/TestEngine/TestEngine.h new file mode 100644 index 00000000..52872100 --- /dev/null +++ b/src/test/examples/TestEngine/TestEngine.h | |||
| @@ -0,0 +1,42 @@ | |||
| 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 | #include "precomp.h" | ||
| 5 | |||
| 6 | class TestEngine | ||
| 7 | { | ||
| 8 | public: | ||
| 9 | HRESULT LoadBA( | ||
| 10 | __in LPCWSTR wzBAFilePath | ||
| 11 | ); | ||
| 12 | |||
| 13 | HRESULT Log( | ||
| 14 | __in LPCWSTR wzMessage | ||
| 15 | ); | ||
| 16 | |||
| 17 | HRESULT SendShutdownEvent( | ||
| 18 | __in BOOTSTRAPPER_SHUTDOWN_ACTION defaultAction | ||
| 19 | ); | ||
| 20 | |||
| 21 | private: | ||
| 22 | static HRESULT BAEngineLog( | ||
| 23 | __in TestEngine* pContext, | ||
| 24 | __in BAENGINE_LOG_ARGS* pArgs, | ||
| 25 | __in BAENGINE_LOG_RESULTS* /*pResults*/ | ||
| 26 | ); | ||
| 27 | |||
| 28 | static HRESULT WINAPI EngineProc( | ||
| 29 | __in BOOTSTRAPPER_ENGINE_MESSAGE message, | ||
| 30 | __in const LPVOID pvArgs, | ||
| 31 | __inout LPVOID pvResults, | ||
| 32 | __in_opt LPVOID pvContext | ||
| 33 | ); | ||
| 34 | |||
| 35 | public: | ||
| 36 | TestEngine(); | ||
| 37 | |||
| 38 | ~TestEngine(); | ||
| 39 | |||
| 40 | private: | ||
| 41 | BOOTSTRAPPER_CREATE_RESULTS* m_pCreateResults; | ||
| 42 | }; \ No newline at end of file | ||
diff --git a/src/test/examples/TestEngine/packages.config b/src/test/examples/TestEngine/packages.config new file mode 100644 index 00000000..f209d5fb --- /dev/null +++ b/src/test/examples/TestEngine/packages.config | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | <?xml version="1.0" encoding="utf-8"?> | ||
| 2 | <packages> | ||
| 3 | <package id="Nerdbank.GitVersioning" version="2.1.65" targetFramework="native" developmentDependency="true" /> | ||
| 4 | <package id="WixToolset.BootstrapperCore.Native" version="4.0.10" targetFramework="native" /> | ||
| 5 | <package id="WixToolset.BalUtil" version="4.0.12" targetFramework="native" /> | ||
| 6 | <package id="WixToolset.DUtil" version="4.0.18" targetFramework="native" /> | ||
| 7 | </packages> \ No newline at end of file | ||
diff --git a/src/test/examples/TestEngine/precomp.cpp b/src/test/examples/TestEngine/precomp.cpp new file mode 100644 index 00000000..37664a1c --- /dev/null +++ b/src/test/examples/TestEngine/precomp.cpp | |||
| @@ -0,0 +1,3 @@ | |||
| 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" | ||
diff --git a/src/test/examples/TestEngine/precomp.h b/src/test/examples/TestEngine/precomp.h new file mode 100644 index 00000000..6e867e89 --- /dev/null +++ b/src/test/examples/TestEngine/precomp.h | |||
| @@ -0,0 +1,19 @@ | |||
| 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 | #include <windows.h> | ||
| 5 | #include <MsiQuery.h> | ||
| 6 | |||
| 7 | #include "dutil.h" | ||
| 8 | #include "conutil.h" | ||
| 9 | #include "logutil.h" | ||
| 10 | #include "memutil.h" | ||
| 11 | |||
| 12 | #include "BootstrapperEngine.h" | ||
| 13 | #include "BootstrapperApplication.h" | ||
| 14 | |||
| 15 | #include "TestEngine.h" | ||
| 16 | |||
| 17 | HRESULT RunShutdownEngine( | ||
| 18 | __in LPCWSTR wzBAFilePath | ||
| 19 | ); | ||
