mirror of
https://github.com/reactos/reactos.git
synced 2025-05-06 18:31:26 +00:00
[WS2_32_APITEST]
- Add a test for NtReadFile on a socket svn path=/trunk/; revision=57234
This commit is contained in:
parent
136c0d4296
commit
358a84e09b
1 changed files with 40 additions and 0 deletions
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <wine/test.h>
|
#include <wine/test.h>
|
||||||
|
#include <winternl.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "ws2_32.h"
|
#include "ws2_32.h"
|
||||||
|
|
||||||
|
@ -25,6 +26,10 @@ int Test_recv()
|
||||||
int iResult;
|
int iResult;
|
||||||
SOCKET sck;
|
SOCKET sck;
|
||||||
WSADATA wdata;
|
WSADATA wdata;
|
||||||
|
NTSTATUS status;
|
||||||
|
IO_STATUS_BLOCK readIosb;
|
||||||
|
HANDLE readEvent;
|
||||||
|
LARGE_INTEGER readOffset;
|
||||||
|
|
||||||
/* Start up Winsock */
|
/* Start up Winsock */
|
||||||
iResult = WSAStartup(MAKEWORD(2, 2), &wdata);
|
iResult = WSAStartup(MAKEWORD(2, 2), &wdata);
|
||||||
|
@ -73,6 +78,41 @@ int Test_recv()
|
||||||
SCKTEST(recv(sck, szBuf1, RECV_BUF, 0));
|
SCKTEST(recv(sck, szBuf1, RECV_BUF, 0));
|
||||||
ok(memcmp(szBuf1, szBuf2, RECV_BUF), "equal\n");
|
ok(memcmp(szBuf1, szBuf2, RECV_BUF), "equal\n");
|
||||||
|
|
||||||
|
/* Create an event for NtReadFile */
|
||||||
|
readOffset.QuadPart = 0LL;
|
||||||
|
memcpy(szBuf1, szBuf2, RECV_BUF);
|
||||||
|
status = NtCreateEvent(&readEvent,
|
||||||
|
EVENT_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
NotificationEvent,
|
||||||
|
FALSE);
|
||||||
|
if (status != 0)
|
||||||
|
{
|
||||||
|
ok(0, "Failed to create event\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try reading the socket using the NT file API */
|
||||||
|
status = NtReadFile((HANDLE)sck,
|
||||||
|
readEvent,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&readIosb,
|
||||||
|
szBuf1,
|
||||||
|
RECV_BUF,
|
||||||
|
&readOffset,
|
||||||
|
NULL);
|
||||||
|
if (status == STATUS_PENDING)
|
||||||
|
{
|
||||||
|
WaitForSingleObject(readEvent, INFINITE);
|
||||||
|
status = readIosb.Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
ok(status == 0, "Read failed with status 0x%x\n", (unsigned int)status);
|
||||||
|
ok(memcmp(szBuf2, szBuf1, RECV_BUF), "equal\n");
|
||||||
|
ok(readIosb.Information == RECV_BUF, "Short read\n");
|
||||||
|
|
||||||
|
NtClose(readEvent);
|
||||||
closesocket(sck);
|
closesocket(sck);
|
||||||
WSACleanup();
|
WSACleanup();
|
||||||
return 1;
|
return 1;
|
||||||
|
|
Loading…
Reference in a new issue