[PATCH] httpapi/tests: Added some basic tests for session and group creation
Nikolay Sivov
nsivov at codeweavers.com
Mon Dec 4 03:09:16 CST 2017
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
configure | 3 +-
configure.ac | 3 +-
dlls/httpapi/tests/Makefile.in | 5 ++
dlls/httpapi/tests/httpapi.c | 193 +++++++++++++++++++++++++++++++++++++++++
include/http.h | 1 +
5 files changed, 203 insertions(+), 2 deletions(-)
create mode 100644 dlls/httpapi/tests/Makefile.in
create mode 100644 dlls/httpapi/tests/httpapi.c
diff --git a/configure b/configure
index 1da4efa683..4704e165b7 100755
--- a/configure
+++ b/configure
@@ -18560,7 +18560,8 @@ wine_fn_config_dll hlink enable_hlink clean,implib
wine_fn_config_test dlls/hlink/tests hlink_test
wine_fn_config_dll hnetcfg enable_hnetcfg clean
wine_fn_config_test dlls/hnetcfg/tests hnetcfg_test
-wine_fn_config_dll httpapi enable_httpapi
+wine_fn_config_dll httpapi enable_httpapi implib
+wine_fn_config_test dlls/httpapi/tests httpapi_test
wine_fn_config_dll iccvid enable_iccvid clean
wine_fn_config_dll icmp enable_icmp
wine_fn_config_dll ieframe enable_ieframe clean,implib
diff --git a/configure.ac b/configure.ac
index 6cba83b16d..69fad417ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3206,7 +3206,8 @@ WINE_CONFIG_DLL(hlink,,[clean,implib])
WINE_CONFIG_TEST(dlls/hlink/tests)
WINE_CONFIG_DLL(hnetcfg,,[clean])
WINE_CONFIG_TEST(dlls/hnetcfg/tests)
-WINE_CONFIG_DLL(httpapi)
+WINE_CONFIG_DLL(httpapi,,[implib])
+WINE_CONFIG_TEST(dlls/httpapi/tests)
WINE_CONFIG_DLL(iccvid,,[clean])
WINE_CONFIG_DLL(icmp)
WINE_CONFIG_DLL(ieframe,,[clean,implib])
diff --git a/dlls/httpapi/tests/Makefile.in b/dlls/httpapi/tests/Makefile.in
new file mode 100644
index 0000000000..1c253a789b
--- /dev/null
+++ b/dlls/httpapi/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL = httpapi.dll
+IMPORTS = httpapi
+
+C_SRCS = \
+ httpapi.c
diff --git a/dlls/httpapi/tests/httpapi.c b/dlls/httpapi/tests/httpapi.c
new file mode 100644
index 0000000000..47df2260c1
--- /dev/null
+++ b/dlls/httpapi/tests/httpapi.c
@@ -0,0 +1,193 @@
+/*
+ * HttpApi tests
+ *
+ * Copyright 2017 Nikolay Sivov for CodeWeavers
+ *
+ * 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 "ntstatus.h"
+#define WIN32_NO_STATUS
+#include "windef.h"
+#include "winbase.h"
+#include "winnt.h"
+#include "winternl.h"
+#include "http.h"
+
+#include "wine/test.h"
+
+static ULONG (WINAPI *pHttpCreateServerSession)(HTTPAPI_VERSION version, HTTP_SERVER_SESSION_ID *session_id,
+ ULONG reserved);
+static ULONG (WINAPI *pHttpCloseServerSession)(HTTP_SERVER_SESSION_ID session_id);
+static ULONG (WINAPI *pHttpCreateUrlGroup)(HTTP_SERVER_SESSION_ID session_id, HTTP_URL_GROUP_ID *group_id,
+ ULONG reserved);
+static ULONG (WINAPI *pHttpCloseUrlGroup)(HTTP_URL_GROUP_ID group_id);
+
+static void init(void)
+{
+ HMODULE mod = GetModuleHandleA("httpapi.dll");
+
+#define X(f) p##f = (void *)GetProcAddress(mod, #f)
+ X(HttpCreateServerSession);
+ X(HttpCloseServerSession);
+ X(HttpCreateUrlGroup);
+ X(HttpCloseUrlGroup);
+#undef X
+}
+
+static void test_HttpCreateHttpHandle(void)
+{
+ HANDLE handle, handle2;
+ ULONG ret;
+ BOOL b;
+
+ ret = HttpCreateHttpHandle(NULL, 0);
+todo_wine
+ ok(ret == ERROR_INVALID_PARAMETER, "Unexpected ret value %u.\n", ret);
+
+ /* Non-zero reserved parameter is accepted on XP/2k3. */
+ handle = NULL;
+ ret = HttpCreateHttpHandle(&handle, 0);
+todo_wine {
+ ok(!ret, "Unexpected ret value %u.\n", ret);
+ ok(handle != NULL, "Unexpected handle value %p.\n", handle);
+}
+ handle2 = NULL;
+ ret = HttpCreateHttpHandle(&handle2, 0);
+todo_wine {
+ ok(!ret, "Unexpected ret value %u.\n", ret);
+ ok(handle2 != NULL && handle != handle2, "Unexpected handle %p.\n", handle2);
+}
+ b = CloseHandle(handle);
+todo_wine
+ ok(b, "Failed to close queue handle.\n");
+}
+
+static void test_HttpCreateServerSession(void)
+{
+ HTTP_SERVER_SESSION_ID session;
+ HTTPAPI_VERSION version;
+ ULONG ret;
+
+ if (!pHttpCreateServerSession || !pHttpCloseServerSession)
+ {
+ skip("HttpCreateServerSession() is not supported.\n");
+ return;
+ }
+
+ version.HttpApiMajorVersion = 1;
+ version.HttpApiMinorVersion = 0;
+ ret = pHttpCreateServerSession(version, NULL, 0);
+ ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
+
+ version.HttpApiMajorVersion = 1;
+ version.HttpApiMinorVersion = 1;
+ ret = pHttpCreateServerSession(version, &session, 0);
+ ok(ret == ERROR_REVISION_MISMATCH, "Unexpected return value %u.\n", ret);
+
+ version.HttpApiMajorVersion = 3;
+ version.HttpApiMinorVersion = 0;
+ ret = pHttpCreateServerSession(version, &session, 0);
+ ok(ret == ERROR_REVISION_MISMATCH, "Unexpected return value %u.\n", ret);
+
+ version.HttpApiMajorVersion = 2;
+ version.HttpApiMinorVersion = 0;
+ ret = pHttpCreateServerSession(version, &session, 0);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+ ret = pHttpCloseServerSession(session);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+
+ version.HttpApiMajorVersion = 1;
+ version.HttpApiMinorVersion = 0;
+ ret = pHttpCreateServerSession(version, &session, 0);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+ ret = pHttpCloseServerSession(session);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+
+ ret = pHttpCloseServerSession(0xdead);
+ ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
+}
+
+static void test_HttpCreateUrlGroup(void)
+{
+ HTTP_SERVER_SESSION_ID session;
+ HTTP_URL_GROUP_ID group_id;
+ HTTPAPI_VERSION version;
+ ULONG ret;
+
+ if (!pHttpCreateUrlGroup)
+ {
+ skip("HttpCreateUrlGroup is not supported.\n");
+ return;
+ }
+
+ group_id = 1;
+ ret = pHttpCreateUrlGroup(0, &group_id, 0);
+ ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
+ ok(group_id == 1, "Unexpected group id %s.\n", wine_dbgstr_longlong(group_id));
+
+ /* Create session, url group, close session. */
+ version.HttpApiMajorVersion = 1;
+ version.HttpApiMinorVersion = 0;
+ ret = pHttpCreateServerSession(version, &session, 0);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+
+ group_id = 0;
+ ret = pHttpCreateUrlGroup(session, &group_id, 0);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+ ok(group_id != 0, "Unexpected group id %s.\n", wine_dbgstr_longlong(group_id));
+
+ ret = pHttpCloseServerSession(session);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+
+ /* Groups are closed together with their session. */
+ ret = pHttpCloseUrlGroup(group_id);
+ ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
+
+ /* Create session, url group, close group. */
+ ret = pHttpCreateServerSession(version, &session, 0);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+
+ group_id = 0;
+ ret = pHttpCreateUrlGroup(session, &group_id, 0);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+ ok(group_id != 0, "Unexpected group id %s.\n", wine_dbgstr_longlong(group_id));
+
+ ret = pHttpCloseUrlGroup(group_id);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+
+ ret = pHttpCloseServerSession(session);
+ ok(!ret, "Unexpected return value %u.\n", ret);
+}
+
+START_TEST(httpapi)
+{
+ HTTPAPI_VERSION version = { 1, 0 };
+ ULONG ret;
+
+ init();
+
+ ret = HttpInitialize(version, HTTP_INITIALIZE_SERVER, NULL);
+ ok(!ret, "Failed to initialize library, ret %u.\n", ret);
+
+ test_HttpCreateHttpHandle();
+ test_HttpCreateServerSession();
+ test_HttpCreateUrlGroup();
+
+ ret = HttpTerminate(HTTP_INITIALIZE_SERVER, NULL);
+ ok(!ret, "Failed to terminate, ret %u.\n", ret);
+}
diff --git a/include/http.h b/include/http.h
index db8a3d4e90..b8ce811e01 100644
--- a/include/http.h
+++ b/include/http.h
@@ -52,6 +52,7 @@ typedef enum _HTTP_SERVICE_CONFIG_ID
typedef ULONGLONG HTTP_OPAQUE_ID, *PHTTP_OPAQUE_ID;
typedef HTTP_OPAQUE_ID HTTP_SERVER_SESSION_ID, *PHTTP_SERVER_SESSION_ID;
+typedef HTTP_OPAQUE_ID HTTP_URL_GROUP_ID, *PHTTP_URL_GROUP_ID;
ULONG WINAPI HttpInitialize(HTTPAPI_VERSION,ULONG,PVOID);
ULONG WINAPI HttpTerminate(ULONG,PVOID);
--
2.15.0
More information about the wine-devel
mailing list