Report the line number where the test failed to wait for the child so one can identify which child process did not behave as expected. Also wait_child_process() is meant for the general case so report all non-crash error cases as test failures so they are accounted for. Omit the "winetest_" prefix to match the other Wine test functions and so the underlying winetest_wait_child_process() function can be wrapped with the usual line-capturing macros.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48651 Signed-off-by: Francois Gouget fgouget@codeweavers.com --- dlls/advapi32/tests/security.c | 4 ++-- dlls/dbgeng/tests/dbgeng.c | 4 ++-- dlls/gdi32/tests/font.c | 2 +- dlls/kernel32/tests/actctx.c | 4 ++-- dlls/kernel32/tests/console.c | 2 +- dlls/kernel32/tests/heap.c | 2 +- dlls/kernel32/tests/pipe.c | 6 +++--- dlls/kernel32/tests/toolhelp.c | 2 +- dlls/kernel32/tests/virtual.c | 4 ++-- dlls/mfplat/tests/mfplat.c | 4 ++-- dlls/mscoree/tests/comtest.c | 2 +- dlls/msvcrt/tests/data.c | 2 +- dlls/msvcrt/tests/file.c | 4 ++-- dlls/ntdll/tests/exception.c | 4 ++-- dlls/ole32/tests/marshal.c | 2 +- dlls/oleacc/tests/main.c | 2 +- dlls/qmgr/tests/qmgr.c | 2 +- dlls/rpcrt4/tests/server.c | 6 +++--- dlls/shell32/tests/shellpath.c | 2 +- dlls/shlwapi/tests/ordinal.c | 2 +- dlls/sxs/tests/sxs.c | 2 +- dlls/ucrtbase/tests/misc.c | 2 +- dlls/urlmon/tests/misc.c | 2 +- dlls/urlmon/tests/sec_mgr.c | 2 +- dlls/user32/tests/class.c | 2 +- dlls/user32/tests/clipboard.c | 2 +- dlls/user32/tests/cursoricon.c | 2 +- dlls/user32/tests/msg.c | 2 +- dlls/user32/tests/win.c | 6 +++--- include/wine/test.h | 32 ++++++++++++++++++++++---------- 30 files changed, 64 insertions(+), 52 deletions(-)
diff --git a/dlls/advapi32/tests/security.c b/dlls/advapi32/tests/security.c index d003a7f1a0d..c6f5d4690ae 100644 --- a/dlls/advapi32/tests/security.c +++ b/dlls/advapi32/tests/security.c @@ -3050,7 +3050,7 @@ static void test_process_security(void) STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL ); TEST_GRANTED_ACCESS2( info.hThread, THREAD_ALL_ACCESS_NT4, STANDARD_RIGHTS_ALL | SPECIFIC_RIGHTS_ALL ); - winetest_wait_child_process( info.hProcess ); + wait_child_process( info.hProcess );
FreeSid(EveryoneSid); CloseHandle( info.hProcess ); @@ -7189,7 +7189,7 @@ static void test_token_security_descriptor(void) sprintf(buffer, "%s security test_token_sd", myARGV[0]); ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info); ok(ret, "CreateProcess failed with error %u\n", GetLastError()); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(info.hProcess); CloseHandle(info.hThread);
diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index 498ecd4de69..572d96e405b 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -308,7 +308,7 @@ todo_wine
SetEvent(event);
- winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess);
CloseHandle(info.hProcess); CloseHandle(info.hThread); @@ -473,7 +473,7 @@ static void test_module_information(void) ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr);
SetEvent(event); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess);
CloseHandle(info.hProcess); CloseHandle(info.hThread); diff --git a/dlls/gdi32/tests/font.c b/dlls/gdi32/tests/font.c index 7e90a50d844..ae4a643aa54 100644 --- a/dlls/gdi32/tests/font.c +++ b/dlls/gdi32/tests/font.c @@ -7268,7 +7268,7 @@ START_TEST(font) sprintf(path_name, "%s font %s", argv[0], test_names[i]); ok(CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n"); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(info.hProcess); CloseHandle(info.hThread); } diff --git a/dlls/kernel32/tests/actctx.c b/dlls/kernel32/tests/actctx.c index 4b7096276e8..01c6c1e627c 100644 --- a/dlls/kernel32/tests/actctx.c +++ b/dlls/kernel32/tests/actctx.c @@ -2506,7 +2506,7 @@ static void run_child_process(void) sprintf(cmdline, ""%s" %s manifest1", argv[0], argv[1]); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %u\n", GetLastError()); - winetest_wait_child_process( pi.hProcess ); + wait_child_process( pi.hProcess ); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); DeleteFileA(path); @@ -3470,7 +3470,7 @@ static void run_child_process_two_dll(int run) ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %u\n", GetLastError());
- winetest_wait_child_process( pi.hProcess ); + wait_child_process( pi.hProcess );
CloseHandle(pi.hThread); CloseHandle(pi.hProcess); diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 9698f11779e..5e35f101d5a 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -3272,7 +3272,7 @@ static void test_AttachConsole(HANDLE console) ok(res, "CreateProcess failed: %u\n", GetLastError()); CloseHandle(info.hThread);
- winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(info.hProcess);
res = ReadConsoleOutputCharacterA(console, buf, 5, c, &len); diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c index 3c697f31952..bc57498bf91 100644 --- a/dlls/kernel32/tests/heap.c +++ b/dlls/kernel32/tests/heap.c @@ -1102,7 +1102,7 @@ static void test_debug_heap( const char *argv0, DWORD flags ) ok( ret, "failed to create child process error %u\n", GetLastError() ); if (ret) { - winetest_wait_child_process( info.hProcess ); + wait_child_process( info.hProcess ); CloseHandle( info.hThread ); CloseHandle( info.hProcess ); } diff --git a/dlls/kernel32/tests/pipe.c b/dlls/kernel32/tests/pipe.c index 20f3450c6d0..3c7ca06a045 100644 --- a/dlls/kernel32/tests/pipe.c +++ b/dlls/kernel32/tests/pipe.c @@ -3258,7 +3258,7 @@ static void test_overlapped_transport(BOOL msg_mode, BOOL msg_read_mode) ok(!res && GetLastError() == ERROR_MORE_DATA, "ReadFile returned: %x %u\n", res, GetLastError()); ok(read_bytes == 10, "read_bytes = %u\n", read_bytes); TerminateProcess(process, 0); - winetest_wait_child_process(process); + wait_child_process(process); /* after terminating process, there is no pending write and pipe buffer is empty */ overlapped_read_async(server, buf, 10, &overlapped); overlapped_write_sync(client, buf, 1); @@ -3524,7 +3524,7 @@ static void test_namedpipe_process_id(void) ok(server != INVALID_HANDLE_VALUE, "got %u\n", GetLastError());
process = create_check_id_process("checkpid", GetProcessId(GetCurrentProcess())); - winetest_wait_child_process(process); + wait_child_process(process);
CloseHandle(overlapped.hEvent); CloseHandle(process); @@ -3667,7 +3667,7 @@ static void test_namedpipe_session_id(void) ok(server != INVALID_HANDLE_VALUE, "got %u\n", GetLastError());
process = create_check_id_process("checksessionid", current); - winetest_wait_child_process(process); + wait_child_process(process);
CloseHandle(overlapped.hEvent); CloseHandle(process); diff --git a/dlls/kernel32/tests/toolhelp.c b/dlls/kernel32/tests/toolhelp.c index 159d71a20cd..9250f8dc549 100644 --- a/dlls/kernel32/tests/toolhelp.c +++ b/dlls/kernel32/tests/toolhelp.c @@ -343,5 +343,5 @@ START_TEST(toolhelp) test_module(info.dwProcessId, sub_expected_modules, ARRAY_SIZE(sub_expected_modules));
SetEvent(ev2); - winetest_wait_child_process( info.hProcess ); + wait_child_process( info.hProcess ); } diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c index c534e310efe..99dde34396f 100644 --- a/dlls/kernel32/tests/virtual.c +++ b/dlls/kernel32/tests/virtual.c @@ -4154,7 +4154,7 @@ static void test_shared_memory(BOOL is_child) sprintf(cmdline, ""%s" virtual sharedmem", argv[0]); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError()); - winetest_wait_child_process(pi.hProcess); + wait_child_process(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } @@ -4194,7 +4194,7 @@ static void test_shared_memory_ro(BOOL is_child, DWORD child_access) sprintf(cmdline, ""%s" virtual sharedmemro %x", argv[0], child_access); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "CreateProcess(%s) error %d\n", cmdline, GetLastError()); - winetest_wait_child_process(pi.hProcess); + wait_child_process(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(pi.hProcess);
diff --git a/dlls/mfplat/tests/mfplat.c b/dlls/mfplat/tests/mfplat.c index bf63337b60f..008aa05c302 100644 --- a/dlls/mfplat/tests/mfplat.c +++ b/dlls/mfplat/tests/mfplat.c @@ -4434,7 +4434,7 @@ static void test_queue_com(void) sprintf(path_name, "%s mfplat s%d", argv[0], system_queues[i]); ok(CreateProcessA( NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n" ); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(info.hProcess); CloseHandle(info.hThread); } @@ -4446,7 +4446,7 @@ static void test_queue_com(void) sprintf(path_name, "%s mfplat u%d", argv[0], user_queues[i]); ok(CreateProcessA( NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n" ); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(info.hProcess); CloseHandle(info.hThread); } diff --git a/dlls/mscoree/tests/comtest.c b/dlls/mscoree/tests/comtest.c index 69e24494e6d..12b112417d5 100644 --- a/dlls/mscoree/tests/comtest.c +++ b/dlls/mscoree/tests/comtest.c @@ -315,7 +315,7 @@ static void run_child_process(const char *dll_source, run_type run) ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %u\n", GetLastError());
- winetest_wait_child_process(pi.hProcess); + wait_child_process(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hProcess); diff --git a/dlls/msvcrt/tests/data.c b/dlls/msvcrt/tests/data.c index 050a234ce87..52742ba4994 100644 --- a/dlls/msvcrt/tests/data.c +++ b/dlls/msvcrt/tests/data.c @@ -217,7 +217,7 @@ static void test___getmainargs_parent(char *name) memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &proc); - winetest_wait_child_process(proc.hProcess); + wait_child_process(proc.hProcess);
_unlink(filepath); sprintf(filepath, "%swine_test\a", tmppath); diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c index 0c4e024a8ec..8c6df2e8e2b 100644 --- a/dlls/msvcrt/tests/file.c +++ b/dlls/msvcrt/tests/file.c @@ -1430,7 +1430,7 @@ static void test_stdout_handle( STARTUPINFOA *startup, char *cmdline, HANDLE hst
CreateProcessA( NULL, cmdline, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE | NORMAL_PRIORITY_CLASS, NULL, NULL, startup, &proc ); - winetest_wait_child_process( proc.hProcess ); + wait_child_process( proc.hProcess );
data = read_file( hErrorFile ); if (expect_stdout) @@ -1647,7 +1647,7 @@ static void test_invalid_stdin( const char* selfname ) sprintf(cmdline, "%s file stdin", selfname); CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &proc); - winetest_wait_child_process(proc.hProcess); + wait_child_process(proc.hProcess);
ret = RegCloseKey(key); ok(!ret, "RegCloseKey failed: %x\n", ret); diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 07e05e45c90..4003b0a4805 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -1182,7 +1182,7 @@ static void test_debugger(void)
} while (de.dwDebugEventCode != EXIT_PROCESS_DEBUG_EVENT);
- winetest_wait_child_process( pi.hProcess ); + wait_child_process( pi.hProcess ); ret = CloseHandle(pi.hThread); ok(ret, "error %u\n", GetLastError()); ret = CloseHandle(pi.hProcess); @@ -3402,7 +3402,7 @@ static void test_suspend_process(void)
SetEvent(event);
- winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess);
CloseHandle(info.hProcess); CloseHandle(info.hThread); diff --git a/dlls/ole32/tests/marshal.c b/dlls/ole32/tests/marshal.c index ea224994e55..e2608ecb768 100644 --- a/dlls/ole32/tests/marshal.c +++ b/dlls/ole32/tests/marshal.c @@ -3894,7 +3894,7 @@ static void test_local_server(void) quit_event = CreateEventA(NULL, FALSE, FALSE, "Wine COM Test Quit Event"); SetEvent(quit_event);
- winetest_wait_child_process( process ); + wait_child_process( process ); CloseHandle(quit_event); CloseHandle(process); } diff --git a/dlls/oleacc/tests/main.c b/dlls/oleacc/tests/main.c index 685e9b76f56..c1e7d93ba3f 100644 --- a/dlls/oleacc/tests/main.c +++ b/dlls/oleacc/tests/main.c @@ -547,7 +547,7 @@ static void test_LresultFromObject(const char *name) memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &proc); - winetest_wait_child_process(proc.hProcess); + wait_child_process(proc.hProcess); ok(Object_ref == 1, "Object_ref = %d\n", Object_ref); }
diff --git a/dlls/qmgr/tests/qmgr.c b/dlls/qmgr/tests/qmgr.c index 4ab12d3360a..d000fd6f36d 100644 --- a/dlls/qmgr/tests/qmgr.c +++ b/dlls/qmgr/tests/qmgr.c @@ -117,7 +117,7 @@ static void run_child(WCHAR *secret)
wsprintfW(cmdline, format, progname, secret); ok(CreateProcessW(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); ok(CloseHandle(info.hProcess), "CloseHandle\n"); ok(CloseHandle(info.hThread), "CloseHandle\n"); } diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index 0a76c96d589..2400143eefe 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -1112,7 +1112,7 @@ run_client(const char *test)
make_cmdline(cmdline, test); ok(CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info), "CreateProcess\n"); - winetest_wait_child_process( info.hProcess ); + wait_child_process( info.hProcess ); ok(CloseHandle(info.hProcess), "CloseHandle\n"); ok(CloseHandle(info.hThread), "CloseHandle\n"); } @@ -2337,7 +2337,7 @@ static void test_reconnect(void)
stop();
- winetest_wait_child_process(server_process); + wait_child_process(server_process); ok(CloseHandle(server_process), "CloseHandle\n");
/* create new server, rpcrt4 will connect to it once sending to existing connection fails @@ -2346,7 +2346,7 @@ static void test_reconnect(void) basic_tests(); stop();
- winetest_wait_child_process(server_process); + wait_child_process(server_process); ok(CloseHandle(server_process), "CloseHandle\n");
ok(RPC_S_OK == RpcStringFreeA(&binding), "RpcStringFree\n"); diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c index f3a634dc298..4c9b9693983 100644 --- a/dlls/shell32/tests/shellpath.c +++ b/dlls/shell32/tests/shellpath.c @@ -1786,7 +1786,7 @@ static void test_NonExistentPath(void) startup.wShowWindow = SW_SHOWNORMAL; CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0L, NULL, NULL, &startup, &info); - winetest_wait_child_process( info.hProcess ); + wait_child_process( info.hProcess );
/* restore original values: */ trace("Restoring CSIDL_FAVORITES to %s\n", originalPath); diff --git a/dlls/shlwapi/tests/ordinal.c b/dlls/shlwapi/tests/ordinal.c index f1527eb6b83..8c5e3e261e2 100644 --- a/dlls/shlwapi/tests/ordinal.c +++ b/dlls/shlwapi/tests/ordinal.c @@ -481,7 +481,7 @@ static void test_alloc_shared(int argc, char **argv) ok(ret, "could not create child process error: %u\n", GetLastError()); if (ret) { - winetest_wait_child_process(pi.hProcess); + wait_child_process(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(pi.hProcess);
diff --git a/dlls/sxs/tests/sxs.c b/dlls/sxs/tests/sxs.c index eb54c6fa1d4..6b1a9952f36 100644 --- a/dlls/sxs/tests/sxs.c +++ b/dlls/sxs/tests/sxs.c @@ -192,7 +192,7 @@ static void run_child_process(void) ret = CreateProcessA(exe, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %u\n", GetLastError());
- winetest_wait_child_process(pi.hProcess); + wait_child_process(pi.hProcess);
CloseHandle(pi.hThread); CloseHandle(pi.hProcess); diff --git a/dlls/ucrtbase/tests/misc.c b/dlls/ucrtbase/tests/misc.c index 79f3dc9af8c..ada3a52eb64 100644 --- a/dlls/ucrtbase/tests/misc.c +++ b/dlls/ucrtbase/tests/misc.c @@ -476,7 +476,7 @@ static void test__get_narrow_winmain_command_line(char *path) CreateProcessA(path, cmd, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE|NORMAL_PRIORITY_CLASS, NULL, NULL, &startup, &proc); - winetest_wait_child_process(proc.hProcess); + wait_child_process(proc.hProcess); CloseHandle(proc.hProcess); CloseHandle(proc.hThread); } diff --git a/dlls/urlmon/tests/misc.c b/dlls/urlmon/tests/misc.c index 4c5c6aea10b..abe77ac7eaf 100644 --- a/dlls/urlmon/tests/misc.c +++ b/dlls/urlmon/tests/misc.c @@ -1916,7 +1916,7 @@ static void test_internet_features(void) { sprintf(cmdline, ""%s" %s internet_features", argv[0], argv[1]); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Could not create process: %u\n", GetLastError()); - winetest_wait_child_process( pi.hProcess ); + wait_child_process( pi.hProcess ); CloseHandle(pi.hThread); CloseHandle(pi.hProcess);
diff --git a/dlls/urlmon/tests/sec_mgr.c b/dlls/urlmon/tests/sec_mgr.c index 54dc67bdeed..0577af4ecc9 100644 --- a/dlls/urlmon/tests/sec_mgr.c +++ b/dlls/urlmon/tests/sec_mgr.c @@ -848,7 +848,7 @@ static void run_child_process(void) sprintf(cmdline, ""%s" %s domain_tests", argv[0], argv[1]); ret = CreateProcessA(argv[0], cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi); ok(ret, "Failed to spawn child process: %u\n", GetLastError()); - winetest_wait_child_process(pi.hProcess); + wait_child_process(pi.hProcess); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); } diff --git a/dlls/user32/tests/class.c b/dlls/user32/tests/class.c index 51bc1169081..606a29a257f 100644 --- a/dlls/user32/tests/class.c +++ b/dlls/user32/tests/class.c @@ -1280,7 +1280,7 @@ static void test_comctl32_classes(void) sprintf( path_name, "%s class %s", argv[0], classes[i] ); ok( CreateProcessA( NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ), "CreateProcess failed.\n" ); - winetest_wait_child_process( info.hProcess ); + wait_child_process( info.hProcess ); CloseHandle( info.hProcess ); CloseHandle( info.hThread ); } diff --git a/dlls/user32/tests/clipboard.c b/dlls/user32/tests/clipboard.c index df23bb28946..6fc4325e985 100644 --- a/dlls/user32/tests/clipboard.c +++ b/dlls/user32/tests/clipboard.c @@ -171,7 +171,7 @@ static void run_process( const char *args ) ok( CreateProcessA( NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info ), "CreateProcess %s failed\n", cmd );
- winetest_wait_child_process( info.hProcess ); + wait_child_process( info.hProcess ); CloseHandle( info.hProcess ); CloseHandle( info.hThread ); } diff --git a/dlls/user32/tests/cursoricon.c b/dlls/user32/tests/cursoricon.c index 7a5f9551615..ff4ab5d8755 100644 --- a/dlls/user32/tests/cursoricon.c +++ b/dlls/user32/tests/cursoricon.c @@ -446,7 +446,7 @@ static void do_parent(void) static void finish_child_process(void) { SendMessageA(child, WM_CLOSE, 0, 0); - winetest_wait_child_process( child_process ); + wait_child_process( child_process ); CloseHandle(child_process); }
diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 423157b623d..303a026cda1 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -16305,7 +16305,7 @@ static void test_WaitForInputIdle( char *argv0 ) WaitForSingleObject( pi.hProcess, 1000 ); /* give it a chance to exit on its own */ } TerminateProcess( pi.hProcess, 0 ); /* just in case */ - winetest_wait_child_process( pi.hProcess ); + wait_child_process( pi.hProcess ); ret = WaitForInputIdle( pi.hProcess, 100 ); ok( ret == WAIT_FAILED, "%u: WaitForInputIdle after exit error %08x\n", i, ret ); CloseHandle( pi.hProcess ); diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 0f683f858a1..56072bebf71 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -9451,7 +9451,7 @@ static void test_window_from_point(const char *argv0) ok(win == child, "WindowFromPoint returned %p, expected %p\n", win, child);
SetEvent(end_event); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(start_event); CloseHandle(end_event); CloseHandle(info.hProcess); @@ -10302,7 +10302,7 @@ static void test_winproc_handles(const char *argv0) startup.cb = sizeof(startup); ok(CreateProcessA(NULL, cmd, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), "CreateProcess failed.\n"); - winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(info.hProcess); CloseHandle(info.hThread); } @@ -11825,7 +11825,7 @@ static void test_other_process_window(const char *argv0) ret = WaitForSingleObject(test_done_event, 5000); ok(ret == WAIT_OBJECT_0, "Unexpected ret %x.\n", ret);
- winetest_wait_child_process(info.hProcess); + wait_child_process(info.hProcess); CloseHandle(window_ready_event); CloseHandle(test_done_event); CloseHandle(info.hProcess); diff --git a/include/wine/test.h b/include/wine/test.h index 3af3ffd2a91..1bf178339fd 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -110,12 +110,14 @@ extern void __winetest_cdecl winetest_trace( const char *msg, ... ) __WINE_PRINT # define skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_skip # define win_skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_win_skip # define trace_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_trace +# define wait_process_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_wait_process #else # define subtest_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_subtest # define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok # define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip # define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip # define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace +# define wait_child_process_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_wait_child_process #endif
#define subtest subtest_(__FILE__, __LINE__) @@ -123,6 +125,7 @@ extern void __winetest_cdecl winetest_trace( const char *msg, ... ) __WINE_PRINT #define skip skip_(__FILE__, __LINE__) #define win_skip win_skip_(__FILE__, __LINE__) #define trace trace_(__FILE__, __LINE__) +#define wait_child_process wait_child_process_(__FILE__, __LINE__)
#define todo_if(is_todo) for (winetest_start_todo(is_todo); \ winetest_loop_todo(); \ @@ -477,24 +480,33 @@ void winetest_add_failures( LONG new_failures )
void winetest_wait_child_process( HANDLE process ) { - DWORD exit_code = 1; + DWORD ret;
- if (WaitForSingleObject( process, 30000 )) - printf( "%s: child process wait failed\n", current_test->name ); - else - GetExitCodeProcess( process, &exit_code ); + winetest_ok( process != NULL, "No child process handle (CreateProcess failed?)\n" ); + if (!process) return;
- if (exit_code) + ret = WaitForSingleObject( process, 30000 ); + if (ret == WAIT_TIMEOUT) + winetest_ok( 0, "Timed out waiting for the child process\n" ); + else if (ret != WAIT_OBJECT_0) + winetest_ok( 0, "Could not wait for the child process: %d le=%u\n", + ret, GetLastError() ); + else { + DWORD exit_code; + struct tls_data *data = get_tls_data(); + GetExitCodeProcess( process, &exit_code ); if (exit_code > 255) { - printf( "%s: exception 0x%08x in child process\n", current_test->name, exit_code ); + DWORD pid = GetProcessId( process ); + printf( "%s:%d: unhandled exception %08x in child process %04x\n", + current_test->name, data->current_line, exit_code, pid ); InterlockedIncrement( &failures ); } - else + else if (exit_code) { - printf( "%s: %u failures in child process\n", - current_test->name, exit_code ); + printf( "%s:%d: %u failures in child process\n", + current_test->name, data->current_line, exit_code ); while (exit_code-- > 0) InterlockedIncrement(&failures); }