Skip to content

Commit

Permalink
wtsapi32/tests: Add some tests for WTSEnumerateProcessesW.
Browse files Browse the repository at this point in the history
  • Loading branch information
camlineStefan authored and julliard committed Feb 26, 2014
1 parent bf681bf commit 26777a4
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 0 deletions.
1 change: 1 addition & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions dlls/wtsapi32/tests/Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TESTDLL = wtsapi32.dll
IMPORTS = wtsapi32

C_SRCS = \
wtsapi.c
106 changes: 106 additions & 0 deletions dlls/wtsapi32/tests/wtsapi.c
Original file line number Diff line number Diff line change
@@ -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();
}
2 changes: 2 additions & 0 deletions include/wtsapi32.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 26777a4

Please sign in to comment.