21 #ifndef __WINE_WINE_TEST_H 22 #define __WINE_WINE_TEST_H 29 #ifdef __WINE_CONFIG_H 30 #error config.h should not be used in Wine tests 32 #ifdef __WINE_WINE_LIBRARY_H 33 #error wine/library.h should not be used in Wine tests 35 #ifdef __WINE_WINE_UNICODE_H 36 #error wine/unicode.h should not be used in Wine tests 38 #ifdef __WINE_WINE_DEBUG_H 39 #error wine/debug.h should not be used in Wine tests 46 #ifndef INVALID_FILE_ATTRIBUTES 47 #define INVALID_FILE_ATTRIBUTES (~0u) 49 #ifndef INVALID_SET_FILE_POINTER 50 #define INVALID_SET_FILE_POINTER (~0u) 83 #ifdef WINETEST_USE_DBGSTR_LONGLONG 93 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
99 #define START_TEST(name) \ 100 static void func_##name(void); \ 101 const struct test winetest_testlist[] = { { #name, func_##name }, { 0, 0 } }; \ 102 static void func_##name(void) 107 #define START_TEST(name) extern "C" void func_##name(void) 109 #define START_TEST(name) void func_##name(void) 114 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT) 115 #define __winetest_cdecl __cdecl 116 #define __winetest_va_list __builtin_ms_va_list 118 #define __winetest_cdecl 119 #define __winetest_va_list va_list 127 # define WINETEST_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args))) 135 # define WINETEST_PRINTF_ATTR(fmt,args) 144 #define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok 145 #define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip 146 #define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip 147 #define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace 149 #define ok ok_(__FILE__, __LINE__) 150 #define skip skip_(__FILE__, __LINE__) 151 #define win_skip win_skip_(__FILE__, __LINE__) 152 #define trace trace_(__FILE__, __LINE__) 154 #define todo_if(is_todo) for (winetest_start_todo(is_todo); \ 155 winetest_loop_todo(); \ 158 #define todo_ros todo_if(!strcmp(winetest_platform, "reactos")) 159 #define todo_ros_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "reactos")) 160 #ifdef USE_WINE_TODOS 161 #define todo_wine todo_ros 162 #define todo_wine_if todo_ros_if 164 #define todo_wine todo_if(!strcmp(winetest_platform, "wine")) 165 #define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine")) 168 #define ros_skip_flaky for (winetest_start_nocount(3); \ 169 winetest_loop_nocount(); \ 170 winetest_end_nocount()) 172 #define disable_success_count for (winetest_start_nocount(1); \ 173 winetest_loop_nocount(); \ 174 winetest_end_nocount()) 176 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 178 #ifdef NONAMELESSUNION 180 # define U1(x) (x).u1 181 # define U2(x) (x).u2 182 # define U3(x) (x).u3 183 # define U4(x) (x).u4 184 # define U5(x) (x).u5 185 # define U6(x) (x).u6 186 # define U7(x) (x).u7 187 # define U8(x) (x).u8 200 #ifdef NONAMELESSSTRUCT 202 # define S1(x) (x).s1 203 # define S2(x) (x).s2 204 # define S3(x) (x).s3 205 # define S4(x) (x).s4 206 # define S5(x) (x).s5 228 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT) 229 # define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg) 230 # define __winetest_va_end(list) __builtin_ms_va_end(list) 232 # define __winetest_va_start(list,arg) va_start(list,arg) 233 # define __winetest_va_end(list) va_end(list) 238 #if defined(WINETEST_MSVC_IDE_FORMATTING) 239 # define __winetest_file_line_prefix "%s(%d)" 241 # define __winetest_file_line_prefix "%s:%d" 265 static int winetest_argc;
266 static char** winetest_argv;
268 static const struct test *current_test;
270 static LONG successes;
273 static LONG todo_successes;
274 static LONG todo_failures;
279 const char* current_file;
281 unsigned int todo_level;
282 unsigned int nocount_level;
324 static void exit_process(
int code )
334 #if defined(WINETEST_MSVC_IDE_FORMATTING) 343 data->current_file++;
351 #ifndef USE_WINE_TODOS
371 if (
data->todo_level)
375 fprintf(
stdout, __winetest_file_line_prefix
": Test succeeded inside todo block: ",
376 data->current_file,
data->current_line );
378 if ((
data->nocount_level & 2) == 0)
387 fprintf(
stdout, __winetest_file_line_prefix
": Test marked todo: ",
388 data->current_file,
data->current_line );
391 if ((
data->nocount_level & 1) == 0)
400 fprintf(
stdout, __winetest_file_line_prefix
": Test failed: ",
401 data->current_file,
data->current_line );
403 if ((
data->nocount_level & 2) == 0)
410 fprintf(
stdout, __winetest_file_line_prefix
": Test succeeded\n",
411 data->current_file,
data->current_line);
412 if ((
data->nocount_level & 1) == 0)
425 __winetest_va_end(
valist);
438 __winetest_va_end(
valist);
450 __winetest_va_end(
valist);
457 fprintf(
stdout, __winetest_file_line_prefix
": Tests skipped: ",
data->current_file,
data->current_line );
467 __winetest_va_end(
valist);
475 #ifndef USE_WINE_TODOS
482 __winetest_va_end(
valist);
488 data->todo_level = (
data->todo_level << 1) | (is_todo != 0);
489 data->todo_do_loop=1;
496 data->todo_do_loop=0;
503 data->todo_level >>= 1;
517 data->todo_do_loop = 1;
524 data->todo_do_loop = 0;
531 data->nocount_level >>= 2;
536 *pargv = winetest_argv;
537 return winetest_argc;
552 while (new_failures-- > 0)
561 fprintf(
stdout,
"%s: child process wait failed\n", current_test->name );
575 current_test->name, (
unsigned)
exit_code );
589 if (!
str)
return "(null)";
609 case '\n': *
dst++ =
'\\'; *
dst++ =
'n';
break;
610 case '\r': *
dst++ =
'\\'; *
dst++ =
'r';
break;
611 case '\t': *
dst++ =
'\\'; *
dst++ =
't';
break;
612 case '"': *
dst++ =
'\\'; *
dst++ =
'"';
break;
613 case '\\': *
dst++ =
'\\'; *
dst++ =
'\\';
break;
615 if (
c >=
' ' &&
c <= 126)
644 if (!
str)
return "(null)";
665 case '\n': *
dst++ =
'\\'; *
dst++ =
'n';
break;
666 case '\r': *
dst++ =
'\\'; *
dst++ =
'r';
break;
667 case '\t': *
dst++ =
'\\'; *
dst++ =
't';
break;
668 case '"': *
dst++ =
'\\'; *
dst++ =
'"';
break;
669 case '\\': *
dst++ =
'\\'; *
dst++ =
'\\';
break;
671 if (
c >=
' ' &&
c <= 126)
697 if (!
guid)
return "(null)";
699 sprintf(
res,
"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
710 if (!
point)
return "(null)";
712 #ifdef __ROS_LONG64__ 725 if (!
size)
return "(null)";
727 #ifdef __ROS_LONG64__ 740 if (!
rect)
return "(null)";
742 #ifdef __ROS_LONG64__ 751 #ifdef WINETEST_USE_DBGSTR_LONGLONG 758 sprintf(
res,
"%lx%08lx", (
unsigned long)(
ll >> 32), (
unsigned long)
ll );
767 static const struct test *find_test(
const char *
name )
787 static void list_tests(
void)
796 #if defined(_MSC_VER) 797 #pragma warning(push) 798 #pragma warning(disable:28182) 812 successes =
failures = todo_successes = todo_failures = 0;
820 fprintf(
stdout,
"\n%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
822 (
int)todo_successes, (
int)(
failures + todo_failures),
823 (
failures + todo_failures != 1) ?
"failures" :
"failure",
830 #if defined(_MSC_VER) 850 winetest_argc =
argc;
851 winetest_argv =
argv;
877 #undef exception_info 881 #define ok_hex_(file, line, expression, result) \ 883 int _value = (expression); \ 884 int _result = (result); \ 885 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \ 886 #expression, _result, _value); \ 888 #define ok_hex(expression, result) ok_hex_(__FILE__, __LINE__, expression, result) 890 #define ok_dec_(file, line, expression, result) \ 892 int _value = (expression); \ 893 int _result = (result); \ 894 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \ 895 #expression, _result, _value); \ 897 #define ok_dec(expression, result) ok_dec_(__FILE__, __LINE__, expression, result) 899 #define ok_ptr_(file, line, expression, result) \ 901 const void *_value = (expression); \ 902 const void *_result = (result); \ 903 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \ 904 #expression, _result, _value); \ 906 #define ok_ptr(expression, result) ok_ptr_(__FILE__, __LINE__, expression, result) 908 #define ok_size_t_(file, line, expression, result) \ 910 size_t _value = (expression); \ 911 size_t _result = (result); \ 912 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \ 913 #expression, _result, _value); \ 915 #define ok_size_t(expression, result) ok_size_t_(__FILE__, __LINE__, expression, result) 917 #define ok_char(expression, result) ok_hex(expression, result) 919 #define ok_err_(file, line, error) \ 920 ok_(file, line)(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError()) 921 #define ok_err(error) ok_err_(__FILE__, __LINE__, error) 923 #define ok_str_(file, line, x, y) \ 924 ok_(file, line)(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x) 925 #define ok_str(x, y) ok_str_(__FILE__, __LINE__, x, y) 927 #define ok_wstr_(file, line, x, y) \ 928 ok_(file, line)(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x) 929 #define ok_wstr(x, y) ok_wstr_(__FILE__, __LINE__, x, y) 931 #define ok_long(expression, result) ok_hex(expression, result) 932 #define ok_int(expression, result) ok_dec(expression, result) 933 #define ok_int_(file, line, expression, result) ok_dec_(file, line, expression, result) 934 #define ok_ntstatus(status, expected) ok_hex(status, expected) 935 #define ok_hdl ok_ptr
UINT WINAPI SetErrorMode(IN UINT uMode)
LONG winetest_get_failures(void)
void winetest_add_failures(LONG new_failures)
int winetest_vok(int condition, const char *msg, __winetest_va_list ap)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
#define SEM_FAILCRITICALERRORS
void __winetest_cdecl winetest_print(const char *msg,...)
ACPI_SIZE strlen(const char *String)
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
int main(int argc, char *argv[])
static char * get_temp_buffer(int size)
const char * wine_dbgstr_guid(const GUID *guid)
VOID WINAPI ExitProcess(IN UINT uExitCode)
DWORD WINAPI GetLastError(VOID)
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define __winetest_va_list
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
#define sprintf(buf, format,...)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int winetest_loop_todo(void)
void winetest_start_todo(int is_todo)
void winetest_end_todo(void)
void winetest_vskip(const char *msg, __winetest_va_list ap)
static int winetest_strcmpW(const WCHAR *str1, const WCHAR *str2)
TCHAR str_pos[MAX_LOADSTRING]
const char * winetest_platform
const char * wine_dbgstr_an(const CHAR *str, intptr_t n)
void __winetest_cdecl winetest_trace(const char *msg,...)
const char * wine_dbgstr_point(const POINT *guid)
int winetest_loop_nocount(void)
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define GetEnvironmentVariableA(x, y, z)
static const char * wine_dbgstr_w(const WCHAR *s)
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
const char * wine_dbgstr_rect(const RECT *rect)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
void winetest_end_nocount(void)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
int winetest_get_mainargs(char ***pargv)
GLsizei const GLchar *const * strings
GLsizeiptr const GLvoid GLenum usage
static char argv0[MAX_PATH]
DWORD WINAPI TlsAlloc(VOID)
static INT do_loop(const PropSheetInfo *psInfo)
#define SEM_NOGPFAULTERRORBOX
static void release_temp_buffer(char *buffer, size_t size)
void winetest_wait_child_process(HANDLE process)
#define InterlockedIncrement
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
const char * wine_dbgstr_size(const SIZE *guid)
const struct test winetest_testlist[]
LPVOID WINAPI TlsGetValue(IN DWORD Index)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
LONG winetest_get_successes(void)
static const char * debugstr_a(const char *s)
void int int ULONGLONG int va_list * ap
void __winetest_cdecl winetest_skip(const char *msg,...)
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
int strcmp(const char *String1, const char *String2)
void __winetest_cdecl winetest_win_skip(const char *msg,...)
_Check_return_opt_ _CRTIMP int __cdecl setvbuf(_Inout_ FILE *_File, _Inout_updates_opt_z_(_Size) char *_Buf, _In_ int _Mode, _In_ size_t _Size)
static __ms_va_list valist
const char * wine_dbgstr_wn(const WCHAR *str, intptr_t n)
int broken(int condition)
tls_data_t * get_tls_data(void)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
static SERVICE_STATUS status
void winetest_start_nocount(unsigned int flags)
void winetest_set_location(const char *file, int line)
GLuint const GLchar * name