kernel32/test: Fix the semaphore handling in test_WaitForJobObject().
Don't include 'sync ' in the semaphore name because it will end up as a separate argument in the child process, causing it to not find the semaphore. Switch the child to OpenSemaphoreA() to reduce the risk of accidentally create a new semaphore instead of opening the parent's one. Use wait_child_process() instead of a raw WaitForSingleObject(). The timeout is longer but the process is expected to exit immediately anyway and this allows proper handling of child failures (such as if there is a bug with the semaphore handling). Signed-off-by: Francois Gouget <fgouget@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ecf70b83e2
commit
dd4fad93e4
@ -2832,7 +2832,8 @@ static void test_WaitForJobObject(void)
|
||||
ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
|
||||
|
||||
sprintf(buffer, "sync kernel32-process-%x", GetCurrentProcessId());
|
||||
sem = CreateSemaphoreA(NULL, 0, 1, buffer);
|
||||
sem = CreateSemaphoreA(NULL, 0, 1, buffer + 5);
|
||||
ok(sem != NULL, "CreateSemaphoreA failed le=%u\n", GetLastError());
|
||||
create_process(buffer, &pi);
|
||||
|
||||
ret = pAssignProcessToJobObject(job, pi.hProcess);
|
||||
@ -2842,10 +2843,11 @@ static void test_WaitForJobObject(void)
|
||||
dwret = WaitForSingleObject(job, 100);
|
||||
ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
|
||||
|
||||
WaitForSingleObject(pi.hProcess, 1000);
|
||||
wait_child_process(pi.hProcess);
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
CloseHandle(job);
|
||||
CloseHandle(sem);
|
||||
}
|
||||
|
||||
static HANDLE test_AddSelfToJob(void)
|
||||
@ -4057,9 +4059,14 @@ START_TEST(process)
|
||||
}
|
||||
else if (!strcmp(myARGV[2], "sync") && myARGC >= 4)
|
||||
{
|
||||
HANDLE sem = CreateSemaphoreA(NULL, 0, 1, myARGV[3]);
|
||||
ok(sem != 0, "Could not get the %s semaphore: le=%u\n", myARGV[3], GetLastError());
|
||||
if (sem) WaitForSingleObject(sem, 30000);
|
||||
HANDLE sem = OpenSemaphoreA(SYNCHRONIZE, FALSE, myARGV[3]);
|
||||
ok(sem != 0, "OpenSemaphoreA(%s) failed le=%u\n", myARGV[3], GetLastError());
|
||||
if (sem)
|
||||
{
|
||||
DWORD ret = WaitForSingleObject(sem, 30000);
|
||||
ok(ret == WAIT_OBJECT_0, "WaitForSingleObject(%s) returned %u\n", myARGV[3], ret);
|
||||
CloseHandle(sem);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (!strcmp(myARGV[2], "exit"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user