kernel32/tests: WaitForMultipleObjects returns lowest signaled handle first.
This commit is contained in:
parent
a1d177c6b6
commit
a52e160c68
|
@ -41,8 +41,7 @@ static void test_signalandwait(void)
|
|||
DWORD (WINAPI *pSignalObjectAndWait)(HANDLE, HANDLE, DWORD, BOOL);
|
||||
HMODULE kernel32;
|
||||
DWORD r;
|
||||
int i;
|
||||
HANDLE event[2], maxevents[MAXIMUM_WAIT_OBJECTS], semaphore[2], file;
|
||||
HANDLE event[2], semaphore[2], file;
|
||||
|
||||
kernel32 = GetModuleHandle("kernel32");
|
||||
pSignalObjectAndWait = (void*) GetProcAddress(kernel32, "SignalObjectAndWait");
|
||||
|
@ -94,19 +93,6 @@ static void test_signalandwait(void)
|
|||
CloseHandle(event[0]);
|
||||
CloseHandle(event[1]);
|
||||
|
||||
/* create the maximum number of events and make sure
|
||||
* we can wait on that many */
|
||||
for (i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
|
||||
{
|
||||
maxevents[i] = CreateEvent(NULL, 1, 1, NULL);
|
||||
ok( maxevents[i] != 0, "should create enough events\n");
|
||||
}
|
||||
r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, 0, 0);
|
||||
ok( r != WAIT_FAILED && r != WAIT_TIMEOUT, "should succeed\n");
|
||||
|
||||
for (i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
|
||||
if (maxevents[i]) CloseHandle(maxevents[i]);
|
||||
|
||||
/* semaphores */
|
||||
semaphore[0] = CreateSemaphore( NULL, 0, 1, NULL );
|
||||
semaphore[1] = CreateSemaphore( NULL, 1, 1, NULL );
|
||||
|
@ -1027,6 +1013,37 @@ static void test_WaitForSingleObject(void)
|
|||
CloseHandle(nonsignaled);
|
||||
}
|
||||
|
||||
static void test_WaitForMultipleObjects(void)
|
||||
{
|
||||
DWORD r;
|
||||
int i;
|
||||
HANDLE maxevents[MAXIMUM_WAIT_OBJECTS];
|
||||
|
||||
/* create the maximum number of events and make sure
|
||||
* we can wait on that many */
|
||||
for (i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
|
||||
{
|
||||
maxevents[i] = CreateEvent(NULL, i==0, TRUE, NULL);
|
||||
ok( maxevents[i] != 0, "should create enough events\n");
|
||||
}
|
||||
|
||||
/* a manual-reset event remains signaled, an auto-reset event is cleared */
|
||||
r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, 0, 0);
|
||||
ok( r == WAIT_OBJECT_0, "should signal lowest handle first, got %d\n", r);
|
||||
r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, 0, 0);
|
||||
ok( r == WAIT_OBJECT_0, "should signal handle #0 first, got %d\n", r);
|
||||
ok(ResetEvent(maxevents[0]), "ResetEvent\n");
|
||||
for (i=1; i<MAXIMUM_WAIT_OBJECTS; i++)
|
||||
{
|
||||
/* the lowest index is checked first and remaining events are untouched */
|
||||
r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, 0, 0);
|
||||
ok( r == WAIT_OBJECT_0+i, "should signal handle #%d first, got %d\n", i, r);
|
||||
}
|
||||
|
||||
for (i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
|
||||
if (maxevents[i]) CloseHandle(maxevents[i]);
|
||||
}
|
||||
|
||||
START_TEST(sync)
|
||||
{
|
||||
HMODULE hdll = GetModuleHandle("kernel32");
|
||||
|
@ -1047,4 +1064,5 @@ START_TEST(sync)
|
|||
test_iocp_callback();
|
||||
test_timer_queue();
|
||||
test_WaitForSingleObject();
|
||||
test_WaitForMultipleObjects();
|
||||
}
|
||||
|
|
|
@ -288,6 +288,7 @@ static VOID test_CreateRemoteThread(void)
|
|||
skip("child process wasn't mapped at same address, so can't do CreateRemoteThread tests.\n");
|
||||
return;
|
||||
}
|
||||
ok(ret == WAIT_OBJECT_0 || broken(ret == WAIT_OBJECT_0+1 /* nt4,w2k */), "WaitForAllObjects 2 events %d\n", ret);
|
||||
|
||||
hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
|
||||
ok(hEvent != NULL, "Can't create event, err=%u\n", GetLastError());
|
||||
|
@ -1248,7 +1249,7 @@ static void test_TLS(void)
|
|||
}
|
||||
|
||||
ret = WaitForMultipleObjects(2, threads, TRUE, 60000);
|
||||
ok(ret == WAIT_OBJECT_0 || ret == WAIT_OBJECT_0+1 /* nt4 */, "WaitForMultipleObjects failed %u\n",ret);
|
||||
ok(ret == WAIT_OBJECT_0 || broken(ret == WAIT_OBJECT_0+1 /* nt4,w2k */), "WaitForAllObjects 2 threads %d\n",ret);
|
||||
|
||||
for (i = 0; i < 2; ++i)
|
||||
CloseHandle(threads[i]);
|
||||
|
|
Loading…
Reference in New Issue