kernel32/tests: Init pointers in common way, add some win_skip() while skipping.

This commit is contained in:
Nikolay Sivov 2009-12-21 20:21:16 +03:00 committed by Alexandre Julliard
parent ea0af93c19
commit 08a778c568
1 changed files with 28 additions and 18 deletions

View File

@ -1323,6 +1323,12 @@ static void test_GetWindowsDirectory(void)
static void test_NeedCurrentDirectoryForExePathA(void) static void test_NeedCurrentDirectoryForExePathA(void)
{ {
if (!pNeedCurrentDirectoryForExePathA)
{
win_skip("NeedCurrentDirectoryForExePathA is not available\n");
return;
}
/* Crashes in Windows */ /* Crashes in Windows */
if (0) if (0)
ok(pNeedCurrentDirectoryForExePathA(NULL), "returned FALSE for NULL\n"); ok(pNeedCurrentDirectoryForExePathA(NULL), "returned FALSE for NULL\n");
@ -1344,6 +1350,12 @@ static void test_NeedCurrentDirectoryForExePathW(void)
const WCHAR fullpath[] = {'c', ':', '\\', 0}; const WCHAR fullpath[] = {'c', ':', '\\', 0};
const WCHAR cmdname[] = {'c', 'm', 'd', '.', 'e', 'x', 'e', 0}; const WCHAR cmdname[] = {'c', 'm', 'd', '.', 'e', 'x', 'e', 0};
if (!pNeedCurrentDirectoryForExePathW)
{
win_skip("NeedCurrentDirectoryForExePathW is not available\n");
return;
}
/* Crashes in Windows */ /* Crashes in Windows */
if (0) if (0)
ok(pNeedCurrentDirectoryForExePathW(NULL), "returned FALSE for NULL\n"); ok(pNeedCurrentDirectoryForExePathW(NULL), "returned FALSE for NULL\n");
@ -1444,19 +1456,23 @@ static void test_drive_letter_case(void)
#undef is_upper_case_letter #undef is_upper_case_letter
} }
static void init_pointers(void)
{
HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
#define MAKEFUNC(f) (p##f = (void*)GetProcAddress(hKernel32, #f))
MAKEFUNC(GetLongPathNameA);
MAKEFUNC(GetLongPathNameW);
MAKEFUNC(NeedCurrentDirectoryForExePathA);
MAKEFUNC(NeedCurrentDirectoryForExePathW);
#undef MAKEFUNC
}
START_TEST(path) START_TEST(path)
{ {
CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive; CHAR origdir[MAX_PATH],curdir[MAX_PATH], curDrive, otherDrive;
pGetLongPathNameA = (void*)GetProcAddress( GetModuleHandleA("kernel32.dll"),
"GetLongPathNameA" ); init_pointers();
pGetLongPathNameW = (void*)GetProcAddress(GetModuleHandleA("kernel32.dll") ,
"GetLongPathNameW" );
pNeedCurrentDirectoryForExePathA =
(void*)GetProcAddress( GetModuleHandleA("kernel32.dll"),
"NeedCurrentDirectoryForExePathA" );
pNeedCurrentDirectoryForExePathW =
(void*)GetProcAddress( GetModuleHandleA("kernel32.dll"),
"NeedCurrentDirectoryForExePathW" );
/* Report only once */ /* Report only once */
if (!pGetLongPathNameA) if (!pGetLongPathNameA)
@ -1474,13 +1490,7 @@ START_TEST(path)
test_GetShortPathNameW(); test_GetShortPathNameW();
test_GetSystemDirectory(); test_GetSystemDirectory();
test_GetWindowsDirectory(); test_GetWindowsDirectory();
if (pNeedCurrentDirectoryForExePathA) test_NeedCurrentDirectoryForExePathA();
{ test_NeedCurrentDirectoryForExePathW();
test_NeedCurrentDirectoryForExePathA();
}
if (pNeedCurrentDirectoryForExePathW)
{
test_NeedCurrentDirectoryForExePathW();
}
test_drive_letter_case(); test_drive_letter_case();
} }