Stefan Leichter : wtsapi32/tests: Add some tests for WTSEnumerateProcessesW.

Alexandre Julliard julliard at winehq.org
Wed Feb 26 15:45:05 CST 2014


Module: wine
Branch: master
Commit: 26777a463800b1f784170b15065432dd824b4ef2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=26777a463800b1f784170b15065432dd824b4ef2

Author: Stefan Leichter <Stefan.Leichter at camLine.com>
Date:   Wed Feb 19 21:30:39 2014 +0100

wtsapi32/tests: Add some tests for WTSEnumerateProcessesW.

---

 configure                       |    1 +
 configure.ac                    |    1 +
 dlls/wtsapi32/tests/Makefile.in |    5 ++
 dlls/wtsapi32/tests/wtsapi.c    |  106 +++++++++++++++++++++++++++++++++++++++
 include/wtsapi32.h              |    2 +
 5 files changed, 115 insertions(+)

diff --git a/configure b/configure
index 39f0213..c6f4b39 100755
--- a/configure
+++ b/configure
@@ -17256,6 +17256,7 @@ wine_fn_config_dll wsnmp32 enable_wsnmp32 implib
 wine_fn_config_test dlls/wsnmp32/tests wsnmp32_test
 wine_fn_config_dll wsock32 enable_wsock32 implib
 wine_fn_config_dll wtsapi32 enable_wtsapi32 implib
+wine_fn_config_test dlls/wtsapi32/tests wtsapi32_test
 wine_fn_config_dll wuapi enable_wuapi clean
 wine_fn_config_dll wuaueng enable_wuaueng
 wine_fn_config_dll xapofx1_1 enable_xapofx1_1
diff --git a/configure.ac b/configure.ac
index 540d5fe..098a5bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3262,6 +3262,7 @@ WINE_CONFIG_DLL(wsnmp32,,[implib])
 WINE_CONFIG_TEST(dlls/wsnmp32/tests)
 WINE_CONFIG_DLL(wsock32,,[implib])
 WINE_CONFIG_DLL(wtsapi32,,[implib])
+WINE_CONFIG_TEST(dlls/wtsapi32/tests)
 WINE_CONFIG_DLL(wuapi,,[clean])
 WINE_CONFIG_DLL(wuaueng)
 WINE_CONFIG_DLL(xapofx1_1)
diff --git a/dlls/wtsapi32/tests/Makefile.in b/dlls/wtsapi32/tests/Makefile.in
new file mode 100644
index 0000000..a398a80
--- /dev/null
+++ b/dlls/wtsapi32/tests/Makefile.in
@@ -0,0 +1,5 @@
+TESTDLL   = wtsapi32.dll
+IMPORTS   = wtsapi32
+
+C_SRCS = \
+	wtsapi.c
diff --git a/dlls/wtsapi32/tests/wtsapi.c b/dlls/wtsapi32/tests/wtsapi.c
new file mode 100644
index 0000000..4c2a9e9
--- /dev/null
+++ b/dlls/wtsapi32/tests/wtsapi.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2014 Stefan Leichter
+ *
+ * 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 <stdlib.h>
+#include <windef.h>
+#include <winbase.h>
+#include <winternl.h>
+#include <wtsapi32.h>
+
+#include "wine/test.h"
+
+static void test_WTSEnumerateProcessesW(void)
+{
+    BOOL found = FALSE, ret;
+    DWORD count, i;
+    PWTS_PROCESS_INFOW info;
+    WCHAR *pname, nameW[MAX_PATH];
+
+    GetModuleFileNameW(NULL, nameW, MAX_PATH);
+    for (pname = nameW + lstrlenW(nameW); pname > nameW; pname--)
+    {
+        if(*pname == '/' || *pname == '\\')
+        {
+            pname++;
+            break;
+        }
+    }
+
+    info = NULL;
+    SetLastError(0xdeadbeef);
+    ret = WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 1, 1, &info, &count);
+    todo_wine
+    ok(!ret, "expected WTSEnumerateProcessesW to fail\n");
+    todo_wine
+    ok(GetLastError()== ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %d\n", GetLastError());
+    if (info) WTSFreeMemory(info);
+
+    info = NULL;
+    SetLastError(0xdeadbeef);
+    ret = WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 0, 0, &info, &count);
+    todo_wine
+    ok(!ret, "expected WTSEnumerateProcessesW to fail\n");
+    todo_wine
+    ok(GetLastError()== ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %d\n", GetLastError());
+    if (info) WTSFreeMemory(info);
+
+    info = NULL;
+    SetLastError(0xdeadbeef);
+    ret = WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 0, 2, &info, &count);
+    todo_wine
+    ok(!ret, "expected WTSEnumerateProcessesW to fail\n");
+    todo_wine
+    ok(GetLastError()== ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %d\n", GetLastError());
+    if (info) WTSFreeMemory(info);
+
+    info = NULL;
+    SetLastError(0xdeadbeef);
+    ret = WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 0, 1, NULL, &count);
+    ok(!ret, "expected WTSEnumerateProcessesW to fail\n");
+    todo_wine
+    ok(GetLastError()== ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %d\n", GetLastError());
+    if (info) WTSFreeMemory(info);
+
+    info = NULL;
+    SetLastError(0xdeadbeef);
+    ret = WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 0, 1, &info, NULL);
+    ok(!ret, "expected WTSEnumerateProcessesW to fail\n");
+    todo_wine
+    ok(GetLastError()== ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER got: %d\n", GetLastError());
+    if (info) WTSFreeMemory(info);
+
+    count = 0;
+    info = NULL;
+    SetLastError(0xdeadbeef);
+    ret = WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 0, 1, &info, &count);
+    ok(ret || broken(!ret), /* fails on Win2K with error ERROR_APP_WRONG_OS */
+        "expected WTSEnumerateProcessesW to succeed; failed with %d\n", GetLastError());
+    for(i = 0; ret && i < count; i++)
+    {
+        found = found || !lstrcmpW(pname, info[i].pProcessName);
+    }
+    todo_wine
+    ok(found || broken(!ret), "process name %s not found\n", wine_dbgstr_w(pname));
+    if (info) WTSFreeMemory(info);
+}
+
+START_TEST (wtsapi)
+{
+    test_WTSEnumerateProcessesW();
+}
diff --git a/include/wtsapi32.h b/include/wtsapi32.h
index f4bab56..d00a699 100644
--- a/include/wtsapi32.h
+++ b/include/wtsapi32.h
@@ -135,6 +135,8 @@ typedef struct _WTS_SERVER_INFOW
 DECL_WINELIB_TYPE_AW(WTS_SERVER_INFO)
 DECL_WINELIB_TYPE_AW(PWTS_SERVER_INFO)
 
+#define WTS_CURRENT_SERVER_HANDLE ((HANDLE)NULL)
+
 void WINAPI WTSCloseServer(HANDLE);
 BOOL WINAPI WTSConnectSessionA(ULONG, ULONG, PSTR, BOOL);
 BOOL WINAPI WTSConnectSessionW(ULONG, ULONG, PWSTR, BOOL);




More information about the wine-cvs mailing list