Commit 5a66e3e0 authored by Francois Gouget's avatar Francois Gouget Committed by Alexandre Julliard

kernel32/tests: Fix a race condition in test_WaitForJobObject().

Synchronize with the child process to ensure it does not exit before being added to the test job. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48642Signed-off-by: 's avatarFrancois Gouget <fgouget@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 2a2d09c5
...@@ -2759,7 +2759,8 @@ static void test_KillOnJobClose(void) ...@@ -2759,7 +2759,8 @@ static void test_KillOnJobClose(void)
static void test_WaitForJobObject(void) static void test_WaitForJobObject(void)
{ {
HANDLE job; HANDLE job, sem;
char buffer[50];
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
BOOL ret; BOOL ret;
DWORD dwret; DWORD dwret;
...@@ -2826,10 +2827,13 @@ static void test_WaitForJobObject(void) ...@@ -2826,10 +2827,13 @@ static void test_WaitForJobObject(void)
dwret = WaitForSingleObject(job, 100); dwret = WaitForSingleObject(job, 100);
ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret); ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
create_process("exit", &pi); sprintf(buffer, "sync kernel32-process-%x", GetCurrentProcessId());
sem = CreateSemaphoreA(NULL, 0, 1, buffer);
create_process(buffer, &pi);
ret = pAssignProcessToJobObject(job, pi.hProcess); ret = pAssignProcessToJobObject(job, pi.hProcess);
ok(ret, "AssignProcessToJobObject error %u\n", GetLastError()); ok(ret, "AssignProcessToJobObject error %u\n", GetLastError());
ReleaseSemaphore(sem, 1, NULL);
dwret = WaitForSingleObject(job, 100); dwret = WaitForSingleObject(job, 100);
ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret); ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret);
...@@ -4047,6 +4051,13 @@ START_TEST(process) ...@@ -4047,6 +4051,13 @@ START_TEST(process)
ok(0, "Child process not killed\n"); ok(0, "Child process not killed\n");
return; return;
} }
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);
return;
}
else if (!strcmp(myARGV[2], "exit")) else if (!strcmp(myARGV[2], "exit"))
{ {
Sleep(100); Sleep(100);
......
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