Skip to content

Commit

Permalink
[ROSTESTS] Fix some formats
Browse files Browse the repository at this point in the history
[ROSTESTS] Fix sleep

[ROSTESTS] Revert format

[ROSTESTS] Fix minor sort
  • Loading branch information
julenuri committed Jun 18, 2024
1 parent be3a6b5 commit dc276fc
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 32 deletions.
4 changes: 2 additions & 2 deletions modules/rostests/apitests/kernel32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ list(APPEND SOURCE
lstrlen.c
Mailslot.c
MultiByteToWideChar.c
Pipes.c
PrivMoveFileIdentityW.c
QueueUserAPC.c
SetComputerNameExW.c
Expand All @@ -38,8 +39,7 @@ list(APPEND SOURCE
TerminateProcess.c
TunnelCache.c
UEFIFirmware.c
WideCharToMultiByte.c
Pipes.c)
WideCharToMultiByte.c)

list(APPEND PCH_SKIP_SOURCE
testlist.c)
Expand Down
66 changes: 38 additions & 28 deletions modules/rostests/apitests/kernel32/Pipes.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ static DWORD dReadBufferSize;
DWORD
WINAPI
PipeWriter(
LPVOID lpParam)
_In_ PVOID Param)
{
DWORD cbWritten;
HANDLE hPipe;
NTSTATUS lastError;
BOOL returnStatus;
LPSTR lpsInMsg = "Test";
DWORD dwLastError;
BOOL Success;
PCSTR pszInMsg = "Test";

hPipe = CreateFile(LP, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
ok(hPipe != INVALID_HANDLE_VALUE, "CreateFile failed, results might not be accurate\n");
if (hPipe != INVALID_HANDLE_VALUE)
{
Sleep(1000);
returnStatus = WriteFile(hPipe, &lpsInMsg, 4, &cbWritten, (LPOVERLAPPED) NULL);
lastError = GetLastError();
Sleep(0);
Success = WriteFile(hPipe, &pszInMsg, 4, &cbWritten, NULL);
dwLastError = GetLastError();

ok(returnStatus, "Pipe's WriteFile returned FALSE, instead of expected TRUE\n");
if(lastError != 0)
trace("Last Error = 0x%lX\n",lastError);
ok(Success, "Pipe's WriteFile returned FALSE, instead of expected TRUE\n");
if(dwLastError != 0)
trace("Last Error = 0x%lX\n",dwLastError);

ok(cbWritten > 0,"Pipe's Writefile has lpNumberOfBytesWritten <= 0\n");

Expand All @@ -48,39 +48,48 @@ PipeWriter(
DWORD
WINAPI
PipeReader(
LPVOID lpParam)
_In_ PVOID Param)
{
HANDLE hPipe;
DWORD cbRead;
HANDLE hThread;
NTSTATUS lastError;
BOOL returnStatus;
char lpsOutMsg[MAXBUFFERSIZE];

hPipe = CreateNamedPipeA(LP, PIPE_ACCESS_DUPLEX, PIPE_TYPE_MESSAGE|PIPE_READMODE_MESSAGE,1,MAXBUFFERSIZE,MAXBUFFERSIZE,0,NULL);
DWORD dwLastError;
BOOL Success;
CHAR szOutMsg[MAXBUFFERSIZE];

hPipe = CreateNamedPipeA(
LP,
PIPE_ACCESS_DUPLEX,
PIPE_TYPE_MESSAGE|PIPE_READMODE_MESSAGE,
1,
MAXBUFFERSIZE,
MAXBUFFERSIZE,
0,
NULL
);
ok(hPipe != INVALID_HANDLE_VALUE, "CreateNamedPipeA failed\n");
if (hPipe != INVALID_HANDLE_VALUE)
{
hThread = CreateThread(NULL,0, PipeWriter, NULL, 0, NULL);
ok(hThread != INVALID_HANDLE_VALUE, "CreateThread failed\n");
if (hThread != INVALID_HANDLE_VALUE)
{
Sleep(1000);
returnStatus = ReadFile(hPipe, &lpsOutMsg, dReadBufferSize, &cbRead, NULL);
lastError = GetLastError();
Sleep(0);
Success = ReadFile(hPipe, &szOutMsg, dReadBufferSize, &cbRead, NULL);
dwLastError = GetLastError();

if(dReadBufferSize == MINBUFFERSIZE)
ok(!returnStatus, "Pipe's ReadFile returned TRUE, instead of expected FALSE\n");
ok(!Success, "Pipe's ReadFile returned TRUE, instead of expected FALSE\n");
else{
ok(returnStatus, "Pipe's ReadFile returned FALSE, instead of expected TRUE\n");
if(lastError != 0)
trace("Last Error = 0x%lX\n",lastError);
ok(Success, "Pipe's ReadFile returned FALSE, instead of expected TRUE\n");
if(dwLastError != 0)
trace("Last Error = 0x%lX\n",dwLastError);
}

ok(cbRead > 0,"Pipe's Readfile has lpNumberOfBytesRead <= 0\n");

if(dReadBufferSize == MINBUFFERSIZE)
ok(lastError == ERROR_MORE_DATA, "Pipe's ReadFile last error is unexpected\n");
ok(dwLastError == ERROR_MORE_DATA, "Pipe's ReadFile last error is unexpected\n");

WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
Expand All @@ -91,11 +100,12 @@ PipeReader(
}

VOID
StartTestCORE17376(DWORD adReadBufferSize)
StartTestCORE17376(
_In_ DWORD adReadBufferSize)
{
HANDLE hThread;
HANDLE hThread;

trace("adReadBufferSize = %ld - START\n",adReadBufferSize);
trace("adReadBufferSize = %ld - START\n", adReadBufferSize);

dReadBufferSize = adReadBufferSize;

Expand All @@ -107,7 +117,7 @@ StartTestCORE17376(DWORD adReadBufferSize)
CloseHandle(hThread);
}

trace("adReadBufferSize = %ld - COMPLETED\n",adReadBufferSize);
trace("adReadBufferSize = %ld - COMPLETED\n", adReadBufferSize);
}

START_TEST(Pipes)
Expand Down
4 changes: 2 additions & 2 deletions modules/rostests/apitests/kernel32/testlist.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ extern void func_lstrcpynW(void);
extern void func_lstrlen(void);
extern void func_Mailslot(void);
extern void func_MultiByteToWideChar(void);
extern void func_Pipes(void);
extern void func_PrivMoveFileIdentityW(void);
extern void func_QueueUserAPC(void);
extern void func_SetComputerNameExW(void);
Expand All @@ -39,7 +40,6 @@ extern void func_TerminateProcess(void);
extern void func_TunnelCache(void);
extern void func_UEFIFirmware(void);
extern void func_WideCharToMultiByte(void);
extern void func_Pipes(void);

const struct test winetest_testlist[] =
{
Expand Down Expand Up @@ -67,6 +67,7 @@ const struct test winetest_testlist[] =
{ "lstrlen", func_lstrlen },
{ "MailslotRead", func_Mailslot },
{ "MultiByteToWideChar", func_MultiByteToWideChar },
{ "Pipes", func_Pipes },
{ "PrivMoveFileIdentityW", func_PrivMoveFileIdentityW },
{ "QueueUserAPC", func_QueueUserAPC },
{ "SetComputerNameExW", func_SetComputerNameExW },
Expand All @@ -79,6 +80,5 @@ const struct test winetest_testlist[] =
{ "UEFIFirmware", func_UEFIFirmware },
{ "WideCharToMultiByte", func_WideCharToMultiByte },
{ "ActCtxWithXmlNamespaces", func_ActCtxWithXmlNamespaces },
{ "Pipes", func_Pipes },
{ 0, 0 }
};

0 comments on commit dc276fc

Please sign in to comment.