cmd: add support for todo_wine constructions in testing infrastructure
Frédéric Delanoy
frederic.delanoy at gmail.com
Sun Jun 12 16:01:37 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.
Also delete obsolete todo_space.
---
programs/cmd/tests/batch.c | 65 ++++++++++++++++++++++++++++++++-----------
1 files changed, 48 insertions(+), 17 deletions(-)
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index 0f01dbf..db60367 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -135,6 +135,16 @@ 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 BOOL is_todo_wine_line(const char *line, const char *line_end)
+{
+ if (line + sizeof(todo_wine_cmd) <= line_end
+ && !memcmp(line, todo_wine_cmd, sizeof(todo_wine_cmd)))
+ return TRUE;
+
+ return FALSE;
+}
+
static const char *compare_line(const char *out_line, const char *out_end, const char *exp_line,
const char *exp_end)
{
@@ -142,10 +152,12 @@ static const char *compare_line(const char *out_line, const char *out_end, const
const char *err = NULL;
static const char pwd_cmd[] = {'@','p','w','d','@'};
- static const char todo_space_cmd[] = {'@','t','o','d','o','_','s','p','a','c','e','@'};
static const char space_cmd[] = {'@','s','p','a','c','e','@'};
static const char or_broken_cmd[] = {'@','o','r','_','b','r','o','k','e','n','@'};
+ if(is_todo_wine_line(exp_line, exp_end))
+ exp_ptr += sizeof(todo_wine_cmd);
+
while(exp_ptr < exp_end) {
if(*exp_ptr == '@') {
if(exp_ptr+sizeof(pwd_cmd) <= exp_end
@@ -159,13 +171,6 @@ static const char *compare_line(const char *out_line, const char *out_end, const
out_ptr += workdir_len;
continue;
}
- }else if(exp_ptr+sizeof(todo_space_cmd) <= exp_end
- && !memcmp(exp_ptr, todo_space_cmd, sizeof(todo_space_cmd))) {
- exp_ptr += sizeof(todo_space_cmd);
- todo_wine ok(*out_ptr == ' ', "expected space\n");
- if(out_ptr < out_end && *out_ptr == ' ')
- out_ptr++;
- continue;
}else if(exp_ptr+sizeof(space_cmd) <= exp_end
&& !memcmp(exp_ptr, space_cmd, sizeof(space_cmd))) {
exp_ptr += sizeof(space_cmd);
@@ -208,6 +213,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 = FALSE;
while(out_ptr < out_data+out_size && exp_ptr < exp_data+exp_size) {
line++;
@@ -216,13 +222,33 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
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);
-
+ is_todo_wine = is_todo_wine_line(exp_ptr, exp_nl);
+
+ 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')
@@ -231,8 +257,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