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=48642 Signed-off-by: Francois Gouget fgouget@codeweavers.com --- dlls/kernel32/tests/process.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c index b5ed99062e9..7cd8e3140e8 100644 --- a/dlls/kernel32/tests/process.c +++ b/dlls/kernel32/tests/process.c @@ -2759,7 +2759,8 @@ static void test_KillOnJobClose(void)
static void test_WaitForJobObject(void) { - HANDLE job; + HANDLE job, sem; + char buffer[50]; PROCESS_INFORMATION pi; BOOL ret; DWORD dwret; @@ -2826,10 +2827,13 @@ static void test_WaitForJobObject(void) dwret = WaitForSingleObject(job, 100); 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); ok(ret, "AssignProcessToJobObject error %u\n", GetLastError()); + ReleaseSemaphore(sem, 1, NULL);
dwret = WaitForSingleObject(job, 100); ok(dwret == WAIT_TIMEOUT, "WaitForSingleObject returned %u\n", dwret); @@ -4047,6 +4051,13 @@ START_TEST(process) ok(0, "Child process not killed\n"); return; } + else if (!strcmp(myARGV[2], "sync") && myARGC >= 4) + { + HANDLE sem = CreateSemaphoreA(NULL, 0, 1, myARGV[3]); + ok(sem, "Could not get the %s semaphore: le=%u\n", myARGV[3], GetLastError()); + if (sem) WaitForSingleObject(sem, 30000); + return; + } else if (!strcmp(myARGV[2], "exit")) { Sleep(100);