Author: cgutman
Date: Tue Sep 4 03:02:40 2012
New Revision: 57234
URL:
http://svn.reactos.org/svn/reactos?rev=57234&view=rev
Log:
[WS2_32_APITEST]
- Add a test for NtReadFile on a socket
Modified:
trunk/rostests/apitests/ws2_32/recv.c
Modified: trunk/rostests/apitests/ws2_32/recv.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ws2_32/recv.c?re…
==============================================================================
--- trunk/rostests/apitests/ws2_32/recv.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/ws2_32/recv.c [iso-8859-1] Tue Sep 4 03:02:40 2012
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <wine/test.h>
+#include <winternl.h>
#include <windows.h>
#include "ws2_32.h"
@@ -25,6 +26,10 @@
int iResult;
SOCKET sck;
WSADATA wdata;
+ NTSTATUS status;
+ IO_STATUS_BLOCK readIosb;
+ HANDLE readEvent;
+ LARGE_INTEGER readOffset;
/* Start up Winsock */
iResult = WSAStartup(MAKEWORD(2, 2), &wdata);
@@ -73,6 +78,41 @@
SCKTEST(recv(sck, szBuf1, RECV_BUF, 0));
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);
WSACleanup();
return 1;