aboutsummaryrefslogtreecommitdiff
path: root/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp')
-rw-r--r--src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp b/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp
index 87a5e8f2..aa6874e4 100644
--- a/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp
+++ b/src/libs/dutil/test/DUtilUnitTest/PipeUtilTest.cpp
@@ -23,6 +23,7 @@ namespace DutilTests
23 HRESULT hr = S_OK; 23 HRESULT hr = S_OK;
24 HANDLE hServerPipe = INVALID_HANDLE_VALUE; 24 HANDLE hServerPipe = INVALID_HANDLE_VALUE;
25 HANDLE hClientThread = NULL; 25 HANDLE hClientThread = NULL;
26 PIPE_RPC_HANDLE hRpc = { INVALID_HANDLE_VALUE };
26 PIPE_MESSAGE msg = { }; 27 PIPE_MESSAGE msg = { };
27 DWORD dwThread = 42; 28 DWORD dwThread = 42;
28 DWORD dwTestMessageId = 987654; 29 DWORD dwTestMessageId = 987654;
@@ -32,6 +33,12 @@ namespace DutilTests
32 hr = PipeCreate(L"DutilTest", NULL, &hServerPipe); 33 hr = PipeCreate(L"DutilTest", NULL, &hServerPipe);
33 NativeAssert::Succeeded(hr, "Failed to create server pipe."); 34 NativeAssert::Succeeded(hr, "Failed to create server pipe.");
34 35
36 PipeRpcInitialize(&hRpc, hServerPipe, FALSE);
37 NativeAssert::Equal((DWORD_PTR)hServerPipe, (DWORD_PTR)hRpc.hPipe);
38
39 BOOL fInitialized = PipeRpcInitialized(&hRpc);
40 NativeAssert::True(fInitialized);
41
35 hClientThread = ::CreateThread(NULL, 0, _TestPipeClientThreadProc, &dwTestMessageId, 0, NULL); 42 hClientThread = ::CreateThread(NULL, 0, _TestPipeClientThreadProc, &dwTestMessageId, 0, NULL);
36 if (hClientThread == 0) 43 if (hClientThread == 0)
37 { 44 {
@@ -39,10 +46,10 @@ namespace DutilTests
39 return; 46 return;
40 } 47 }
41 48
42 hr = PipeServerWaitForClientConnect(hServerPipe); 49 hr = PipeServerWaitForClientConnect(hClientThread, hServerPipe);
43 NativeAssert::Succeeded(hr, "Failed to wait for client to connect to pipe."); 50 NativeAssert::Succeeded(hr, "Failed to wait for client to connect to pipe.");
44 51
45 hr = PipeReadMessage(hServerPipe, &msg); 52 hr = PipeRpcReadMessage(&hRpc, &msg);
46 NativeAssert::Succeeded(hr, "Failed to read message from client."); 53 NativeAssert::Succeeded(hr, "Failed to read message from client.");
47 54
48 NativeAssert::Equal(dwTestMessageId, msg.dwMessageType); 55 NativeAssert::Equal(dwTestMessageId, msg.dwMessageType);
@@ -57,6 +64,8 @@ namespace DutilTests
57 ReleasePipeMessage(&msg); 64 ReleasePipeMessage(&msg);
58 ReleaseHandle(hClientThread); 65 ReleaseHandle(hClientThread);
59 ReleasePipeHandle(hServerPipe); 66 ReleasePipeHandle(hServerPipe);
67
68 PipeRpcUninitiailize(&hRpc);
60 } 69 }
61 } 70 }
62 }; 71 };
@@ -69,6 +78,7 @@ static DWORD STDAPICALLTYPE _TestPipeClientThreadProc(
69{ 78{
70 HRESULT hr = S_OK; 79 HRESULT hr = S_OK;
71 HANDLE hClientPipe = INVALID_HANDLE_VALUE; 80 HANDLE hClientPipe = INVALID_HANDLE_VALUE;
81 PIPE_RPC_HANDLE hRpc = { INVALID_HANDLE_VALUE };
72 82
73 hr = PipeClientConnect(L"DutilTest", &hClientPipe); 83 hr = PipeClientConnect(L"DutilTest", &hClientPipe);
74 if (FAILED(hr)) 84 if (FAILED(hr))
@@ -76,14 +86,17 @@ static DWORD STDAPICALLTYPE _TestPipeClientThreadProc(
76 return hr; 86 return hr;
77 } 87 }
78 88
89 PipeRpcInitialize(&hRpc, hClientPipe, TRUE);
90
79 ::Sleep(200); 91 ::Sleep(200);
80 92
81 hr = PipeWriteMessage(hClientPipe, *(LPDWORD)lpThreadParameter, NULL, 0); 93 hr = PipeRpcWriteMessage(&hRpc, *(LPDWORD)lpThreadParameter, NULL, 0);
82 if (FAILED(hr)) 94 if (FAILED(hr))
83 { 95 {
84 return hr; 96 return hr;
85 } 97 }
86 98
87 ReleasePipeHandle(hClientPipe); 99 PipeRpcUninitiailize(&hRpc);
100
88 return 12; 101 return 12;
89} 102}