From: Stefan Leichter Subject: [2/2] wtsapi32/tests: add some tests for WTSEnumerateProcessesW Message-Id: <201401072350.38397.Stefan.Leichter@camline.com> Date: Tue, 7 Jan 2014 23:50:38 +0100 For an unknown reason the test from this patch do not build on the testbot (error: make: Nothing to be done for `all'). I have asked for help / support on wine-devel, but ... The tests build fine for the linux plattform (32 and 64 bit). The tests can be build for windows with make crosstest. The test result of the binary build with make crosstest are in https://testbot.winehq.org/JobDetails.pl?Key=27698 --- configure.ac | 1 + dlls/wtsapi32/tests/Makefile.in | 5 ++ dlls/wtsapi32/tests/wtsapi.c | 97 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 dlls/wtsapi32/tests/Makefile.in create mode 100644 dlls/wtsapi32/tests/wtsapi.c diff --git a/configure.ac b/configure.ac index eb780fa..cad4401 100644 --- a/configure.ac +++ b/configure.ac @@ -3216,6 +3216,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..f5a160b --- /dev/null +++ b/dlls/wtsapi32/tests/wtsapi.c @@ -0,0 +1,97 @@ +/* + * 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 +#include +#include +#include +#include +#include + +#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); + ok(!ret, "expected WTSEnumerateProcessesW to fail\n"); + 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); + ok(!ret, "expected WTSEnumerateProcessesW to fail\n"); + 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); + ok(!ret, "expected WTSEnumerateProcessesW to fail\n"); + 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"); + 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"); + 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); + } + ok(found || broken(!ret), "process name %s not found\n", wine_dbgstr_w(pname)); + if (info) WTSFreeMemory(info); +} + +START_TEST (wtsapi) +{ + test_WTSEnumerateProcessesW(); +}