cmd/tests: Add support for todo_wine constructions (try 2)
Frédéric Delanoy
frederic.delanoy at gmail.com
Thu Jun 30 03:04:28 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.
---
Got rid of the previous char[]->char* and keyword recognition patches.
programs/cmd/tests/batch.c | 40 ++++++++++++++++++++++++++++++++--------
1 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index 3c12fe7..57c30ab 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_ptr+sizeof(todo_wine_cmd) <= exp_end)
+ && !memcmp(exp_ptr, 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,13 +216,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-sizeof(todo_wine_cmd)), exp_ptr+sizeof(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-sizeof(todo_wine_cmd)), exp_ptr+sizeof(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