wtsapi32/tests: Add some tests for WTSEnumerateProcessesW.

This commit is contained in:
Stefan Leichter 2014-02-19 21:30:39 +01:00 committed by Alexandre Julliard
parent bf681bff2e
commit 26777a4638
5 changed files with 115 additions and 0 deletions

1
configure vendored
View File

@ -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

View File

@ -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)

View File

@ -0,0 +1,5 @@
TESTDLL = wtsapi32.dll
IMPORTS = wtsapi32
C_SRCS = \
wtsapi.c

View File

@ -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();
}

View File

@ -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);