Author: akhaldi
Date: Wed Oct 5 09:33:03 2016
New Revision: 72908
URL:
http://svn.reactos.org/svn/reactos?rev=72908&view=rev
Log:
[WS2_32_APITEST] Add tests for getnameinfo. By Peter Hater. CORE-8549
Added:
trunk/rostests/apitests/ws2_32/getnameinfo.c (with props)
Modified:
trunk/rostests/apitests/ws2_32/CMakeLists.txt
trunk/rostests/apitests/ws2_32/testlist.c
Modified: trunk/rostests/apitests/ws2_32/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ws2_32/CMakeList…
==============================================================================
--- trunk/rostests/apitests/ws2_32/CMakeLists.txt [iso-8859-1] (original)
+++ trunk/rostests/apitests/ws2_32/CMakeLists.txt [iso-8859-1] Wed Oct 5 09:33:03 2016
@@ -1,6 +1,7 @@
list(APPEND SOURCE
getaddrinfo.c
+ getnameinfo.c
getservbyname.c
getservbyport.c
helpers.c
Added: trunk/rostests/apitests/ws2_32/getnameinfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ws2_32/getnamein…
==============================================================================
--- trunk/rostests/apitests/ws2_32/getnameinfo.c (added)
+++ trunk/rostests/apitests/ws2_32/getnameinfo.c [iso-8859-1] Wed Oct 5 09:33:03 2016
@@ -0,0 +1,99 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: GPLv2+ - See COPYING in the top level directory
+ * PURPOSE: Test for getaddrinfo
+ * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+#include <stdarg.h>
+#include <windef.h>
+#include <winbase.h>
+#include <ws2tcpip.h>
+#include <ndk/umtypes.h>
+
+START_TEST(getnameinfo)
+{
+ WSADATA WsaData;
+ int Error, MinSize;
+ PCHAR NodeBuffer, ServiceBuffer;
+ CHAR TestBuf[NI_MAXHOST];
+ WCHAR TestBufW[NI_MAXHOST];
+ SOCKADDR_IN LocalAddr;
+
+ /* not yet initialized */
+ StartSeh()
+ Error = getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+ ok_dec(Error, WSANOTINITIALISED);
+ EndSeh(STATUS_SUCCESS);
+ StartSeh()
+ NodeBuffer = InvalidPointer;
+ ServiceBuffer = InvalidPointer;
+ Error = getnameinfo(NULL, 0, NodeBuffer, 0, ServiceBuffer, 0, 0);
+ ok_dec(Error, WSANOTINITIALISED);
+ ok_ptr(NodeBuffer, InvalidPointer);
+ ok_ptr(ServiceBuffer, InvalidPointer);
+ EndSeh(STATUS_SUCCESS);
+
+ LocalAddr.sin_family = AF_INET;
+ LocalAddr.sin_port = 80;
+ LocalAddr.sin_addr.S_un.S_addr = ntohl(INADDR_LOOPBACK);
+ Error = getnameinfo((PSOCKADDR)&LocalAddr, sizeof(LocalAddr), TestBuf,
sizeof(TestBuf), NULL, 0, 0);
+ ok_dec(Error, WSANOTINITIALISED);
+
+ Error = WSAStartup(MAKEWORD(2, 2), &WsaData);
+ ok_dec(Error, 0);
+
+ StartSeh()
+ Error = getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
+ ok_dec(Error, WSAEFAULT);
+ EndSeh(STATUS_SUCCESS);
+ StartSeh()
+ NodeBuffer = InvalidPointer;
+ ServiceBuffer = InvalidPointer;
+ Error = getnameinfo(NULL, 0, NodeBuffer, 0, ServiceBuffer, 0, 0);
+ ok_dec(Error, WSAEFAULT);
+ ok_ptr(NodeBuffer, InvalidPointer);
+ ok_ptr(ServiceBuffer, InvalidPointer);
+ EndSeh(STATUS_SUCCESS);
+
+ /* initialize LocalAddress for tests */
+ Error = getnameinfo((PSOCKADDR)&LocalAddr, sizeof(LocalAddr), TestBuf,
sizeof(TestBuf), NULL, 0, 0);
+ ok_dec(Error, 0);
+ ok_dec(WSAGetLastError(), 0);
+
+ /* test minimal size */
+ MinSize = sizeof(LocalAddr);
+ Error = getnameinfo((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf),
NULL, 0, 0);
+ ok_dec(Error, 0);
+ ok_dec(WSAGetLastError(), 0);
+
+ Error = GetNameInfoA((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf),
NULL, 0, 0);
+ ok_dec(Error, 0);
+ ok_dec(WSAGetLastError(), 0);
+
+ Error = GetNameInfoW((PSOCKADDR)&LocalAddr, MinSize, TestBufW, sizeof(TestBufW),
NULL, 0, 0);
+ ok_dec(Error, 0);
+ ok_dec(WSAGetLastError(), 0);
+
+ MinSize--;
+ Error = getnameinfo((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf),
NULL, 0, 0);
+ ok_dec(Error, WSAEFAULT);
+
+ Error = GetNameInfoA((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf),
NULL, 0, 0);
+ ok_dec(Error, WSAEFAULT);
+
+ Error = GetNameInfoW((PSOCKADDR)&LocalAddr, MinSize, TestBufW, sizeof(TestBufW),
NULL, 0, 0);
+ ok_dec(Error, WSAEFAULT);
+
+ Error = WSACleanup();
+ ok_dec(Error, 0);
+
+ /* not initialized anymore */
+ Error = getnameinfo((PSOCKADDR)&LocalAddr, sizeof(LocalAddr), NodeBuffer, 0,
ServiceBuffer, 0, 0);
+ ok_dec(Error, WSANOTINITIALISED);
+}
Propchange: trunk/rostests/apitests/ws2_32/getnameinfo.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/ws2_32/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/ws2_32/testlist.…
==============================================================================
--- trunk/rostests/apitests/ws2_32/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/ws2_32/testlist.c [iso-8859-1] Wed Oct 5 09:33:03 2016
@@ -4,6 +4,7 @@
#include <apitest.h>
extern void func_getaddrinfo(void);
+extern void func_getnameinfo(void);
extern void func_getservbyname(void);
extern void func_getservbyport(void);
extern void func_ioctlsocket(void);
@@ -15,6 +16,7 @@
const struct test winetest_testlist[] =
{
{ "getaddrinfo", func_getaddrinfo },
+ { "getnameinfo", func_getnameinfo },
{ "getservbyname", func_getservbyname },
{ "getservbyport", func_getservbyport },
{ "ioctlsocket", func_ioctlsocket },