Added Wine psapi tests.

As of 2004-10-7 we pass 17 out of 20 tests.
I have disabled the three we fail.

svn path=/trunk/; revision=11581
This commit is contained in:
Steven Edwards 2004-11-07 20:05:22 +00:00
parent 626b0a1f74
commit da9108e6ff
4 changed files with 218 additions and 0 deletions

View file

@ -0,0 +1,5 @@
*.o
*.a
*.exe
*.map
*.sym

View file

@ -0,0 +1,27 @@
# $Id: Makefile,v 1.1 2004/11/07 20:05:22 sedwards Exp $
PATH_TO_TOP = ../../..
TARGET_NORC = yes
TARGET_TYPE = program
TARGET_APPTYPE = console
# require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -D_DISABLE_TIDENTS -D__USE_W32API -D_WIN32_IE=0x0600 \
-D_WIN32_WINNT=0x0501 -D__REACTOS__
TARGET_NAME = psapi_test
TARGET_SDKLIBS = gdi32.a comctl32.a ntdll.a
TARGET_OBJECTS = \
testlist.o \
module.o
include $(PATH_TO_TOP)/rules.mak
include $(TOOLS_PATH)/helper.mk
# EOF

View file

@ -0,0 +1,161 @@
/*
* Copyright (C) 2004 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "wine/test.h"
#include "windef.h"
#include "winbase.h"
#include "winerror.h"
#include "wingdi.h"
#include "psapi.h"
/* Function ptrs */
static HMODULE dll;
static DWORD (WINAPI *pGetModuleBaseNameA)(HANDLE, HANDLE, LPSTR, DWORD);
static void test_module_base_name(void)
{ DWORD retval;
char buffer[MAX_PATH];
HMODULE self, modself;
DWORD exact;
if (!pGetModuleBaseNameA) return;
self = OpenProcess( PROCESS_QUERY_INFORMATION|PROCESS_VM_READ,
FALSE, GetCurrentProcessId());
if (!self) {
ok(0, "OpenProcess() failed\n");
return;
}
modself = GetModuleHandle(NULL);
if (!modself) {
ok(0, "GetModuleHandle() failed\n");
return;
}
exact = pGetModuleBaseNameA( self, modself, buffer, MAX_PATH);
if (!exact) {
ok(0, "GetModuleBaseNameA failed unexpected with error 0x%08lx\n",
GetLastError());
return;
}
SetLastError(ERROR_SUCCESS);
retval = pGetModuleBaseNameA( NULL, NULL, NULL, 0);
ok(!retval, "function result wrong, got %ld expected 0\n", retval);
ok( ERROR_INVALID_PARAMETER == GetLastError() ||
ERROR_INVALID_HANDLE == GetLastError(),
"last error wrong, got %ld expected ERROR_INVALID_PARAMETER/"
"ERROR_INVALID_HANDLE (98)\n", GetLastError());
SetLastError(ERROR_SUCCESS);
retval = pGetModuleBaseNameA( NULL, NULL, NULL, MAX_PATH);
ok(!retval, "function result wrong, got %ld expected 0\n", retval);
ok( ERROR_INVALID_PARAMETER == GetLastError() ||
ERROR_INVALID_HANDLE == GetLastError(),
"last error wrong, got %ld expected ERROR_INVALID_PARAMETER/"
"ERROR_INVALID_HANDLE (98)\n", GetLastError());
SetLastError(ERROR_SUCCESS);
retval = pGetModuleBaseNameA( NULL, NULL, buffer, 0);
ok(!retval, "function result wrong, got %ld expected 0\n", retval);
ok( ERROR_INVALID_PARAMETER == GetLastError() ||
ERROR_INVALID_HANDLE == GetLastError(),
"last error wrong, got %ld expected ERROR_INVALID_PARAMETER/"
"ERROR_INVALID_HANDLE (98)\n", GetLastError());
memset(buffer, 0, sizeof(buffer));
SetLastError(ERROR_SUCCESS);
retval = pGetModuleBaseNameA( NULL, NULL, buffer, 1);
ok(!retval, "function result wrong, got %ld expected 0\n", retval);
ok(ERROR_INVALID_HANDLE == GetLastError(),
"last error wrong, got %ld expected ERROR_INVALID_HANDLE\n",
GetLastError());
memset(buffer, 0, sizeof(buffer));
SetLastError(ERROR_SUCCESS);
retval = pGetModuleBaseNameA( self, NULL, buffer, 1);
ok(!retval || retval == 1,
"function result wrong, got %ld expected 0 (98)/1\n", retval);
#ifndef __REACTOS__
ok((retval && ERROR_SUCCESS == GetLastError()) ||
(!retval && ERROR_MOD_NOT_FOUND == GetLastError()),
"last error wrong, got %ld expected ERROR_SUCCESS/"
"ERROR_MOD_NOT_FOUND (98)\n", GetLastError());
#endif
ok(1 == strlen(buffer) || !strlen(buffer),
"buffer content length wrong, got %d(%s) expected 0 (98,XP)/1\n",
strlen(buffer), buffer);
memset(buffer, 0, sizeof(buffer));
SetLastError(ERROR_SUCCESS);
retval = pGetModuleBaseNameA( self, modself, buffer, 1);
#ifndef __REACTOS__
ok(retval == 1, "function result wrong, got %ld expected 1\n", retval);
#endif
ok(ERROR_SUCCESS == GetLastError(),
"last error wrong, got %ld expected ERROR_SUCCESS\n",
GetLastError());
ok((!strlen(buffer)) || (1 == strlen(buffer)),
"buffer content length wrong, got %d(%s) expected 0 (XP)/1\n",
strlen(buffer), buffer);
SetLastError(ERROR_SUCCESS);
memset(buffer, 0, sizeof(buffer));
retval = pGetModuleBaseNameA( self, NULL, buffer, exact);
ok( !retval || retval == exact,
"function result wrong, got %ld expected 0 (98)/%ld\n", retval, exact);
#ifndef __REACTOS__
ok( (retval && ERROR_SUCCESS == GetLastError()) ||
(!retval && ERROR_MOD_NOT_FOUND == GetLastError()),
"last error wrong, got %ld expected ERROR_SUCCESS/"
"ERROR_MOD_NOT_FOUND (98)\n", GetLastError());
#endif
ok((retval && (exact == strlen(buffer) || exact -1 == strlen(buffer))) ||
(!retval && !strlen(buffer)),
"buffer content length wrong, got %d(%s) expected 0(98)/%ld(XP)/%ld\n",
strlen(buffer), buffer, exact -1, exact);
SetLastError(ERROR_SUCCESS);
memset(buffer, 0, sizeof(buffer));
retval = pGetModuleBaseNameA( self, modself, buffer, exact);
ok(retval == exact || retval == exact -1,
"function result wrong, got %ld expected %ld(98)/%ld\n",
retval, exact -1, exact);
ok(ERROR_SUCCESS == GetLastError(),
"last error wrong, got %ld expected ERROR_SUCCESS\n",
GetLastError());
ok(exact == strlen(buffer) || exact -1 == strlen(buffer),
"buffer content length wrong, got %d(%s) expected %ld(98,XP)/%ld\n",
strlen(buffer), buffer, exact -1, exact);
}
START_TEST(module)
{
dll = LoadLibrary("psapi.dll");
if (!dll) {
trace("LoadLibraryA(psapi.dll) failed: skipping tests with target module\n");
return;
}
pGetModuleBaseNameA = (void*) GetProcAddress(dll, "GetModuleBaseNameA");
test_module_base_name();
FreeLibrary(dll);
}

View file

@ -0,0 +1,25 @@
/* Automatically generated file; DO NOT EDIT!! */
/* stdarg.h is needed for Winelib */
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
extern void func_module(void);
struct test
{
const char *name;
void (*func)(void);
};
static const struct test winetest_testlist[] =
{
{ "module", func_module },
{ 0, 0 }
};
#define WINETEST_WANT_MAIN
#include "wine/test.h"