ntdll/tests: Use GetModuleHandle and skip.

This commit is contained in:
Paul Vriens 2007-04-05 10:29:46 +02:00 committed by Alexandre Julliard
parent dddf348716
commit f5678a4d38
1 changed files with 15 additions and 18 deletions

View File

@ -24,34 +24,33 @@ static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, P
static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG); static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
static NTSTATUS (WINAPI * pNtReadVirtualMemory)(HANDLE, const void*, void*, SIZE_T, SIZE_T*); static NTSTATUS (WINAPI * pNtReadVirtualMemory)(HANDLE, const void*, void*, SIZE_T, SIZE_T*);
static HMODULE hntdll = 0;
/* one_before_last_pid is used to be able to compare values of a still running process /* one_before_last_pid is used to be able to compare values of a still running process
with the output of the test_query_process_times and test_query_process_handlecount tests. with the output of the test_query_process_times and test_query_process_handlecount tests.
*/ */
static DWORD one_before_last_pid = 0; static DWORD one_before_last_pid = 0;
#define NTDLL_GET_PROC(func) \ #define NTDLL_GET_PROC(func) do { \
p ## func = (void*)GetProcAddress(hntdll, #func); \ p ## func = (void*)GetProcAddress(hntdll, #func); \
if(!p ## func) { \ if(!p ## func) { \
trace("GetProcAddress(%s) failed\n", #func); \ trace("GetProcAddress(%s) failed\n", #func); \
FreeLibrary(hntdll); \
return FALSE; \ return FALSE; \
} } \
} while(0)
static BOOL InitFunctionPtrs(void) static BOOL InitFunctionPtrs(void)
{ {
hntdll = LoadLibraryA("ntdll.dll"); /* All needed functions are NT based, so using GetModuleHandle is a good check */
if(!hntdll) { HMODULE hntdll = GetModuleHandle("ntdll");
trace("Could not load ntdll.dll\n"); if (!hntdll)
return FALSE;
}
if (hntdll)
{ {
NTDLL_GET_PROC(NtQuerySystemInformation) skip("Not running on NT\n");
NTDLL_GET_PROC(NtQueryInformationProcess) return FALSE;
NTDLL_GET_PROC(NtReadVirtualMemory)
} }
NTDLL_GET_PROC(NtQuerySystemInformation);
NTDLL_GET_PROC(NtQueryInformationProcess);
NTDLL_GET_PROC(NtReadVirtualMemory);
return TRUE; return TRUE;
} }
@ -277,7 +276,7 @@ static void test_query_process(void)
is_nt = ( spi->dwOffset - (sbi.NumberOfProcessors * sizeof(SYSTEM_THREAD_INFORMATION)) == 136); is_nt = ( spi->dwOffset - (sbi.NumberOfProcessors * sizeof(SYSTEM_THREAD_INFORMATION)) == 136);
if (is_nt) trace("Windows version is NT, we will skip thread tests\n"); if (is_nt) skip("Windows version is NT, we will skip thread tests\n");
/* Check if we have some return values /* Check if we have some return values
* *
@ -629,7 +628,7 @@ static void test_query_process_io(void)
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength); status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessIoCounters, &pii, sizeof(pii), &ReturnLength);
if (status == STATUS_NOT_SUPPORTED) if (status == STATUS_NOT_SUPPORTED)
{ {
trace("ProcessIoCounters information class not supported, skipping tests\n"); skip("ProcessIoCounters information class is not supported\n");
return; return;
} }
@ -892,6 +891,4 @@ START_TEST(info)
/* belongs into it's own file */ /* belongs into it's own file */
trace("Starting test_readvirtualmemory()\n"); trace("Starting test_readvirtualmemory()\n");
test_readvirtualmemory(); test_readvirtualmemory();
FreeLibrary(hntdll);
} }