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:
Daniel Lehman 2020-08-05 22:09:46 -07:00 committed by Alexandre Julliard
parent f7895ef25a
commit 93fa2e0ab8
1 changed files with 15 additions and 9 deletions

View File

@ -51,6 +51,12 @@ static BOOL is_wow64;
*/
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 { \
p ## func = (void*)GetProcAddress(hntdll, #func); \
if(!p ## func) { \
@ -2251,8 +2257,8 @@ static void test_affinity(void)
status = pNtQueryInformationProcess( GetCurrentProcess(), ProcessBasicInformation, &pbi, sizeof(pbi), NULL );
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
proc_affinity = pbi.AffinityMask;
ok( proc_affinity == (1 << si.dwNumberOfProcessors) - 1, "Unexpected process affinity\n" );
proc_affinity = 1 << si.dwNumberOfProcessors;
ok( proc_affinity == get_affinity_mask( si.dwNumberOfProcessors ), "Unexpected process affinity\n" );
proc_affinity = (DWORD_PTR)1 << si.dwNumberOfProcessors;
status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) );
ok( status == STATUS_INVALID_PARAMETER,
"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 );
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1, "Unexpected thread affinity\n" );
thread_affinity = 1 << si.dwNumberOfProcessors;
ok( tbi.AffinityMask == get_affinity_mask( si.dwNumberOfProcessors ), "Unexpected thread affinity\n" );
thread_affinity = (DWORD_PTR)1 << si.dwNumberOfProcessors;
status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) );
ok( status == STATUS_INVALID_PARAMETER,
"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 );
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
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,
"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) );
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
/* Resetting the process affinity also resets the thread affinity */
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
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" );
}
@ -2445,13 +2451,13 @@ static void test_NtGetCurrentProcessorNumber(void)
ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
/* 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));
ok(status == STATUS_SUCCESS, "got 0x%x (expected STATUS_SUCCESS)\n", status);
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));
ok(status == STATUS_SUCCESS, "%d: got 0x%x (expected STATUS_SUCCESS)\n", i, status);