[2/3] cmd/tests: Add support for todo_wine constructions (try 2)

Frédéric Delanoy frederic.delanoy at gmail.com
Mon Jun 13 15:19:45 CDT 2011


"@todo_wine@" can be used as a marker at the beginning of expected lines to
indicate that ok tests are to be enclosed in standard todo_wine constructs.
---
 programs/cmd/tests/batch.c |   55 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index 3c12fe7..8ee86db 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -135,8 +135,10 @@ static DWORD map_file(const char *file_name, const char **ret)
     return size;
 }
 
+static const char todo_wine_cmd[] = {'@','t','o','d','o','_','w','i','n','e','@'};
+
 static const char *compare_line(const char *out_line, const char *out_end, const char *exp_line,
-        const char *exp_end)
+        const char *exp_end, BOOL* is_todo_wine_line)
 {
     const char *out_ptr = out_line, *exp_ptr = exp_line;
     const char *err = NULL;
@@ -145,6 +147,12 @@ static const char *compare_line(const char *out_line, const char *out_end, const
     static const char space_cmd[] = {'@','s','p','a','c','e','@'};
     static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'};
 
+    *is_todo_wine_line = exp_line + sizeof(todo_wine_cmd) <= exp_end
+                         && !memcmp(exp_line, todo_wine_cmd, sizeof(todo_wine_cmd));
+
+    if (*is_todo_wine_line)
+        exp_ptr += sizeof(todo_wine_cmd);
+
     while(exp_ptr < exp_end) {
         if(*exp_ptr == '@') {
             if(exp_ptr+sizeof(pwd_cmd) <= exp_end
@@ -200,6 +208,7 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
 {
     const char *out_ptr = out_data, *exp_ptr = exp_data, *out_nl, *exp_nl, *err;
     DWORD line = 0;
+    BOOL is_todo_wine;
 
     while(out_ptr < out_data+out_size && exp_ptr < exp_data+exp_size) {
         line++;
@@ -207,14 +216,33 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
         for(exp_nl = exp_ptr; exp_nl < exp_data+exp_size && *exp_nl != '\r' && *exp_nl != '\n'; exp_nl++);
         for(out_nl = out_ptr; out_nl < out_data+out_size && *out_nl != '\r' && *out_nl != '\n'; out_nl++);
 
-        err = compare_line(out_ptr, out_nl, exp_ptr, exp_nl);
-        if(err == out_nl)
-            ok(0, "unexpected end of line %d (got '%.*s', wanted '%.*s')\n",
-               line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
-        else if(err)
-            ok(0, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
-               *err, (int)(err-out_ptr), line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
-
+        err = compare_line(out_ptr, out_nl, exp_ptr, exp_nl, &is_todo_wine);
+
+        if(err == out_nl) {
+            if (!is_todo_wine)
+                ok(0, "unexpected end of line %d (got '%.*s', wanted '%.*s')\n",
+                   line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
+            else
+                todo_wine
+                ok(0, "unexpected end of line %d (got '%.*s', wanted '%.*s')\n",
+                   line, (int)(out_nl-out_ptr), out_ptr,
+                   (int)(exp_nl-exp_ptr-sizeof(todo_wine_cmd)), exp_ptr+sizeof(todo_wine_cmd));
+        }else if(err) {
+            if (!is_todo_wine)
+                ok(0, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
+                   *err, (int)(err-out_ptr), line, (int)(out_nl-out_ptr),
+                   out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
+            else
+                todo_wine
+                ok(0, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
+                   *err, (int)(err-out_ptr), line, (int)(out_nl-out_ptr), out_ptr,
+                   (int)(exp_nl-exp_ptr-sizeof(todo_wine_cmd)), exp_ptr+sizeof(todo_wine_cmd));
+        }else {
+            if(!is_todo_wine)
+                ok(TRUE, "match at line %d\n", line);
+            else
+                todo_wine ok(TRUE, "match at line %d\n", line);
+        }
         exp_ptr = exp_nl+1;
         out_ptr = out_nl+1;
         if(out_nl+1 < out_data+out_size && out_nl[0] == '\r' && out_nl[1] == '\n')
@@ -223,8 +251,13 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
             exp_ptr++;
     }
 
-    ok(exp_ptr >= exp_data+exp_size, "unexpected end of output in line %d, missing %s\n", line, exp_ptr);
-    ok(out_ptr >= out_data+out_size, "too long output, got additional %s\n", out_ptr);
+    if(!is_todo_wine) {
+        ok(exp_ptr >= exp_data+exp_size, "unexpected end of output in line %d, missing %s\n", line, exp_ptr);
+        ok(out_ptr >= out_data+out_size, "too long output, got additional %s\n", out_ptr);
+    }else {
+        todo_wine ok(exp_ptr >= exp_data+exp_size, "unexpected end of output in line %d, missing %s\n", line, exp_ptr);
+        todo_wine ok(out_ptr >= out_data+out_size, "too long output, got additional %s\n", out_ptr);
+    }
 }
 
 static void run_test(const char *cmd_data, DWORD cmd_size, const char *exp_data, DWORD exp_size)
-- 
1.7.5.4




More information about the wine-patches mailing list