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 );
extern void winetest_wait_child_process( HANDLE process );
-extern const char *wine_dbgstr_wn( const WCHAR *str, int n );
+extern const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n );
+extern const char *wine_dbgstr_guid( const GUID *guid );
static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
/* strcmpW is available for tests compiled under Wine, but not in standalone
extern void winetest_vskip( const char *msg, __winetest_va_list ap );
#ifdef __GNUC__
-
+# define WINETEST_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
extern void __winetest_cdecl winetest_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
extern void __winetest_cdecl winetest_win_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
extern void __winetest_cdecl winetest_trace( const char *msg, ... ) __attribute__((format (printf,1,2)));
#else /* __GNUC__ */
-
+# define WINETEST_PRINTF_ATTR(fmt,args)
extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... );
extern void __winetest_cdecl winetest_skip( const char *msg, ... );
extern void __winetest_cdecl winetest_win_skip( const char *msg, ... );
#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_if(is_todo) for (winetest_start_todo(is_todo); \
+ winetest_loop_todo(); \
+ winetest_end_todo())
-#define todo_ros todo("reactos")
+#define todo_ros todo_if(!strcmp(winetest_platform, "reactos"))
+#define todo_ros_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "reactos"))
#ifdef USE_WINE_TODOS
-#define todo_wine todo_ros
+#define todo_wine todo_ros
+#define todo_wine_if todo_ros_if
#else
-#define todo_wine todo("wine")
+#define todo_wine todo_if(!strcmp(winetest_platform, "wine"))
+#define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine"))
#endif
# define __winetest_va_end(list) va_end(list)
#endif
+/* Define WINETEST_MSVC_IDE_FORMATTING to alter the output format winetest will use for file/line numbers.
+ This alternate format makes the file/line numbers clickable in visual studio, to directly jump to them. */
+#if defined(WINETEST_MSVC_IDE_FORMATTING)
+# define __winetest_file_line_prefix "%s(%d)"
+#else
+# define __winetest_file_line_prefix "%s:%d"
+#endif
+
struct test
{
const char *name;
{
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 */
DWORD last_error;
last_error=GetLastError();
- data=TlsGetValue(tls_index);
+ data=(tls_data*)TlsGetValue(tls_index);
if (!data)
{
- data=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(tls_data));
+ data=(tls_data*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(tls_data));
data->str_pos = data->strings;
TlsSetValue(tls_index,data);
}
void winetest_set_location( const char* file, int line )
{
tls_data* data=get_tls_data();
+#if defined(WINETEST_MSVC_IDE_FORMATTING)
+ data->current_file = file;
+#else
data->current_file=strrchr(file,'/');
if (data->current_file==NULL)
data->current_file=strrchr(file,'\\');
data->current_file=file;
else
data->current_file++;
+#endif
data->current_line=line;
}
int broken( int condition )
{
- return (strcmp(winetest_platform, "windows") == 0) && condition;
+ return ((strcmp(winetest_platform, "windows") == 0)
+#ifndef USE_WINE_TODOS
+ || (strcmp(winetest_platform, "reactos") == 0)
+#endif
+ ) && condition;
}
/*
{
if (condition)
{
- fprintf( stdout, "%s:%d: Test succeeded inside todo block: ",
+ fprintf( stdout, __winetest_file_line_prefix ": Test succeeded inside todo block: ",
data->current_file, data->current_line );
vfprintf(stdout, msg, args);
InterlockedIncrement(&todo_failures);
/* show todos even if traces are disabled*/
/*if (winetest_debug > 0)*/
{
- fprintf( stdout, "%s:%d: Test marked todo: ",
+ fprintf( stdout, __winetest_file_line_prefix ": Test marked todo: ",
data->current_file, data->current_line );
vfprintf(stdout, msg, args);
}
{
if (!condition)
{
- fprintf( stdout, "%s:%d: Test failed: ",
+ fprintf( stdout, __winetest_file_line_prefix ": Test failed: ",
data->current_file, data->current_line );
vfprintf(stdout, msg, args);
InterlockedIncrement(&failures);
else
{
if (report_success)
- fprintf( stdout, "%s:%d: Test succeeded\n",
+ fprintf( stdout, __winetest_file_line_prefix ": Test succeeded\n",
data->current_file, data->current_line);
InterlockedIncrement(&successes);
return 1;
if (winetest_debug > 0)
{
- fprintf( stdout, "%s:%d: ", data->current_file, data->current_line );
+ fprintf( stdout, __winetest_file_line_prefix ": ", data->current_file, data->current_line );
__winetest_va_start(valist, msg);
vfprintf(stdout, msg, valist);
__winetest_va_end(valist);
{
tls_data* data=get_tls_data();
- fprintf( stdout, "%s:%d: Tests skipped: ", data->current_file, data->current_line );
+ fprintf( stdout, __winetest_file_line_prefix ": Tests skipped: ", data->current_file, data->current_line );
vfprintf(stdout, msg, args);
skipped++;
}
{
__winetest_va_list valist;
__winetest_va_start(valist, msg);
- if (strcmp(winetest_platform, "windows") == 0)
+ if ((strcmp(winetest_platform, "windows") == 0)
+#ifndef USE_WINE_TODOS
+ || (strcmp(winetest_platform, "reactos") == 0)
+#endif
+ )
winetest_vskip(msg, valist);
else
winetest_vok(0, msg, valist);
__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;
}
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 )
{
if (exit_code > 255)
{
- fprintf( stdout, "%s: exception 0x%08x in child process\n", current_test->name, exit_code );
+ fprintf( stdout, "%s: exception 0x%08x in child process\n", current_test->name, (unsigned)exit_code );
InterlockedIncrement( &failures );
}
else
{
fprintf( stdout, "%s: %u failures in child process\n",
- current_test->name, exit_code );
+ current_test->name, (unsigned)exit_code );
while (exit_code-- > 0)
InterlockedIncrement(&failures);
}
}
}
-const char *wine_dbgstr_wn( const WCHAR *str, int n )
+const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n )
{
char *dst, *res;
size_t size;
return res;
}
+const char *wine_dbgstr_guid( const GUID *guid )
+{
+ char *res;
+
+ if (!guid) return "(null)";
+ res = get_temp_buffer( 39 ); /* CHARS_IN_GUID */
+ sprintf( res, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
+ guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
+ guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
+ guid->Data4[5], guid->Data4[6], guid->Data4[7] );
+ return res;
+}
+
/* Find a test by name */
static const struct test *find_test( const char *name )
{
/* show test results even if traces are disabled */
/*if (winetest_debug)*/
{
- fprintf( stdout, "%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
- test->name, successes + failures + todo_successes + todo_failures,
- todo_successes, failures + todo_failures,
+ fprintf( stdout, "\n%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
+ test->name, (int)(successes + failures + todo_successes + todo_failures),
+ (int)todo_successes, (int)(failures + todo_failures),
(failures + todo_failures != 1) ? "failures" : "failure",
- skipped );
+ (int)skipped );
}
status = (failures + todo_failures < 255) ? failures + todo_failures : 255;
return status;
#define ok_char(expression, result) ok_hex(expression, result)
#define ok_err(error) \
- ok(GetLastError() == (error), "Wrong last error. Expected " #error ", got %d\n", (int)GetLastError())
+ ok(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError())
#define ok_str(x, y) \
ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)