[2/5] include/wine/test.h: Report child process failures using shared memory.

Dmitry Timoshkov dmitry at baikal.ru
Thu Apr 11 04:14:27 CDT 2013


Alexandre Julliard <julliard at winehq.org> wrote:

> > As far as I can see ExitProcess returns 'failures' as the child process exit
> > code, but variable 'failures' is not visible from the tests. Do you have a
> > suggestion how to fix that?
>
> You need to report the status a different way. For instance you could
> store it in a file.

How does this one look like? (In theory this approach could be used
to transfer other child process information to the parent).
---
 include/wine/test.h | 51 ++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 38 insertions(+), 13 deletions(-)

diff --git a/include/wine/test.h b/include/wine/test.h
index 401e06a..485e9b1 100644
--- a/include/wine/test.h
+++ b/include/wine/test.h
@@ -216,6 +216,8 @@ static LONG failures;        /* number of failures */
 static LONG skipped;         /* number of skipped test chunks */
 static LONG todo_successes;  /* number of successful tests inside todo block */
 static LONG todo_failures;   /* number of failures inside todo block */
+static BOOL is_child;        /* whether the test is a child process */
+static LONG *child_failures; /* number of failures in child process */
 
 /* The following data must be kept track of on a per-thread basis */
 typedef struct
@@ -333,6 +335,7 @@ int winetest_vok( int condition, const char *msg, __winetest_va_list args )
                      data->current_file, data->current_line );
             vfprintf(stdout, msg, args);
             InterlockedIncrement(&failures);
+            if (is_child) *child_failures += 1;
             return 0;
         }
         else
@@ -437,21 +440,19 @@ void winetest_wait_child_process( HANDLE process )
     else
         GetExitCodeProcess( process, &exit_code );
 
-    if (exit_code)
+    if (exit_code > 255)
     {
-        if (exit_code > 255)
-        {
-            fprintf( stdout, "%s: exception 0x%08x in child process\n", current_test->name, exit_code );
-            InterlockedIncrement( &failures );
-        }
-        else
-        {
-            fprintf( stdout, "%s: %u failures in child process\n",
-                     current_test->name, exit_code );
-            while (exit_code-- > 0)
-                InterlockedIncrement(&failures);
-        }
+        fprintf( stdout, "%s: exception 0x%08x in child process\n", current_test->name, exit_code );
+        InterlockedIncrement( &failures );
     }
+    else if (*child_failures)
+    {
+        fprintf( stdout, "%s: %d failures in child process\n",
+                 current_test->name, *child_failures );
+        while ((*child_failures)-- > 0)
+            InterlockedIncrement(&failures);
+    }
+    *child_failures = -1;
 }
 
 const char *wine_dbgstr_wn( const WCHAR *str, int n )
@@ -543,14 +544,38 @@ static void list_tests(void)
 /* Run a named test, and return exit status */
 static int run_test( const char *name )
 {
+    char test_name[MAX_PATH], *p;
     const struct test *test;
     int status;
+    HANDLE mapping;
 
     if (!(test = find_test( name )))
     {
         fprintf( stdout, "Fatal: test '%s' does not exist.\n", name );
         exit_process(1);
     }
+
+    if ((p = strrchr( name, '/' ))) name = p + 1;
+    if ((p = strrchr( name, '\\' ))) name = p + 1;
+    strcpy( test_name, "winetest_" );
+    strcat( test_name, name );
+    if ((p = strchr( test_name, '.' ))) *p = 0;
+
+    mapping = CreateFileMapping( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, 4096, test_name );
+    if (!mapping)
+    {
+        fprintf( stdout, "Fatal: CreateFileMapping(%s) failed.\n", test_name );
+        exit_process(1);
+    }
+    child_failures = MapViewOfFile( mapping, FILE_MAP_READ|FILE_MAP_WRITE, 0, 0, 4096 );
+    if (*child_failures == -1)
+    {
+        is_child = TRUE;
+        *child_failures = 0;
+    }
+    else
+        *child_failures = -1;
+
     successes = failures = todo_successes = todo_failures = 0;
     tls_index=TlsAlloc();
     current_test = test;
-- 
1.8.2.1




More information about the wine-patches mailing list