diff options
author | Rob Mensching <rob@firegiant.com> | 2024-01-10 23:53:18 -0800 |
---|---|---|
committer | Rob Mensching <rob@firegiant.com> | 2024-01-11 18:24:06 -0800 |
commit | 4e7b7c0059d76498d1c24f348dbf6d5799203fe0 (patch) | |
tree | 1b00606cee7fd54ca4e07aa7b550fe63982220b3 /src/libs/dutil/test/DUtilUnitTest | |
parent | 57b7689b2dc5e971911d1c6d48eebb5424ebca89 (diff) | |
download | wix-4e7b7c0059d76498d1c24f348dbf6d5799203fe0.tar.gz wix-4e7b7c0059d76498d1c24f348dbf6d5799203fe0.tar.bz2 wix-4e7b7c0059d76498d1c24f348dbf6d5799203fe0.zip |
Add pipeutil to dutil
Plus a couple small clean-ups in a couple of dutil files.
Diffstat (limited to '')
4 files changed, 95 insertions, 2 deletions
diff --git a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj index edf8ba67..94826b8f 100644 --- a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj +++ b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj | |||
@@ -59,6 +59,7 @@ | |||
59 | <ClCompile Include="MemUtilTest.cpp" /> | 59 | <ClCompile Include="MemUtilTest.cpp" /> |
60 | <ClCompile Include="MonUtilTest.cpp" /> | 60 | <ClCompile Include="MonUtilTest.cpp" /> |
61 | <ClCompile Include="PathUtilTest.cpp" /> | 61 | <ClCompile Include="PathUtilTest.cpp" /> |
62 | <ClCompile Include="PipeUtilTest.cpp" /> | ||
62 | <ClCompile Include="ProcUtilTest.cpp" /> | 63 | <ClCompile Include="ProcUtilTest.cpp" /> |
63 | <ClCompile Include="precomp.cpp"> | 64 | <ClCompile Include="precomp.cpp"> |
64 | <PrecompiledHeader>Create</PrecompiledHeader> | 65 | <PrecompiledHeader>Create</PrecompiledHeader> |
diff --git a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters index d216f2af..e4972c1a 100644 --- a/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters +++ b/src/libs/dutil/test/DUtilUnitTest/DUtilUnitTest.vcxproj.filters | |||
@@ -78,6 +78,9 @@ | |||
78 | <ClCompile Include="LocUtilTests.cpp"> | 78 | <ClCompile Include="LocUtilTests.cpp"> |
79 | <Filter>Source Files</Filter> | 79 | <Filter>Source Files</Filter> |
80 | </ClCompile> | 80 | </ClCompile> |
81 | <ClCompile Include="PipeUtilTest.cpp"> | ||
82 | <Filter>Source Files</Filter> | ||
83 | </ClCompile> | ||
81 | </ItemGroup> | 84 | </ItemGroup> |
82 | <ItemGroup> | 85 | <ItemGroup> |
83 | <ResourceCompile Include="UnitTest.rc"> | 86 | <ResourceCompile Include="UnitTest.rc"> |
@@ -94,10 +97,9 @@ | |||
94 | </ItemGroup> | 97 | </ItemGroup> |
95 | <ItemGroup> | 98 | <ItemGroup> |
96 | <None Include="$(MSBuildThisFileDirectory)xunit.runner.visualstudio.testadapter.dll" /> | 99 | <None Include="$(MSBuildThisFileDirectory)xunit.runner.visualstudio.testadapter.dll" /> |
97 | <None Include="$(MSBuildThisFileDirectory)xunit.runner.reporters.net452.dll" /> | ||
98 | <None Include="$(MSBuildThisFileDirectory)xunit.runner.utility.net452.dll" /> | ||
99 | <None Include="$(MSBuildThisFileDirectory)xunit.abstractions.dll" /> | 100 | <None Include="$(MSBuildThisFileDirectory)xunit.abstractions.dll" /> |
100 | <None Include="TestData\ApupUtilTests\FeedBv2.0.xml" /> | 101 | <None Include="TestData\ApupUtilTests\FeedBv2.0.xml" /> |
101 | <None Include="TestData\LocUtilTests\strings.wxl" /> | 102 | <None Include="TestData\LocUtilTests\strings.wxl" /> |
103 | <None Include="TestData\LocUtilTests\controls.wxl" /> | ||
102 | </ItemGroup> | 104 | </ItemGroup> |
103 | </Project> \ No newline at end of file | 105 | </Project> \ No newline at end of file |
diff --git a/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp new file mode 100644 index 00000000..87a5e8f2 --- /dev/null +++ b/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp | |||
@@ -0,0 +1,89 @@ | |||
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 | using namespace System; | ||
6 | using namespace System::Security::Principal; | ||
7 | using namespace Xunit; | ||
8 | using namespace WixInternal::TestSupport; | ||
9 | using namespace WixInternal::TestSupport::XunitExtensions; | ||
10 | |||
11 | static DWORD STDAPICALLTYPE _TestPipeClientThreadProc( | ||
12 | __in LPVOID lpThreadParameter | ||
13 | ); | ||
14 | |||
15 | namespace DutilTests | ||
16 | { | ||
17 | public ref class PipeUtil | ||
18 | { | ||
19 | public: | ||
20 | [Fact] | ||
21 | void PipeConnectWriteAndRead() | ||
22 | { | ||
23 | HRESULT hr = S_OK; | ||
24 | HANDLE hServerPipe = INVALID_HANDLE_VALUE; | ||
25 | HANDLE hClientThread = NULL; | ||
26 | PIPE_MESSAGE msg = { }; | ||
27 | DWORD dwThread = 42; | ||
28 | DWORD dwTestMessageId = 987654; | ||
29 | |||
30 | try | ||
31 | { | ||
32 | hr = PipeCreate(L"DutilTest", NULL, &hServerPipe); | ||
33 | NativeAssert::Succeeded(hr, "Failed to create server pipe."); | ||
34 | |||
35 | hClientThread = ::CreateThread(NULL, 0, _TestPipeClientThreadProc, &dwTestMessageId, 0, NULL); | ||
36 | if (hClientThread == 0) | ||
37 | { | ||
38 | NativeAssert::Fail("Failed to create client thread."); | ||
39 | return; | ||
40 | } | ||
41 | |||
42 | hr = PipeServerWaitForClientConnect(hServerPipe); | ||
43 | NativeAssert::Succeeded(hr, "Failed to wait for client to connect to pipe."); | ||
44 | |||
45 | hr = PipeReadMessage(hServerPipe, &msg); | ||
46 | NativeAssert::Succeeded(hr, "Failed to read message from client."); | ||
47 | |||
48 | NativeAssert::Equal(dwTestMessageId, msg.dwMessageType); | ||
49 | |||
50 | AppWaitForSingleObject(hClientThread, INFINITE); | ||
51 | |||
52 | ::GetExitCodeThread(hClientThread, &dwThread); | ||
53 | NativeAssert::Equal((DWORD)12, dwThread); | ||
54 | } | ||
55 | finally | ||
56 | { | ||
57 | ReleasePipeMessage(&msg); | ||
58 | ReleaseHandle(hClientThread); | ||
59 | ReleasePipeHandle(hServerPipe); | ||
60 | } | ||
61 | } | ||
62 | }; | ||
63 | } | ||
64 | |||
65 | |||
66 | static DWORD STDAPICALLTYPE _TestPipeClientThreadProc( | ||
67 | __in LPVOID lpThreadParameter | ||
68 | ) | ||
69 | { | ||
70 | HRESULT hr = S_OK; | ||
71 | HANDLE hClientPipe = INVALID_HANDLE_VALUE; | ||
72 | |||
73 | hr = PipeClientConnect(L"DutilTest", &hClientPipe); | ||
74 | if (FAILED(hr)) | ||
75 | { | ||
76 | return hr; | ||
77 | } | ||
78 | |||
79 | ::Sleep(200); | ||
80 | |||
81 | hr = PipeWriteMessage(hClientPipe, *(LPDWORD)lpThreadParameter, NULL, 0); | ||
82 | if (FAILED(hr)) | ||
83 | { | ||
84 | return hr; | ||
85 | } | ||
86 | |||
87 | ReleasePipeHandle(hClientPipe); | ||
88 | return 12; | ||
89 | } | ||
diff --git a/src/libs/dutil/test/DUtilUnitTest/precomp.h b/src/libs/dutil/test/DUtilUnitTest/precomp.h index 92310b41..5a836074 100644 --- a/src/libs/dutil/test/DUtilUnitTest/precomp.h +++ b/src/libs/dutil/test/DUtilUnitTest/precomp.h | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <locutil.h> | 24 | #include <locutil.h> |
25 | #include <memutil.h> | 25 | #include <memutil.h> |
26 | #include <pathutil.h> | 26 | #include <pathutil.h> |
27 | #include <pipeutil.h> | ||
27 | #include <procutil.h> | 28 | #include <procutil.h> |
28 | #include <strutil.h> | 29 | #include <strutil.h> |
29 | #include <monutil.h> | 30 | #include <monutil.h> |