[3/3] cmd/tests: Add support for todo_wine constructions

Frédéric Delanoy frederic.delanoy at gmail.com
Fri Jun 24 08:51:21 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.
---
Fixes bug 22063

 programs/cmd/tests/batch.c |   39 +++++++++++++++++++++++++++++++--------
 1 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index 946d9d3..3dd219b 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -141,8 +141,10 @@ static inline BOOL command_found(const char *cmd_name, const char *line_ptr, con
     return (line_ptr + cmd_size <= line_end) && !strncmp(line_ptr, cmd_name, cmd_size);
 }
 
+static const char *todo_wine_cmd = "@todo_wine@";
+
 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;
@@ -151,6 +153,11 @@ static const char *compare_line(const char *out_line, const char *out_end, const
     static const char *space_cmd = "@space@";
     static const char *or_broken_cmd = "@or_broken@";
 
+    *is_todo_wine_line = command_found(todo_wine_cmd, exp_line, exp_end);
+
+    if (*is_todo_wine_line)
+        exp_ptr += strlen(todo_wine_cmd);
+
     while(exp_ptr < exp_end) {
         if(*exp_ptr == '@') {
             if(command_found(pwd_cmd, exp_ptr, exp_end)) {
@@ -204,6 +211,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++;
@@ -211,13 +219,28 @@ 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-strlen(todo_wine_cmd)), exp_ptr+strlen(todo_wine_cmd));
+        }else {
+            if (!is_todo_wine)
+                ok(!err, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
+                   (err ? *err : 0), (int)(err-out_ptr), line, (int)(out_nl-out_ptr),
+                   out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
+            else
+                todo_wine
+                ok(!err, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
+                   (err ? *err : 0), (int)(err-out_ptr), line, (int)(out_nl-out_ptr), out_ptr,
+                   (int)(exp_nl-exp_ptr-strlen(todo_wine_cmd)), exp_ptr+strlen(todo_wine_cmd));
+        }
 
         exp_ptr = exp_nl+1;
         out_ptr = out_nl+1;
-- 
1.7.5.4




More information about the wine-patches mailing list