Skip to content

Commit 05a5c3f

Browse files
authored
[kernel32][apitest] Remove checkError, using stack allocation for outMsg, adding e-mails to PROGRAMMER
1 parent da35ee1 commit 05a5c3f

File tree

1 file changed

+14
-33
lines changed
  • modules/rostests/apitests/kernel32

1 file changed

+14
-33
lines changed

modules/rostests/apitests/kernel32/Pipes.c

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
* PROJECT: ReactOS api tests
33
* LICENSE: GNU GPLv2 only as published by the Free Software Foundation
44
* PURPOSE: Test for pipe (CORE-17376)
5-
* PROGRAMMER: Simone Mario Lombardo
5+
* PROGRAMMER: Simone Mario Lombardo <[email protected]>
6+
* Julen Urizar Compains <[email protected]>
67
*/
78

89
#include "precomp.h"
@@ -16,57 +17,38 @@ static const char* g_PipeName = "\\\\.\\pipe\\rostest_pipe";
1617

1718
static DWORD g_dwReadBufferSize;
1819

19-
void CheckError(BOOL Success, DWORD dwLastError, const char* errorMsg)
20-
{
21-
ok(Success, errorMsg);
22-
if (!Success)
23-
{
24-
trace("Error: %s. LastError: 0x%lX\n", errorMsg, dwLastError);
25-
}
26-
}
27-
2820
DWORD WINAPI PipeWriter(_In_ PVOID Param)
2921
{
3022
HANDLE hPipe = (HANDLE)Param;
3123
DWORD cbWritten = 0;
3224
BOOL Success = WriteFile(hPipe, TEST_MESSAGE, TEST_MESSAGE_SIZE, &cbWritten, NULL);
33-
DWORD dwLastError = GetLastError();
3425

35-
CheckError(Success, dwLastError, "Pipe's WriteFile failed");
36-
ok(cbWritten == TEST_MESSAGE_SIZE, "Invalid cbWritten: 0x%lx\n", cbWritten);
26+
ok(Success, "WriteFile() failed, last error = 0x%lx\n", GetLastError());
27+
ok_int(cbWritten, TEST_MESSAGE_SIZE);
3728

3829
return 0;
3930
}
4031

4132
DWORD WINAPI PipeReader(_In_ PVOID Param)
4233
{
43-
HANDLE hPipe = (HANDLE)Param;
44-
CHAR* szOutMsg = (CHAR*)malloc(g_dwReadBufferSize);
45-
if (!szOutMsg)
46-
{
47-
trace("Memory allocation failed for szOutMsg\n");
48-
return -1;
49-
}
34+
CHAR outMsg[MAXBUFFERSIZE];
35+
HANDLE hPipe;
36+
37+
hPipe=(HANDLE)Param;
5038

5139
DWORD cbRead = 0;
52-
BOOL Success = ReadFile(hPipe, szOutMsg, g_dwReadBufferSize, &cbRead, NULL);
53-
DWORD dwLastError = GetLastError();
54-
40+
BOOL Success = ReadFile(hPipe, outMsg, g_dwReadBufferSize, &cbRead, NULL);
41+
5542
if (g_dwReadBufferSize == MINBUFFERSIZE)
56-
{
57-
ok(!Success, "Pipe's ReadFile returned TRUE, instead of expected FALSE\n");
58-
}
43+
ok(!Success, "ReadFile() unexpectedly succeeded\n");
5944
else
60-
{
61-
CheckError(Success, dwLastError, "Pipe's ReadFile failed");
62-
}
45+
ok(Success, "ReadFile() failed, last error = 0x%lx\n", GetLastError());
6346

64-
ok(cbRead > 0, "Invalid cbRead: 0x%lx\n", cbRead);
47+
ok(cbRead != 0, "cbRead == 0\n");
6548

6649
if (g_dwReadBufferSize == MINBUFFERSIZE)
67-
ok(dwLastError == ERROR_MORE_DATA, "Pipe's ReadFile last error is unexpected\n");
50+
ok_hex(GetLastError(), ERROR_MORE_DATA);
6851

69-
free(szOutMsg);
7052
return 0;
7153
}
7254

@@ -132,4 +114,3 @@ START_TEST(Pipes)
132114
StartTestCORE17376(MINBUFFERSIZE);
133115
StartTestCORE17376(MAXBUFFERSIZE);
134116
}
135-

0 commit comments

Comments
 (0)