include: Implement todo_wine_if for usage in wine tests.
Sebastian Lackner
sebastian at fds-team.de
Tue Feb 9 03:40:01 CST 2016
From: Bernhard Übelacker <bernhardu at vr-web.de>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
> Questions:
> - Should we check in winetest_vok also just for the last bit in todo_level?
No, to stay compatible with the way how it worked before, a check for != 0 is fine.
I have a couple of more suggested changes, so I'm sending here a modified version of your patch.
Changes since Bernhards last version:
* Handle todo_wine as a special case of todo_if(.).
* Get rid of warning message when exceeding nesting level of 32.
* Demonstrate usage of new functions in cmd tests.
Notes:
* todo_wine_if intentionally checks is_todo first, to avoid check-specific side effects in the tests.
include/wine/test.h | 29 ++++++++++++---------------
programs/cmd/tests/batch.c | 48 ++++++++++++++++++++++-----------------------
2 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/include/wine/test.h b/include/wine/test.h
index bed44f9..0d81a24 100644
--- a/include/wine/test.h
+++ b/include/wine/test.h
@@ -56,9 +56,9 @@ extern int winetest_interactive;
extern const char *winetest_platform;
extern void winetest_set_location( const char* file, int line );
-extern void winetest_start_todo( const char* platform );
+extern void winetest_start_todo( int is_todo );
extern int winetest_loop_todo(void);
-extern void winetest_end_todo( const char* platform );
+extern void winetest_end_todo(void);
extern int winetest_get_mainargs( char*** pargv );
extern LONG winetest_get_failures(void);
extern void winetest_add_failures( LONG new_failures );
@@ -118,10 +118,11 @@ extern void __winetest_cdecl winetest_trace( const char *msg, ... ) WINETEST_PRI
#define win_skip win_skip_(__FILE__, __LINE__)
#define trace trace_(__FILE__, __LINE__)
-#define todo(platform) for (winetest_start_todo(platform); \
- winetest_loop_todo(); \
- winetest_end_todo(platform))
-#define todo_wine todo("wine")
+#define todo_if(is_todo) for (winetest_start_todo(is_todo); \
+ winetest_loop_todo(); \
+ winetest_end_todo())
+#define todo_wine todo_if(!strcmp(winetest_platform, "wine"))
+#define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine"))
#ifdef NONAMELESSUNION
@@ -220,7 +221,7 @@ typedef struct
{
const char* current_file; /* file of current check */
int current_line; /* line of current check */
- int todo_level; /* current todo nesting level */
+ unsigned int todo_level; /* current todo nesting level */
int todo_do_loop;
char *str_pos; /* position in debug buffer */
char strings[2000]; /* buffer for debug strings */
@@ -395,11 +396,10 @@ void __winetest_cdecl winetest_win_skip( const char *msg, ... )
__winetest_va_end(valist);
}
-void winetest_start_todo( const char* platform )
+void winetest_start_todo( int is_todo )
{
tls_data* data=get_tls_data();
- if (strcmp(winetest_platform,platform)==0)
- data->todo_level++;
+ data->todo_level = (data->todo_level << 1) | (is_todo != 0);
data->todo_do_loop=1;
}
@@ -411,13 +411,10 @@ int winetest_loop_todo(void)
return do_loop;
}
-void winetest_end_todo( const char* platform )
+void winetest_end_todo(void)
{
- if (strcmp(winetest_platform,platform)==0)
- {
- tls_data* data=get_tls_data();
- data->todo_level--;
- }
+ tls_data* data=get_tls_data();
+ data->todo_level >>= 1;
}
int winetest_get_mainargs( char*** pargv )
diff --git a/programs/cmd/tests/batch.c b/programs/cmd/tests/batch.c
index 9b54089..ea2cf65 100644
--- a/programs/cmd/tests/batch.c
+++ b/programs/cmd/tests/batch.c
@@ -287,32 +287,32 @@ static void test_output(const char *out_data, DWORD out_size, const char *exp_da
is_todo_wine = (exp_ptr+sizeof(todo_wine_cmd) <= exp_nl &&
!memcmp(exp_ptr, todo_wine_cmd, sizeof(todo_wine_cmd)));
- if (is_todo_wine) {
+ if (is_todo_wine)
exp_ptr += sizeof(todo_wine_cmd);
- winetest_start_todo("wine");
- }
- is_exp_resync=(exp_ptr+sizeof(resync_cmd) <= exp_nl &&
- !memcmp(exp_ptr, resync_cmd, sizeof(resync_cmd)));
- is_out_resync=(out_ptr+sizeof(resync_cmd) <= out_nl &&
- !memcmp(out_ptr, resync_cmd, sizeof(resync_cmd)));
-
- 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 == exp_nl)
- ok(0, "excess characters on 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 && is_todo_wine && is_out_resync && is_exp_resync)
- /* Consider that the todo_wine was to deal with extra lines,
- * not for the resync line itself
- */
- err = NULL;
- else
- ok(!err, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
- (err ? *err : 0), (err ? (int)(err-out_ptr) : -1), line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
- if(is_todo_wine) winetest_end_todo("wine");
+ todo_wine_if(is_todo_wine)
+ {
+ is_exp_resync=(exp_ptr+sizeof(resync_cmd) <= exp_nl &&
+ !memcmp(exp_ptr, resync_cmd, sizeof(resync_cmd)));
+ is_out_resync=(out_ptr+sizeof(resync_cmd) <= out_nl &&
+ !memcmp(out_ptr, resync_cmd, sizeof(resync_cmd)));
+
+ 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 == exp_nl)
+ ok(0, "excess characters on 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 && is_todo_wine && is_out_resync && is_exp_resync)
+ /* Consider that the todo_wine was to deal with extra lines,
+ * not for the resync line itself
+ */
+ err = NULL;
+ else
+ ok(!err, "unexpected char 0x%x position %d in line %d (got '%.*s', wanted '%.*s')\n",
+ (err ? *err : 0), (err ? (int)(err-out_ptr) : -1), line, (int)(out_nl-out_ptr), out_ptr, (int)(exp_nl-exp_ptr), exp_ptr);
+ }
if (is_exp_resync && err && is_todo_wine)
{
--
2.7.0
More information about the wine-patches
mailing list