ntdll/tests: Some tests for NtQuerySystemInformationEx().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f157192513
commit
c9c138f53f
|
@ -87,7 +87,7 @@ static BOOL (WINAPI *pProcess32First)(HANDLE, PROCESSENTRY32*);
|
|||
static BOOL (WINAPI *pProcess32Next)(HANDLE, PROCESSENTRY32*);
|
||||
static BOOL (WINAPI *pThread32First)(HANDLE, THREADENTRY32*);
|
||||
static BOOL (WINAPI *pThread32Next)(HANDLE, THREADENTRY32*);
|
||||
|
||||
static BOOL (WINAPI *pGetLogicalProcessorInformationEx)(LOGICAL_PROCESSOR_RELATIONSHIP,SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*,DWORD*);
|
||||
|
||||
/* ############################### */
|
||||
static char base[MAX_PATH];
|
||||
|
@ -251,6 +251,7 @@ static BOOL init(void)
|
|||
pProcess32Next = (void *)GetProcAddress(hkernel32, "Process32Next");
|
||||
pThread32First = (void *)GetProcAddress(hkernel32, "Thread32First");
|
||||
pThread32Next = (void *)GetProcAddress(hkernel32, "Thread32Next");
|
||||
pGetLogicalProcessorInformationEx = (void *)GetProcAddress(hkernel32, "GetLogicalProcessorInformationEx");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -3107,6 +3108,37 @@ todo_wine
|
|||
CloseHandle(hproc);
|
||||
}
|
||||
|
||||
static void test_GetLogicalProcessorInformationEx(void)
|
||||
{
|
||||
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *info;
|
||||
DWORD len;
|
||||
BOOL ret;
|
||||
|
||||
if (!pGetLogicalProcessorInformationEx)
|
||||
{
|
||||
win_skip("GetLogicalProcessorInformationEx() is not supported\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, NULL);
|
||||
ok(!ret, "got %d, error %d\n", ret, GetLastError());
|
||||
|
||||
len = 0;
|
||||
ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, &len);
|
||||
todo_wine {
|
||||
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %d\n", ret, GetLastError());
|
||||
ok(len > 0, "got %u\n", len);
|
||||
}
|
||||
|
||||
if (len) {
|
||||
info = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
||||
ret = pGetLogicalProcessorInformationEx(RelationAll, info, &len);
|
||||
ok(ret, "got %d, error %d\n", ret, GetLastError());
|
||||
ok(info->Size > 0, "got %u\n", info->Size);
|
||||
HeapFree(GetProcessHeap(), 0, info);
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST(process)
|
||||
{
|
||||
HANDLE job;
|
||||
|
@ -3153,6 +3185,7 @@ START_TEST(process)
|
|||
ok(0, "Unexpected command %s\n", myARGV[2]);
|
||||
return;
|
||||
}
|
||||
|
||||
test_process_info();
|
||||
test_TerminateProcess();
|
||||
test_Startup();
|
||||
|
@ -3177,6 +3210,7 @@ START_TEST(process)
|
|||
test_StartupNoConsole();
|
||||
test_GetNumaProcessorNode();
|
||||
test_session_info();
|
||||
test_GetLogicalProcessorInformationEx();
|
||||
|
||||
/* things that can be tested:
|
||||
* lookup: check the way program to be executed is searched
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
static NTSTATUS (WINAPI * pNtQuerySystemInformation)(SYSTEM_INFORMATION_CLASS, PVOID, ULONG, PULONG);
|
||||
static NTSTATUS (WINAPI * pNtQuerySystemInformationEx)(SYSTEM_INFORMATION_CLASS, void*, ULONG, void*, ULONG, ULONG*);
|
||||
static NTSTATUS (WINAPI * pNtPowerInformation)(POWER_INFORMATION_LEVEL, PVOID, ULONG, PVOID, ULONG);
|
||||
static NTSTATUS (WINAPI * pNtQueryInformationProcess)(HANDLE, PROCESSINFOCLASS, PVOID, ULONG, PULONG);
|
||||
static NTSTATUS (WINAPI * pNtQueryInformationThread)(HANDLE, THREADINFOCLASS, PVOID, ULONG, PULONG);
|
||||
|
@ -36,6 +37,7 @@ static NTSTATUS (WINAPI * pNtUnmapViewOfSection)(HANDLE,PVOID);
|
|||
static NTSTATUS (WINAPI * pNtClose)(HANDLE);
|
||||
static ULONG (WINAPI * pNtGetCurrentProcessorNumber)(void);
|
||||
static BOOL (WINAPI * pIsWow64Process)(HANDLE, PBOOL);
|
||||
static BOOL (WINAPI * pGetLogicalProcessorInformationEx)(LOGICAL_PROCESSOR_RELATIONSHIP,SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*,DWORD*);
|
||||
|
||||
static BOOL is_wow64;
|
||||
|
||||
|
@ -56,6 +58,8 @@ static BOOL InitFunctionPtrs(void)
|
|||
{
|
||||
/* All needed functions are NT based, so using GetModuleHandle is a good check */
|
||||
HMODULE hntdll = GetModuleHandleA("ntdll");
|
||||
HMODULE hkernel32 = GetModuleHandleA("kernel32");
|
||||
|
||||
if (!hntdll)
|
||||
{
|
||||
win_skip("Not running on NT\n");
|
||||
|
@ -78,8 +82,16 @@ static BOOL InitFunctionPtrs(void)
|
|||
/* not present before XP */
|
||||
pNtGetCurrentProcessorNumber = (void *) GetProcAddress(hntdll, "NtGetCurrentProcessorNumber");
|
||||
|
||||
pIsWow64Process = (void *)GetProcAddress(GetModuleHandleA("kernel32.dll"), "IsWow64Process");
|
||||
pIsWow64Process = (void *)GetProcAddress(hkernel32, "IsWow64Process");
|
||||
if (!pIsWow64Process || !pIsWow64Process( GetCurrentProcess(), &is_wow64 )) is_wow64 = FALSE;
|
||||
|
||||
/* starting with Win7 */
|
||||
pNtQuerySystemInformationEx = (void *) GetProcAddress(hntdll, "NtQuerySystemInformationEx");
|
||||
if (!pNtQuerySystemInformationEx)
|
||||
skip("NtQuerySystemInformationEx() is not supported, some tests will be skipped.\n");
|
||||
|
||||
pGetLogicalProcessorInformationEx = (void *) GetProcAddress(hkernel32, "GetLogicalProcessorInformationEx");
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -696,6 +708,44 @@ static void test_query_logicalproc(void)
|
|||
HeapFree(GetProcessHeap(), 0, slpi);
|
||||
}
|
||||
|
||||
static void test_query_logicalprocex(void)
|
||||
{
|
||||
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infoex, *infoex2;
|
||||
DWORD relationship, len2, len;
|
||||
NTSTATUS status;
|
||||
BOOL ret;
|
||||
|
||||
if (!pNtQuerySystemInformationEx)
|
||||
return;
|
||||
|
||||
len = 0;
|
||||
relationship = RelationAll;
|
||||
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len);
|
||||
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
|
||||
ok(len > 0, "got %u\n", len);
|
||||
|
||||
len2 = 0;
|
||||
ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, &len2);
|
||||
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %d\n", ret, GetLastError());
|
||||
ok(len == len2, "got %u, expected %u\n", len2, len);
|
||||
|
||||
if (len == len2) {
|
||||
infoex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
||||
infoex2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
|
||||
|
||||
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex, len, &len);
|
||||
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
|
||||
ok(infoex->Size > 0, "got %u\n", infoex->Size);
|
||||
|
||||
ret = pGetLogicalProcessorInformationEx(RelationAll, infoex2, &len2);
|
||||
ok(ret, "got %d, error %d\n", ret, GetLastError());
|
||||
ok(!memcmp(infoex, infoex2, len), "returned info data mismatch\n");
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, infoex);
|
||||
HeapFree(GetProcessHeap(), 0, infoex2);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_query_processor_power_info(void)
|
||||
{
|
||||
NTSTATUS status;
|
||||
|
@ -1934,6 +1984,7 @@ START_TEST(info)
|
|||
/* 0x49 SystemLogicalProcessorInformation */
|
||||
trace("Starting test_query_logicalproc()\n");
|
||||
test_query_logicalproc();
|
||||
test_query_logicalprocex();
|
||||
|
||||
/* NtPowerInformation */
|
||||
|
||||
|
|
|
@ -842,6 +842,7 @@ typedef enum _SYSTEM_INFORMATION_CLASS {
|
|||
Unknown71,
|
||||
Unknown72,
|
||||
SystemLogicalProcessorInformation = 73,
|
||||
SystemLogicalProcessorInformationEx = 107,
|
||||
SystemInformationClassMax
|
||||
} SYSTEM_INFORMATION_CLASS, *PSYSTEM_INFORMATION_CLASS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue