wine/test.h: Identify the process responsible for test summary lines.

Currently the child process summary lines are indistinguishable from the
main process one. This makes it impossible to automatically detect
when a process exits abruptly, i.e. without printing a summary line,
if it has run a subprocess.

This will let analysis tools identify which summary lines correspond to
processes they started and thus when some are missing.  Note also that
in case of a crash the 'unhandled exception' play the same role as the
test summary lines. Thus it is important to also tag them with the pid
of the source process.

Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Francois Gouget 2017-02-22 15:33:21 +01:00 committed by Alexandre Julliard
parent 46315d8d27
commit 873eace6e4
2 changed files with 14 additions and 8 deletions

View File

@ -590,8 +590,9 @@ static int run_test( const char *name )
if (winetest_debug)
{
printf( "%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
test->name, successes + failures + todo_successes + todo_failures,
printf( "%04x:%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
GetCurrentProcessId(), test->name,
successes + failures + todo_successes + todo_failures,
todo_successes, failures + todo_failures,
(failures + todo_failures != 1) ? "failures" : "failure",
skipped );
@ -617,7 +618,8 @@ static LONG CALLBACK exc_filter( EXCEPTION_POINTERS *ptrs )
if (data->current_file)
printf( "%s:%d: this is the last test seen before the exception\n",
data->current_file, data->current_line );
printf( "%s: unhandled exception %08x at %p\n", current_test->name,
printf( "%04x:%s: unhandled exception %08x at %p\n",
GetCurrentProcessId(), current_test->name,
ptrs->ExceptionRecord->ExceptionCode, ptrs->ExceptionRecord->ExceptionAddress );
fflush( stdout );
return EXCEPTION_EXECUTE_HANDLER;

View File

@ -609,7 +609,7 @@ static void append_path( const char *path)
value of WaitForSingleObject.
*/
static int
run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms)
run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms, DWORD* pid)
{
STARTUPINFOA si;
PROCESS_INFORMATION pi;
@ -627,9 +627,13 @@ run_ex (char *cmd, HANDLE out_file, const char *tempdir, DWORD ms)
if (!CreateProcessA (NULL, cmd, NULL, NULL, TRUE, CREATE_DEFAULT_ERROR_MODE,
NULL, tempdir, &si, &pi))
{
if (pid) *pid = 0;
return -2;
}
CloseHandle (pi.hThread);
if (pid) *pid = pi.dwProcessId;
status = wait_process( pi.hProcess, ms );
switch (status)
{
@ -713,7 +717,7 @@ get_subtests (const char *tempdir, struct wine_test *test, LPSTR res_name)
/* We need to add the path (to the main dll) to PATH */
append_path(test->maindllpath);
}
status = run_ex (cmd, subfile, tempdir, 5000);
status = run_ex (cmd, subfile, tempdir, 5000, NULL);
err = GetLastError();
if (test->maindllpath) {
/* Restore PATH again */
@ -785,13 +789,13 @@ run_test (struct wine_test* test, const char* subtest, HANDLE out_file, const ch
else
{
int status;
DWORD start = GetTickCount();
DWORD pid, start = GetTickCount();
char *cmd = strmake (NULL, "%s %s", test->exename, subtest);
report (R_STEP, "Running: %s:%s", test->name, subtest);
xprintf ("%s:%s start %s -\n", test->name, subtest, file);
status = run_ex (cmd, out_file, tempdir, 120000);
status = run_ex (cmd, out_file, tempdir, 120000, &pid);
heap_free (cmd);
xprintf ("%s:%s done (%d) in %ds\n", test->name, subtest, status, (GetTickCount()-start)/1000);
xprintf ("%s:%s:%04x done (%d) in %ds\n", test->name, subtest, pid, status, (GetTickCount()-start)/1000);
if (status) failures++;
}
if (failures) report (R_STATUS, "Running tests - %u failures", failures);