ntdll/tests: Handle 32 cores.
Signed-off-by: Daniel Lehman <dlehman25@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f7895ef25a
commit
93fa2e0ab8
|
@ -51,6 +51,12 @@ static BOOL is_wow64;
|
||||||
*/
|
*/
|
||||||
static DWORD one_before_last_pid = 0;
|
static DWORD one_before_last_pid = 0;
|
||||||
|
|
||||||
|
static inline DWORD_PTR get_affinity_mask(DWORD num_cpus)
|
||||||
|
{
|
||||||
|
if (num_cpus >= sizeof(DWORD_PTR) * 8) return ~(DWORD_PTR)0;
|
||||||
|
return ((DWORD_PTR)1 << num_cpus) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
#define NTDLL_GET_PROC(func) do { \
|
#define NTDLL_GET_PROC(func) do { \
|
||||||
p ## func = (void*)GetProcAddress(hntdll, #func); \
|
p ## func = (void*)GetProcAddress(hntdll, #func); \
|
||||||
if(!p ## func) { \
|
if(!p ## func) { \
|
||||||
|
@ -2251,8 +2257,8 @@ static void test_affinity(void)
|
||||||
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
|
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
|
||||||
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
||||||
proc_affinity = pbi.AffinityMask;
|
proc_affinity = pbi.AffinityMask;
|
||||||
ok( proc_affinity == (1 << si.dwNumberOfProcessors) - 1, "Unexpected process affinity\n" );
|
ok( proc_affinity == get_affinity_mask( si.dwNumberOfProcessors ), "Unexpected process affinity\n" );
|
||||||
proc_affinity = 1 << si.dwNumberOfProcessors;
|
proc_affinity = (DWORD_PTR)1 << si.dwNumberOfProcessors;
|
||||||
status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
|
status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
|
||||||
ok( status == STATUS_INVALID_PARAMETER,
|
ok( status == STATUS_INVALID_PARAMETER,
|
||||||
"Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
|
"Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
|
||||||
|
@ -2264,8 +2270,8 @@ static void test_affinity(void)
|
||||||
|
|
||||||
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
|
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
|
||||||
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
||||||
ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1, "Unexpected thread affinity\n" );
|
ok( tbi.AffinityMask == get_affinity_mask( si.dwNumberOfProcessors ), "Unexpected thread affinity\n" );
|
||||||
thread_affinity = 1 << si.dwNumberOfProcessors;
|
thread_affinity = (DWORD_PTR)1 << si.dwNumberOfProcessors;
|
||||||
status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
|
status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
|
||||||
ok( status == STATUS_INVALID_PARAMETER,
|
ok( status == STATUS_INVALID_PARAMETER,
|
||||||
"Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
|
"Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
|
||||||
|
@ -2319,7 +2325,7 @@ static void test_affinity(void)
|
||||||
{
|
{
|
||||||
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
|
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
|
||||||
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
ok(status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
||||||
ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1, "unexpected affinity %#lx\n", tbi.AffinityMask );
|
ok( tbi.AffinityMask == get_affinity_mask( si.dwNumberOfProcessors ), "unexpected affinity %#lx\n", tbi.AffinityMask );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
skip("Cannot test thread affinity mask for 'all processors' flag\n");
|
skip("Cannot test thread affinity mask for 'all processors' flag\n");
|
||||||
|
@ -2341,13 +2347,13 @@ static void test_affinity(void)
|
||||||
ok( status == STATUS_INVALID_PARAMETER,
|
ok( status == STATUS_INVALID_PARAMETER,
|
||||||
"Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
|
"Expected STATUS_INVALID_PARAMETER, got %08x\n", status);
|
||||||
|
|
||||||
proc_affinity = (1 << si.dwNumberOfProcessors) - 1;
|
proc_affinity = get_affinity_mask( si.dwNumberOfProcessors );
|
||||||
status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
|
status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
|
||||||
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
||||||
/* Resetting the process affinity also resets the thread affinity */
|
/* Resetting the process affinity also resets the thread affinity */
|
||||||
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
|
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
|
||||||
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
|
||||||
ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1,
|
ok( tbi.AffinityMask == get_affinity_mask( si.dwNumberOfProcessors ),
|
||||||
"Unexpected thread affinity\n" );
|
"Unexpected thread affinity\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2445,13 +2451,13 @@ static void test_NtGetCurrentProcessorNumber(void)
|
||||||
ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
|
ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
|
||||||
|
|
||||||
/* allow the test to run on all processors */
|
/* allow the test to run on all processors */
|
||||||
new_mask = (1 << si.dwNumberOfProcessors) - 1;
|
new_mask = get_affinity_mask( si.dwNumberOfProcessors );
|
||||||
status = pNtSetInformationProcess(GetCurrentProcess(), ProcessAffinityMask, &new_mask, sizeof(new_mask));
|
status = pNtSetInformationProcess(GetCurrentProcess(), ProcessAffinityMask, &new_mask, sizeof(new_mask));
|
||||||
ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
|
ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
|
||||||
|
|
||||||
for (i = 0; i < si.dwNumberOfProcessors; i++)
|
for (i = 0; i < si.dwNumberOfProcessors; i++)
|
||||||
{
|
{
|
||||||
new_mask = 1 << i;
|
new_mask = (DWORD_PTR)1 << i;
|
||||||
status = pNtSetInformationThread(GetCurrentThread(), ThreadAffinityMask, &new_mask, sizeof(new_mask));
|
status = pNtSetInformationThread(GetCurrentThread(), ThreadAffinityMask, &new_mask, sizeof(new_mask));
|
||||||
ok(status == STATUS_SUCCESS, "%d: got 0x%x (expected STATUS_SUCCESS)\n", i, status);
|
ok(status == STATUS_SUCCESS, "%d: got 0x%x (expected STATUS_SUCCESS)\n", i, status);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue