ws2_32/tests: add initial tests for WSAStartup
Austin English
austinenglish at gmail.com
Tue Apr 28 15:37:38 CDT 2009
Based on a patch by Mark Karpeles.
Added todo_wine's and general cleanup.
See bug 11965.
--
-Austin
-------------- next part --------------
From 62d7a4157c6a47359ea5a732de97fd60f4a2c582 Mon Sep 17 00:00:00 2001
From: Austin English <austinenglish at gmail.com>
Date: Tue, 28 Apr 2009 15:33:50 -0500
Subject: [PATCH] ws2_32/tests: add initial tests for WSAStartup
---
dlls/ws2_32/tests/Makefile.in | 3 +-
dlls/ws2_32/tests/startup.c | 62 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 64 insertions(+), 1 deletions(-)
create mode 100644 dlls/ws2_32/tests/startup.c
diff --git a/dlls/ws2_32/tests/Makefile.in b/dlls/ws2_32/tests/Makefile.in
index d180471..006dffa 100644
--- a/dlls/ws2_32/tests/Makefile.in
+++ b/dlls/ws2_32/tests/Makefile.in
@@ -7,7 +7,8 @@ IMPORTS = ws2_32 kernel32
CTESTS = \
protocol.c \
- sock.c
+ sock.c \
+ startup.c
@MAKE_TEST_RULES@
diff --git a/dlls/ws2_32/tests/startup.c b/dlls/ws2_32/tests/startup.c
new file mode 100644
index 0000000..45f65f5
--- /dev/null
+++ b/dlls/ws2_32/tests/startup.c
@@ -0,0 +1,62 @@
+/*
+ * Unit test suite for wsastartup function
+ *
+ * Copyright 2008 Mark Karpeles
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include <windef.h>
+#include <winbase.h>
+#include <winsock2.h>
+
+#include "wine/test.h"
+
+static void test_WithoutWSAStartup(void)
+{
+ LPVOID ptr;
+
+ WSASetLastError(0xdeadbeef);
+ ptr = gethostbyname("localhost");
+
+ todo_wine ok(ptr == NULL, "gethostbyname() succeeded unexpectedly: %d\n", WSAGetLastError());
+ todo_wine ok(WSAGetLastError() == WSANOTINITIALISED, "gethostbyname() failed with unexpected error: %d\n",
+ WSAGetLastError());
+}
+
+static void test_WithWSAStartup(void)
+{
+ WSADATA data;
+ WORD version = MAKEWORD( 2, 2 );
+ INT res;
+ LPVOID ptr;
+
+ res = WSAStartup( version, &data );
+ ok(res == 0, "WSAStartup() failed unexpectedly: %d\n", res);
+
+ ptr = gethostbyname("localhost");
+ ok(ptr != NULL, "gethostbyname() failed unexpectedly: %d\n", WSAGetLastError());
+
+ WSACleanup();
+}
+
+START_TEST(startup)
+{
+ test_WithoutWSAStartup();
+ test_WithWSAStartup();
+}
+
--
1.5.4.3
More information about the wine-patches
mailing list