Commit 0b6c3a44 authored by Anastasios Simeonidis's avatar Anastasios Simeonidis Committed by Alexandre Julliard

ntdll/tests: Add relationship tests for NtQuerySystemInformationEx.

parent 440a06f7
......@@ -738,8 +738,9 @@ static void test_query_logicalproc(void)
static void test_query_logicalprocex(void)
{
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infoex, *infoex2;
DWORD relationship, len2, len;
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infoex, *infoex_public, *infoex_core, *infoex_numa,
*infoex_cache, *infoex_package, *infoex_group, *ex;
DWORD relationship, len, len_public, len_core, len_numa, len_cache, len_package, len_group, len_union;
NTSTATUS status;
BOOL ret;
......@@ -747,40 +748,69 @@ static void test_query_logicalprocex(void)
return;
len = 0;
relationship = RelationProcessorCore;
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);
len = 0;
relationship = RelationAll;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len);
len_core = 0;
relationship = RelationProcessorCore;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len_core);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
ok(len > 0, "got %u\n", len);
ok(len_core > 0, "got %u\n", len_core);
len_numa = 0;
relationship = RelationNumaNode;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len_numa);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
ok(len_numa > 0, "got %u\n", len_numa);
len_cache = 0;
relationship = RelationCache;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len_cache);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
ok(len_cache > 0, "got %u\n", len_cache);
len_package = 0;
relationship = RelationProcessorPackage;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len_package);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
ok(len_package > 0, "got %u\n", len_package);
len_group = 0;
relationship = RelationGroup;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), NULL, 0, &len_group);
ok(status == STATUS_INFO_LENGTH_MISMATCH, "got 0x%08x\n", status);
ok(len_group > 0, "got %u\n", len_group);
len2 = 0;
ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, &len2);
len_public = 0;
ret = pGetLogicalProcessorInformationEx(RelationAll, NULL, &len_public);
ok(!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER, "got %d, error %d\n", ret, GetLastError());
ok(len == len2, "got %u, expected %u\n", len2, len);
ok(len == len_public, "got %u, expected %u\n", len_public, len);
if (len && len == len2) {
if (len && len == len_public) {
int j, i;
infoex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
infoex2 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
infoex_public = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len_public);
infoex_core = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len_core);
infoex_numa = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len_numa);
infoex_cache = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len_cache);
infoex_package = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len_package);
infoex_group = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len_group);
relationship = RelationAll;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex, len, &len);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
ret = pGetLogicalProcessorInformationEx(RelationAll, infoex2, &len2);
ret = pGetLogicalProcessorInformationEx(RelationAll, infoex_public, &len_public);
ok(ret, "got %d, error %d\n", ret, GetLastError());
ok(!memcmp(infoex, infoex2, len), "returned info data mismatch\n");
ok(!memcmp(infoex, infoex_public, len), "returned info data mismatch\n");
/* Test for RelationAll. */
for(i = 0; status == STATUS_SUCCESS && i < len; ){
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *ex = (void*)(((char *)infoex) + i);
ex = (void*)(((char *)infoex) + i);
ok(ex->Relationship >= RelationProcessorCore && ex->Relationship <= RelationGroup,
"Got invalid relationship value: 0x%x\n", ex->Relationship);
if (!ex->Size)
{
ok(0, "got infoex[%u].Size=0\n", i);
......@@ -791,7 +821,7 @@ static void test_query_logicalprocex(void)
switch(ex->Relationship){
case RelationProcessorCore:
case RelationProcessorPackage:
trace("infoex[%u].Relationship: 0x%x (Core == 0x0 or Package == 0x3)\n", i, ex->Relationship);
trace("infoex[%u].Relationship: 0x%x (%s)\n", i, ex->Relationship, ex->Relationship == RelationProcessorCore ? "Core" : "Package");
trace("infoex[%u].Processor.Flags: 0x%x\n", i, ex->Processor.Flags);
trace("infoex[%u].Processor.EfficiencyClass: 0x%x\n", i, ex->Processor.EfficiencyClass);
trace("infoex[%u].Processor.GroupCount: 0x%x\n", i, ex->Processor.GroupCount);
......@@ -827,14 +857,110 @@ static void test_query_logicalprocex(void)
}
break;
default:
ok(0, "Got invalid relationship value: 0x%x\n", ex->Relationship);
break;
}
i += ex->Size;
}
/* Test Relationship filtering. */
relationship = RelationProcessorCore;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex_core, len_core, &len_core);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
for(i = 0; status == STATUS_SUCCESS && i < len_core;) {
ex = (void*)(((char*)infoex_core) + i);
if (ex->Size == 0) {
ok(0, "Got infoex_core[%u].Size=0\n", i);
break;
}
if (ex->Relationship != RelationProcessorCore) {
ok(0, "Expected 0x%x, got 0x%x\n", RelationProcessorCore, ex->Relationship);
break;
}
i += ex->Size;
}
relationship = RelationNumaNode;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex_numa, len_numa, &len_numa);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
for(i = 0; status == STATUS_SUCCESS && i < len_numa;) {
ex = (void*)(((char*)infoex_numa) + i);
if (ex->Size == 0) {
ok(0, "Got infoex_numa[%u].Size=0\n", i);
break;
}
if (ex->Relationship != RelationNumaNode) {
ok(0, "Expected 0x%x, got 0x%x\n", RelationNumaNode, ex->Relationship);
break;
}
i += ex->Size;
}
relationship = RelationCache;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex_cache, len_cache, &len_cache);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
for(i = 0; status == STATUS_SUCCESS && i < len_cache;) {
ex = (void*)(((char*)infoex_cache) + i);
if (ex->Size == 0) {
ok(0, "Got infoex_cache[%u].Size=0\n", i);
break;
}
if (ex->Relationship != RelationCache) {
ok(0, "Expected 0x%x, got 0x%x\n", RelationCache, ex->Relationship);
break;
}
i += ex->Size;
}
relationship = RelationProcessorPackage;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex_package, len_package, &len_package);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
for(i = 0; status == STATUS_SUCCESS && i < len_package;) {
ex = (void*)(((char*)infoex_package) + i);
if (ex->Size == 0) {
ok(0, "Got infoex_package[%u].Size=0\n", i);
break;
}
if (ex->Relationship != RelationProcessorPackage) {
ok(0, "Expected 0x%x, got 0x%x\n", RelationProcessorPackage, ex->Relationship);
break;
}
i += ex->Size;
}
relationship = RelationGroup;
status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex_group, len_group, &len_group);
ok(status == STATUS_SUCCESS, "got 0x%08x\n", status);
for(i = 0; status == STATUS_SUCCESS && i < len_group;) {
ex = (void*)(((char *)infoex_group) + i);
if (ex->Size == 0) {
ok(0, "Got infoex_group[%u].Size=0\n", i);
break;
}
if (ex->Relationship != RelationGroup) {
ok(0, "Expected 0x%x, got 0x%x\n", RelationGroup, ex->Relationship);
break;
}
i += ex->Size;
}
len_union = len_core + len_numa + len_cache + len_package + len_group;
ok(len == len_union, "Expected 0x%x, got 0x%0x\n", len, len_union);
HeapFree(GetProcessHeap(), 0, infoex);
HeapFree(GetProcessHeap(), 0, infoex2);
HeapFree(GetProcessHeap(), 0, infoex_public);
HeapFree(GetProcessHeap(), 0, infoex_core);
HeapFree(GetProcessHeap(), 0, infoex_numa);
HeapFree(GetProcessHeap(), 0, infoex_cache);
HeapFree(GetProcessHeap(), 0, infoex_package);
HeapFree(GetProcessHeap(), 0, infoex_group);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment