-- v2: dinput: Get rid of duplicated winetest helpers. include: Avoid using strcmp directly in wine/test.h. include: Introduce winetest wrappers for vprintf and GetTickCount. include: Pass a temporary buffer to winetest_elapsed. include: Rename winetest_printf to winetest_print_location. include: Initialize winetest global counters to 0.
From: Rémi Bernon rbernon@codeweavers.com
Fixes: ef3e97dbc2176d8de5a078b50a8dd1ddfaa3cb2e --- include/wine/test.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/wine/test.h b/include/wine/test.h index 723d23cfc02..b5baece987c 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -515,7 +515,7 @@ int winetest_report_success = 0; int winetest_mute_threshold = 42;
/* use ANSI escape codes for output coloring */ -int winetest_color; +int winetest_color = 0;
static HANDLE winetest_mutex;
@@ -525,15 +525,15 @@ static char** winetest_argv;
static const struct test *current_test; /* test currently being run */
-LONG winetest_successes; /* number of successful tests */ -LONG winetest_failures; /* number of failures */ -LONG winetest_flaky_failures; /* number of failures inside flaky block */ -LONG winetest_skipped; /* number of skipped test chunks */ -LONG winetest_todo_successes; /* number of successful tests inside todo block */ -LONG winetest_todo_failures; /* number of failures inside todo block */ -LONG winetest_muted_traces; /* number of silenced traces */ -LONG winetest_muted_skipped; /* same as skipped but silent */ -LONG winetest_muted_todo_successes; /* same as todo_successes but silent */ +LONG winetest_successes = 0; /* number of successful tests */ +LONG winetest_failures = 0; /* number of failures */ +LONG winetest_flaky_failures = 0; /* number of failures inside flaky block */ +LONG winetest_skipped = 0; /* number of skipped test chunks */ +LONG winetest_todo_successes = 0; /* number of successful tests inside todo block */ +LONG winetest_todo_failures = 0; /* number of failures inside todo block */ +LONG winetest_muted_traces = 0; /* number of silenced traces */ +LONG winetest_muted_skipped = 0; /* same as skipped but silent */ +LONG winetest_muted_todo_successes = 0; /* same as todo_successes but silent */
static DWORD tls_index;
From: Rémi Bernon rbernon@codeweavers.com
--- include/wine/test.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/include/wine/test.h b/include/wine/test.h index b5baece987c..e47c795ac82 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -168,8 +168,8 @@ static const char winetest_color_blue[] = "\x1b[34m"; static const char winetest_color_bright_red[] = "\x1b[1;91m"; static const char winetest_color_bright_purple[] = "\x1b[1;95m";
-static void winetest_printf( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2); -static void winetest_printf( const char *msg, ... ) +static void winetest_print_location( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2); +static void winetest_print_location( const char *msg, ... ) { struct winetest_thread_data *data = winetest_get_thread_data(); va_list valist; @@ -185,7 +185,7 @@ static void winetest_print_context( const char *msgtype ) struct winetest_thread_data *data = winetest_get_thread_data(); unsigned int i;
- winetest_printf( "%s", msgtype ); + winetest_print_location( "%s", msgtype ); for (i = 0; i < data->context_count; ++i) printf( "%s: ", data->context[i] ); } @@ -193,14 +193,14 @@ static void winetest_print_context( const char *msgtype ) static inline void winetest_subtest( const char *name ) { winetest_print_lock(); - winetest_printf( "Subtest %s\n", name ); + winetest_print_location( "Subtest %s\n", name ); winetest_print_unlock(); }
static inline void winetest_ignore_exceptions( BOOL ignore ) { winetest_print_lock(); - winetest_printf( "IgnoreExceptions=%d\n", ignore ? 1 : 0 ); + winetest_print_location( "IgnoreExceptions=%d\n", ignore ? 1 : 0 ); winetest_print_unlock(); }
@@ -226,7 +226,7 @@ static LONG winetest_add_line( void ) if (count == winetest_mute_threshold) { winetest_print_lock(); - winetest_printf( "Line has been silenced after %d occurrences\n", winetest_mute_threshold ); + winetest_print_location( "Line has been silenced after %d occurrences\n", winetest_mute_threshold ); winetest_print_unlock(); }
@@ -320,7 +320,7 @@ static int winetest_vok( int condition, const char *msg, va_list args ) { winetest_print_lock(); if (winetest_color) printf( winetest_color_green ); - winetest_printf("Test succeeded\n"); + winetest_print_location("Test succeeded\n"); if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); } @@ -577,7 +577,7 @@ void winetest_print_lock(void) ret = WaitForSingleObject( winetest_mutex, 30000 ); if (ret != WAIT_OBJECT_0 && ret != WAIT_ABANDONED) { - winetest_printf( "could not get the print lock: %u\n", ret ); + winetest_print_location( "could not get the print lock: %u\n", ret ); winetest_mutex = 0; } } @@ -615,7 +615,7 @@ void winetest_wait_child_process( HANDLE process ) DWORD pid = GetProcessId( process ); winetest_print_lock(); if (winetest_color) printf( winetest_color_bright_red ); - winetest_printf( "unhandled exception %08x in child process %04x\n", (UINT)exit_code, (UINT)pid ); + winetest_print_location( "unhandled exception %08x in child process %04x\n", (UINT)exit_code, (UINT)pid ); if (winetest_color) printf( winetest_color_reset ); winetest_print_unlock(); InterlockedIncrement( &winetest_failures ); @@ -623,7 +623,7 @@ void winetest_wait_child_process( HANDLE process ) else if (exit_code) { winetest_print_lock(); - winetest_printf( "%u failures in child process\n", (UINT)exit_code ); + winetest_print_location( "%u failures in child process\n", (UINT)exit_code ); winetest_print_unlock(); while (exit_code-- > 0) InterlockedIncrement( &winetest_failures ); }
From: Rémi Bernon rbernon@codeweavers.com
Using wine_dbg_sprintf pulls various things that are not available in the driver tests. --- include/wine/test.h | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/include/wine/test.h b/include/wine/test.h index e47c795ac82..1ae759afcf6 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -88,7 +88,6 @@ struct winetest_thread_data extern struct winetest_thread_data *winetest_get_thread_data(void); extern void winetest_print_lock(void); extern void winetest_print_unlock(void); -extern const char *winetest_elapsed(void);
extern int winetest_get_mainargs( char*** pargv ); extern void winetest_wait_child_process( HANDLE process ); @@ -168,13 +167,24 @@ static const char winetest_color_blue[] = "\x1b[34m"; static const char winetest_color_bright_red[] = "\x1b[1;91m"; static const char winetest_color_bright_purple[] = "\x1b[1;95m";
+static const char *winetest_elapsed( char *buffer ) +{ + DWORD now; + + if (!winetest_time) return ""; + winetest_last_time = now = GetTickCount(); + sprintf( buffer, "%.3f", (now - winetest_start_time) / 1000.0 ); + return buffer; +} + static void winetest_print_location( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2); static void winetest_print_location( const char *msg, ... ) { struct winetest_thread_data *data = winetest_get_thread_data(); + char elapsed[64]; va_list valist;
- printf( "%s:%d:%s ", data->current_file, data->current_line, winetest_elapsed() ); + printf( "%s:%d:%s ", data->current_file, data->current_line, winetest_elapsed( elapsed ) ); va_start( valist, msg ); vprintf( msg, valist ); va_end( valist ); @@ -560,15 +570,6 @@ static void exit_process( int code ) ExitProcess( code ); }
-const char *winetest_elapsed(void) -{ - DWORD now; - - if (!winetest_time) return ""; - winetest_last_time = now = GetTickCount(); - return wine_dbg_sprintf( "%.3f", (now - winetest_start_time) / 1000.0); -} - void winetest_print_lock(void) { UINT ret; @@ -678,13 +679,15 @@ static int run_test( const char *name )
if (winetest_debug) { + char elapsed[64]; + winetest_print_lock(); if (winetest_muted_todo_successes || winetest_muted_skipped || winetest_muted_traces) printf( "%04x:%s:%s Silenced %d todos, %d skips and %d traces.\n", - (UINT)GetCurrentProcessId(), test->name, winetest_elapsed(), + (UINT)GetCurrentProcessId(), test->name, winetest_elapsed( elapsed ), (UINT)winetest_muted_todo_successes, (UINT)winetest_muted_skipped, (UINT)winetest_muted_traces); printf( "%04x:%s:%s %d tests executed (%d marked as todo, %d as flaky, %d %s), %d skipped.\n", - (UINT)GetCurrentProcessId(), test->name, winetest_elapsed(), + (UINT)GetCurrentProcessId(), test->name, winetest_elapsed( elapsed ), (UINT)(winetest_successes + winetest_failures + winetest_flaky_failures + winetest_todo_successes + winetest_todo_failures), (UINT)winetest_todo_successes, (UINT)winetest_flaky_failures, (UINT)(winetest_failures + winetest_todo_failures), (winetest_failures + winetest_todo_failures != 1) ? "failures" : "failure", @@ -710,6 +713,7 @@ static void usage( const char *argv0 ) static LONG CALLBACK exc_filter( EXCEPTION_POINTERS *ptrs ) { struct winetest_thread_data *data = winetest_get_thread_data(); + char elapsed[64];
winetest_print_lock(); if (data->current_file) @@ -717,7 +721,7 @@ static LONG CALLBACK exc_filter( EXCEPTION_POINTERS *ptrs ) data->current_file, data->current_line ); if (winetest_color) printf( winetest_color_bright_red ); printf( "%04x:%s:%s unhandled exception %08x at %p\n", - (UINT)GetCurrentProcessId(), current_test->name, winetest_elapsed(), + (UINT)GetCurrentProcessId(), current_test->name, winetest_elapsed( elapsed ), (UINT)ptrs->ExceptionRecord->ExceptionCode, ptrs->ExceptionRecord->ExceptionAddress ); if (winetest_color) printf( winetest_color_reset ); fflush( stdout );
From: Rémi Bernon rbernon@codeweavers.com
--- include/wine/test.h | 85 +++++++++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 30 deletions(-)
diff --git a/include/wine/test.h b/include/wine/test.h index 1ae759afcf6..ec6dcb0a02a 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -40,7 +40,7 @@ extern int winetest_debug;
/* trace timing information */ extern int winetest_time; -extern DWORD winetest_start_time, winetest_last_time; +extern int winetest_start_time, winetest_last_time;
/* running in interactive mode? */ extern int winetest_interactive; @@ -88,6 +88,8 @@ struct winetest_thread_data extern struct winetest_thread_data *winetest_get_thread_data(void); extern void winetest_print_lock(void); extern void winetest_print_unlock(void); +extern int winetest_vprintf( const char *msg, va_list args ); +extern int winetest_get_time(void);
extern int winetest_get_mainargs( char*** pargv ); extern void winetest_wait_child_process( HANDLE process ); @@ -167,12 +169,25 @@ static const char winetest_color_blue[] = "\x1b[34m"; static const char winetest_color_bright_red[] = "\x1b[1;91m"; static const char winetest_color_bright_purple[] = "\x1b[1;95m";
+static int winetest_printf( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2); +static int winetest_printf( const char *msg, ... ) +{ + va_list valist; + int ret; + + va_start( valist, msg ); + ret = winetest_vprintf( msg, valist ); + va_end( valist ); + + return ret; +} + static const char *winetest_elapsed( char *buffer ) { - DWORD now; + int now;
if (!winetest_time) return ""; - winetest_last_time = now = GetTickCount(); + winetest_last_time = now = winetest_get_time(); sprintf( buffer, "%.3f", (now - winetest_start_time) / 1000.0 ); return buffer; } @@ -184,9 +199,9 @@ static void winetest_print_location( const char *msg, ... ) char elapsed[64]; va_list valist;
- printf( "%s:%d:%s ", data->current_file, data->current_line, winetest_elapsed( elapsed ) ); + winetest_printf( "%s:%d:%s ", data->current_file, data->current_line, winetest_elapsed( elapsed ) ); va_start( valist, msg ); - vprintf( msg, valist ); + winetest_vprintf( msg, valist ); va_end( valist ); }
@@ -197,7 +212,7 @@ static void winetest_print_context( const char *msgtype )
winetest_print_location( "%s", msgtype ); for (i = 0; i < data->context_count; ++i) - printf( "%s: ", data->context[i] ); + winetest_printf( "%s: ", data->context[i] ); }
static inline void winetest_subtest( const char *name ) @@ -264,19 +279,19 @@ static int winetest_vok( int condition, const char *msg, va_list args ) winetest_print_lock(); if (data->flaky_level) { - if (winetest_color) printf( winetest_color_dark_purple ); + if (winetest_color) winetest_printf( winetest_color_dark_purple ); winetest_print_context( "Test succeeded inside flaky todo block: " ); - vprintf(msg, args); + winetest_vprintf( msg, args ); InterlockedIncrement( &winetest_flaky_failures ); } else { - if (winetest_color) printf( winetest_color_dark_red ); + if (winetest_color) winetest_printf( winetest_color_dark_red ); winetest_print_context( "Test succeeded inside todo block: " ); - vprintf(msg, args); + winetest_vprintf( msg, args ); InterlockedIncrement( &winetest_todo_failures ); } - if (winetest_color) printf( winetest_color_reset ); + if (winetest_color) winetest_printf( winetest_color_reset ); winetest_print_unlock(); return 0; } @@ -288,10 +303,10 @@ static int winetest_vok( int condition, const char *msg, va_list args ) if (winetest_debug > 0) { winetest_print_lock(); - if (winetest_color) printf( winetest_color_yellow ); + if (winetest_color) winetest_printf( winetest_color_yellow ); winetest_print_context( "Test marked todo: " ); - vprintf(msg, args); - if (winetest_color) printf( winetest_color_reset ); + winetest_vprintf( msg, args ); + if (winetest_color) winetest_printf( winetest_color_reset ); winetest_print_unlock(); } InterlockedIncrement( &winetest_todo_successes ); @@ -307,31 +322,31 @@ static int winetest_vok( int condition, const char *msg, va_list args ) winetest_print_lock(); if (data->flaky_level) { - if (winetest_color) printf( winetest_color_bright_purple ); + if (winetest_color) winetest_printf( winetest_color_bright_purple ); winetest_print_context( "Test marked flaky: " ); - vprintf(msg, args); + winetest_vprintf( msg, args ); InterlockedIncrement( &winetest_flaky_failures ); } else { - if (winetest_color) printf( winetest_color_bright_red ); + if (winetest_color) winetest_printf( winetest_color_bright_red ); winetest_print_context( "Test failed: " ); - vprintf(msg, args); + winetest_vprintf( msg, args ); InterlockedIncrement( &winetest_failures ); } - if (winetest_color) printf( winetest_color_reset ); + if (winetest_color) winetest_printf( winetest_color_reset ); winetest_print_unlock(); return 0; } else { if (winetest_report_success || - (winetest_time && GetTickCount() >= winetest_last_time + 1000)) + (winetest_time && winetest_get_time() >= winetest_last_time + 1000)) { winetest_print_lock(); - if (winetest_color) printf( winetest_color_green ); + if (winetest_color) winetest_printf( winetest_color_green ); winetest_print_location("Test succeeded\n"); - if (winetest_color) printf( winetest_color_reset ); + if (winetest_color) winetest_printf( winetest_color_reset ); winetest_print_unlock(); } InterlockedIncrement( &winetest_successes ); @@ -362,7 +377,7 @@ static inline void winetest_trace( const char *msg, ... ) winetest_print_lock(); winetest_print_context( "" ); va_start(valist, msg); - vprintf( msg, valist ); + winetest_vprintf( msg, valist ); va_end(valist); winetest_print_unlock(); } @@ -374,10 +389,10 @@ static void winetest_vskip( const char *msg, va_list args ) if (winetest_add_line() < winetest_mute_threshold) { winetest_print_lock(); - if (winetest_color) printf( winetest_color_blue ); + if (winetest_color) winetest_printf( winetest_color_blue ); winetest_print_context( "Tests skipped: " ); - vprintf(msg, args); - if (winetest_color) printf( winetest_color_reset ); + winetest_vprintf( msg, args ); + if (winetest_color) winetest_printf( winetest_color_reset ); winetest_print_unlock(); InterlockedIncrement( &winetest_skipped ); } @@ -507,7 +522,7 @@ int winetest_debug = 1;
/* trace timing information */ int winetest_time = 0; -DWORD winetest_start_time, winetest_last_time; +int winetest_start_time, winetest_last_time;
/* interactive mode? */ int winetest_interactive = 0; @@ -588,6 +603,16 @@ void winetest_print_unlock(void) if (winetest_mutex) ReleaseMutex( winetest_mutex ); }
+int winetest_vprintf( const char *msg, va_list args ) +{ + return vprintf( msg, args ); +} + +int winetest_get_time(void) +{ + return GetTickCount(); +} + int winetest_get_mainargs( char ***pargv ) { *pargv = winetest_argv; @@ -615,9 +640,9 @@ void winetest_wait_child_process( HANDLE process ) { DWORD pid = GetProcessId( process ); winetest_print_lock(); - if (winetest_color) printf( winetest_color_bright_red ); + if (winetest_color) winetest_printf( winetest_color_bright_red ); winetest_print_location( "unhandled exception %08x in child process %04x\n", (UINT)exit_code, (UINT)pid ); - if (winetest_color) printf( winetest_color_reset ); + if (winetest_color) winetest_printf( winetest_color_reset ); winetest_print_unlock(); InterlockedIncrement( &winetest_failures ); } @@ -777,7 +802,7 @@ int main( int argc, char **argv ) if (GetEnvironmentVariableA( "WINETEST_REPORT_FLAKY", p, sizeof(p) )) winetest_report_flaky = atoi(p); if (GetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", p, sizeof(p) )) winetest_report_success = atoi(p); if (GetEnvironmentVariableA( "WINETEST_TIME", p, sizeof(p) )) winetest_time = atoi(p); - winetest_last_time = winetest_start_time = GetTickCount(); + winetest_last_time = winetest_start_time = winetest_get_time();
if (!strcmp( winetest_platform, "windows" )) SetUnhandledExceptionFilter( exc_filter ); if (!winetest_interactive) SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX );
From: Rémi Bernon rbernon@codeweavers.com
It's not available in kernel driver code. --- include/wine/test.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/wine/test.h b/include/wine/test.h index ec6dcb0a02a..889923afacc 100644 --- a/include/wine/test.h +++ b/include/wine/test.h @@ -56,6 +56,7 @@ extern int winetest_mute_threshold;
/* current platform */ extern const char *winetest_platform; +extern int winetest_platform_is_wine;
/* use ANSI escape codes for output coloring */ extern int winetest_color; @@ -133,14 +134,14 @@ extern void winetest_wait_child_process( HANDLE process ); winetest_loop_flaky(); \ winetest_end_flaky()) #define flaky flaky_if(TRUE) -#define flaky_wine flaky_if(!strcmp(winetest_platform, "wine")) -#define flaky_wine_if(is_flaky) flaky_if((is_flaky) && !strcmp(winetest_platform, "wine")) +#define flaky_wine flaky_if(winetest_platform_is_wine) +#define flaky_wine_if(is_flaky) flaky_if((is_flaky) && winetest_platform_is_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")) +#define todo_wine todo_if(winetest_platform_is_wine) +#define todo_wine_if(is_todo) todo_if((is_todo) && winetest_platform_is_wine)
#ifndef ARRAY_SIZE @@ -231,7 +232,7 @@ static inline void winetest_ignore_exceptions( BOOL ignore )
static inline int broken( int condition ) { - return (strcmp(winetest_platform, "windows") == 0) && condition; + return !winetest_platform_is_wine && condition; }
static LONG winetest_add_line( void ) @@ -413,7 +414,7 @@ static inline void winetest_win_skip( const char *msg, ... ) { va_list valist; va_start(valist, msg); - if (strcmp(winetest_platform, "windows") == 0) + if (!winetest_platform_is_wine) winetest_vskip(msg, valist); else winetest_vok(0, msg, valist); @@ -529,6 +530,7 @@ int winetest_interactive = 0;
/* current platform */ const char *winetest_platform = "windows"; +int winetest_platform_is_wine = 0;
/* report failed flaky tests as failures (BOOL) */ int winetest_report_flaky = 0; @@ -781,6 +783,7 @@ int main( int argc, char **argv ) winetest_platform = strdup(p); else if (running_under_wine()) winetest_platform = "wine"; + winetest_platform_is_wine = !strcmp( winetest_platform, "wine" );
if (GetEnvironmentVariableA( "WINETEST_COLOR", p, sizeof(p) )) {
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/dinput/tests/dinput_test.h | 2 - dlls/dinput/tests/driver_bus.c | 7 +- dlls/dinput/tests/driver_hid.c | 1 + dlls/dinput/tests/driver_hid.h | 345 +++++----------------------- dlls/dinput/tests/driver_hid_poll.c | 1 + 5 files changed, 64 insertions(+), 292 deletions(-)
diff --git a/dlls/dinput/tests/dinput_test.h b/dlls/dinput/tests/dinput_test.h index e25314f6224..a4a133e6384 100644 --- a/dlls/dinput/tests/dinput_test.h +++ b/dlls/dinput/tests/dinput_test.h @@ -39,8 +39,6 @@ #include "ddk/hidsdi.h" #include "ddk/hidport.h"
-#include "wine/test.h" - #include "driver_hid.h"
#define EXPECT_VIDPID MAKELONG( 0x1209, 0x0001 ) diff --git a/dlls/dinput/tests/driver_bus.c b/dlls/dinput/tests/driver_bus.c index a95ee569c1b..44a14798337 100644 --- a/dlls/dinput/tests/driver_bus.c +++ b/dlls/dinput/tests/driver_bus.c @@ -33,6 +33,7 @@
#include "wine/list.h"
+#define WINE_DRIVER_TEST #include "initguid.h" #include "driver_hid.h"
@@ -246,8 +247,8 @@ static void expect_queue_next( struct expect_queue *queue, ULONG code, HID_XFER_ tmp = queue->pos; while (tmp < queue->end) { - if (running_under_wine && !tmp->todo) break; - if (!running_under_wine && !tmp->broken && !tmp->wine_only) break; + if (winetest_platform_is_wine && !tmp->todo) break; + if (!winetest_platform_is_wine && !tmp->broken && !tmp->wine_only) break; if (tmp->code == code && tmp->report_id == id && tmp->report_len == len && (!compare_buf || RtlCompareMemory( tmp->report_buf, buf, len ) == len)) break; @@ -260,7 +261,7 @@ static void expect_queue_next( struct expect_queue *queue, ULONG code, HID_XFER_
while (queue->pos < queue->end) { - if (running_under_wine || !queue->pos->wine_only) break; + if (winetest_platform_is_wine || !queue->pos->wine_only) break; queue->pos++; }
diff --git a/dlls/dinput/tests/driver_hid.c b/dlls/dinput/tests/driver_hid.c index 9222c4b8f18..8f015eb5ddf 100644 --- a/dlls/dinput/tests/driver_hid.c +++ b/dlls/dinput/tests/driver_hid.c @@ -32,6 +32,7 @@
#include "wine/list.h"
+#define WINE_DRIVER_TEST #include "initguid.h" #include "driver_hid.h"
diff --git a/dlls/dinput/tests/driver_hid.h b/dlls/dinput/tests/driver_hid.h index e97b4e3493b..291cf8963c2 100644 --- a/dlls/dinput/tests/driver_hid.h +++ b/dlls/dinput/tests/driver_hid.h @@ -39,6 +39,8 @@ #include "ddk/hidport.h" #include "ddk/hidclass.h"
+#include "wine/test.h" + DEFINE_GUID(control_class,0xdeadbeef,0x29ef,0x4538,0xa5,0xfd,0xb6,0x95,0x73,0xa3,0x62,0xc0);
#define IOCTL_WINETEST_HID_SET_EXPECT CTL_CODE(FILE_DEVICE_KEYBOARD, 0x800, METHOD_IN_DIRECT, FILE_ANY_ACCESS) @@ -175,89 +177,75 @@ static inline const char *debugstr_ioctl( ULONG code ) } }
-#ifndef __WINE_WINE_TEST_H - -#ifdef __MINGW32__ -#define __WINE_PRINTF_ATTR( fmt, args ) __attribute__((format( printf, fmt, args ))) -#else -#define __WINE_PRINTF_ATTR( fmt, args ) -#endif +#ifdef WINE_DRIVER_TEST
static HANDLE okfile; -static LONG successes; -static LONG failures; -static LONG skipped; -static LONG todo_successes; -static LONG todo_failures; -static LONG muted_traces; -static LONG muted_skipped; -static LONG muted_todo_successes; - -static int running_under_wine; -static int winetest_debug; -static int winetest_report_success; - -/* silence todos and skips above this threshold */ -static int winetest_mute_threshold = 42;
-/* counts how many times a given line printed a message */ -static LONG line_counters[16384]; +LONG winetest_successes = 0; +LONG winetest_failures = 0; +LONG winetest_flaky_failures = 0; +LONG winetest_skipped = 0; +LONG winetest_todo_successes = 0; +LONG winetest_todo_failures = 0; +LONG winetest_muted_traces = 0; +LONG winetest_muted_skipped = 0; +LONG winetest_muted_todo_successes = 0; + +const char *winetest_platform; +int winetest_platform_is_wine; +int winetest_debug; +int winetest_report_success; +int winetest_color = 0; +int winetest_time = 0; +int winetest_start_time, winetest_last_time;
-/* The following data must be kept track of on a per-thread basis */ -struct tls_data -{ - HANDLE thread; - const char *current_file; /* file of current check */ - int current_line; /* line of current check */ - 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 */ - char context[8][128]; /* data to print before messages */ - unsigned int context_count; /* number of context prefixes */ -}; +/* silence todos and skips above this threshold */ +int winetest_mute_threshold = 42;
static KSPIN_LOCK tls_data_lock; -static struct tls_data tls_data_pool[128]; +static struct winetest_thread_data tls_data_pool[128]; +static HANDLE tls_data_thread[ARRAY_SIZE(tls_data_pool)]; static DWORD tls_data_count;
-static inline struct tls_data *get_tls_data(void) +struct winetest_thread_data *winetest_get_thread_data(void) { - static struct tls_data tls_overflow; - struct tls_data *data; HANDLE thread = PsGetCurrentThreadId(); + struct winetest_thread_data *data; KIRQL irql; + UINT i;
KeAcquireSpinLock( &tls_data_lock, &irql ); - for (data = tls_data_pool; data != tls_data_pool + tls_data_count; ++data) - if (data->thread == thread) break; - if (data == tls_data_pool + ARRAY_SIZE(tls_data_pool)) data = &tls_overflow; - else if (data == tls_data_pool + tls_data_count) + + for (i = 0; i < tls_data_count; i++) if (tls_data_thread[i] == thread) break; + data = tls_data_pool + i; + + if (tls_data_thread[i] != thread) { - data->thread = thread; + tls_data_count = min(tls_data_count + 1, ARRAY_SIZE(tls_data_pool)); + tls_data_thread[i] = thread; data->str_pos = data->strings; - tls_data_count++; } + KeReleaseSpinLock( &tls_data_lock, irql );
return data; }
-static inline void winetest_set_location( const char *file, int line ) +void winetest_print_lock(void) +{ +} + +void winetest_print_unlock(void) { - struct tls_data *data = get_tls_data(); - data->current_file = strrchr( file, '/' ); - if (data->current_file == NULL) data->current_file = strrchr( file, '\' ); - if (data->current_file == NULL) data->current_file = file; - else data->current_file++; - data->current_line = line; }
-static inline void kvprintf( const char *format, va_list ap ) +int winetest_vprintf( const char *format, va_list args ) { - struct tls_data *data = get_tls_data(); + struct winetest_thread_data *data = winetest_get_thread_data(); IO_STATUS_BLOCK io; - int len = vsnprintf( data->str_pos, sizeof(data->strings) - (data->str_pos - data->strings), format, ap ); + int len; + + len = vsnprintf( data->str_pos, sizeof(data->strings) - (data->str_pos - data->strings), format, args ); data->str_pos += len;
if (len && data->str_pos[-1] == '\n') @@ -266,28 +254,13 @@ static inline void kvprintf( const char *format, va_list ap ) strlen( data->strings ), NULL, NULL ); data->str_pos = data->strings; } -} - -static inline void WINAPIV kprintf( const char *format, ... ) __WINE_PRINTF_ATTR( 1, 2 ); -static inline void WINAPIV kprintf( const char *format, ... ) -{ - va_list valist;
- va_start( valist, format ); - kvprintf( format, valist ); - va_end( valist ); + return len; }
-static inline void WINAPIV winetest_printf( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 ); -static inline void WINAPIV winetest_printf( const char *msg, ... ) +int winetest_get_time(void) { - struct tls_data *data = get_tls_data(); - va_list valist; - - kprintf( "%s:%d: ", data->current_file, data->current_line ); - va_start( valist, msg ); - kvprintf( msg, valist ); - va_end( valist ); + return 0; }
static inline NTSTATUS winetest_init(void) @@ -314,7 +287,8 @@ static inline NTSTATUS winetest_init(void) return ret; } data = addr; - running_under_wine = data->running_under_wine; + winetest_platform_is_wine = data->running_under_wine; + winetest_platform = winetest_platform_is_wine ? "wine" : "windows"; winetest_debug = data->winetest_debug; winetest_report_success = data->winetest_report_success;
@@ -348,10 +322,11 @@ static inline void winetest_cleanup_( const char *file )
if (winetest_debug) { - kprintf( "%04lx:%s: %ld tests executed (%ld marked as todo, 0 as flaky, %ld %s), %ld skipped.\n", - (DWORD)(DWORD_PTR)PsGetCurrentProcessId(), test_name, - successes + failures + todo_successes + todo_failures, todo_successes, failures + todo_failures, - (failures + todo_failures != 1) ? "failures" : "failure", skipped ); + winetest_printf( "%04lx:%s: %ld tests executed (%ld marked as todo, 0 as flaky, %ld %s), %ld skipped.\n", + (DWORD)(DWORD_PTR)PsGetCurrentProcessId(), test_name, + winetest_successes + winetest_failures + winetest_todo_successes + winetest_todo_failures, + winetest_todo_successes, winetest_failures + winetest_todo_failures, + (winetest_failures + winetest_todo_failures != 1) ? "failures" : "failure", winetest_skipped ); }
RtlInitUnicodeString( &string, L"\BaseNamedObjects\winetest_dinput_section" ); @@ -364,8 +339,8 @@ static inline void winetest_cleanup_( const char *file ) { data = addr;
- InterlockedExchangeAdd( &data->failures, failures ); - InterlockedExchangeAdd( &data->todo_failures, todo_failures ); + InterlockedExchangeAdd( &data->failures, winetest_failures ); + InterlockedExchangeAdd( &data->todo_failures, winetest_todo_failures );
ZwUnmapViewOfSection( NtCurrentProcess(), addr ); } @@ -375,210 +350,6 @@ static inline void winetest_cleanup_( const char *file ) ZwClose( okfile ); }
-static inline void winetest_print_context( const char *msgtype ) -{ - struct tls_data *data = get_tls_data(); - unsigned int i; - - winetest_printf( "%s", msgtype ); - for (i = 0; i < data->context_count; ++i) kprintf( "%s: ", data->context[i] ); -} - -static inline LONG winetest_add_line(void) -{ - struct tls_data *data; - int index, count; - - if (winetest_debug > 1) return 0; - - data = get_tls_data(); - index = data->current_line % ARRAY_SIZE(line_counters); - count = InterlockedIncrement( line_counters + index ) - 1; - if (count == winetest_mute_threshold) - winetest_printf( "Line has been silenced after %d occurrences\n", winetest_mute_threshold ); - - return count; -} - -static inline int winetest_vok( int condition, const char *msg, va_list args ) -{ - struct tls_data *data = get_tls_data(); - - if (data->todo_level) - { - if (condition) - { - winetest_print_context( "Test succeeded inside todo block: " ); - kvprintf( msg, args ); - InterlockedIncrement( &todo_failures ); - return 0; - } - else - { - if (!winetest_debug || winetest_add_line() < winetest_mute_threshold) - { - if (winetest_debug > 0) - { - winetest_print_context( "Test marked todo: " ); - kvprintf( msg, args ); - } - InterlockedIncrement( &todo_successes ); - } - else InterlockedIncrement( &muted_todo_successes ); - return 1; - } - } - else - { - if (!condition) - { - winetest_print_context( "Test failed: " ); - kvprintf( msg, args ); - InterlockedIncrement( &failures ); - return 0; - } - else - { - if (winetest_report_success) winetest_printf( "Test succeeded\n" ); - InterlockedIncrement( &successes ); - return 1; - } - } -} - -static inline void WINAPIV winetest_ok( int condition, const char *msg, ... ) __WINE_PRINTF_ATTR( 2, 3 ); -static inline void WINAPIV winetest_ok( int condition, const char *msg, ... ) -{ - va_list args; - va_start( args, msg ); - winetest_vok( condition, msg, args ); - va_end( args ); -} - -static inline void winetest_vskip( const char *msg, va_list args ) -{ - if (winetest_add_line() < winetest_mute_threshold) - { - winetest_print_context( "Driver tests skipped: " ); - kvprintf( msg, args ); - InterlockedIncrement( &skipped ); - } - else InterlockedIncrement( &muted_skipped ); -} - -static inline void WINAPIV winetest_skip( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 ); -static inline void WINAPIV winetest_skip( const char *msg, ... ) -{ - va_list args; - va_start( args, msg ); - winetest_vskip( msg, args ); - va_end( args ); -} - -static inline void WINAPIV winetest_win_skip( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 ); -static inline void WINAPIV winetest_win_skip( const char *msg, ... ) -{ - va_list args; - va_start( args, msg ); - if (!running_under_wine) winetest_vskip( msg, args ); - else winetest_vok( 0, msg, args ); - va_end( args ); -} - -static inline void WINAPIV winetest_trace( const char *msg, ... ) __WINE_PRINTF_ATTR( 1, 2 ); -static inline void WINAPIV winetest_trace( const char *msg, ... ) -{ - va_list args; - - if (!winetest_debug) return; - if (winetest_add_line() < winetest_mute_threshold) - { - winetest_print_context( "" ); - va_start( args, msg ); - kvprintf( msg, args ); - va_end( args ); - } - else InterlockedIncrement( &muted_traces ); -} - -static inline void winetest_start_todo( int is_todo ) -{ - struct tls_data *data = get_tls_data(); - data->todo_level = (data->todo_level << 1) | (is_todo != 0); - data->todo_do_loop = 1; -} - -static inline int winetest_loop_todo(void) -{ - struct tls_data *data = get_tls_data(); - int do_loop = data->todo_do_loop; - data->todo_do_loop = 0; - return do_loop; -} - -static inline void winetest_end_todo(void) -{ - struct tls_data *data = get_tls_data(); - data->todo_level >>= 1; -} - -static inline void WINAPIV winetest_push_context( const char *fmt, ... ) __WINE_PRINTF_ATTR( 1, 2 ); -static inline void WINAPIV winetest_push_context( const char *fmt, ... ) -{ - struct tls_data *data = get_tls_data(); - va_list valist; - - if (data->context_count < ARRAY_SIZE(data->context)) - { - va_start( valist, fmt ); - vsnprintf( data->context[data->context_count], sizeof(data->context[data->context_count]), fmt, valist ); - va_end( valist ); - data->context[data->context_count][sizeof(data->context[data->context_count]) - 1] = 0; - } - ++data->context_count; -} - -static inline void winetest_pop_context(void) -{ - struct tls_data *data = get_tls_data(); - - if (data->context_count) --data->context_count; -} - -static inline int broken( int condition ) -{ - return !running_under_wine && condition; -} - -#ifdef WINETEST_NO_LINE_NUMBERS -# define subtest_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_subtest -# define ignore_exceptions_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_ignore_exceptions -# define ok_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_ok -# define skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_skip -# define win_skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_win_skip -# define trace_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_trace -# define wait_child_process_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_wait_child_process -#else -# define subtest_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_subtest -# define ignore_exceptions_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ignore_exceptions -# define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok -# define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip -# define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip -# define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace -# define wait_child_process_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_wait_child_process -#endif - -#define ok ok_(__FILE__, __LINE__) -#define skip skip_(__FILE__, __LINE__) -#define trace trace_(__FILE__, __LINE__) -#define win_skip win_skip_(__FILE__, __LINE__) - -#define todo_if(is_todo) for (winetest_start_todo(is_todo); \ - winetest_loop_todo(); \ - winetest_end_todo()) -#define todo_wine todo_if(running_under_wine) -#define todo_wine_if(is_todo) todo_if((is_todo) && running_under_wine) - -#endif /* __WINE_WINE_TEST_H */ +#endif /* WINE_DRIVER_TEST */
#endif /* __WINE_DRIVER_HID_H */ diff --git a/dlls/dinput/tests/driver_hid_poll.c b/dlls/dinput/tests/driver_hid_poll.c index 7d9c215a0f0..b5cf46f389e 100644 --- a/dlls/dinput/tests/driver_hid_poll.c +++ b/dlls/dinput/tests/driver_hid_poll.c @@ -32,6 +32,7 @@
#include "wine/list.h"
+#define WINE_DRIVER_TEST #include "initguid.h" #include "driver_hid.h"
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=136879
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
Report validation errors: dinput:hid has unaccounted for skip messages
=== w7u_el (32 bit report) ===
Report validation errors: dinput:hid has unaccounted for skip messages
v2: Add a change to fix the missing zero-initialization of now non-static counters, fix broken wine platform detection.