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) 84 #ifdef WINETEST_USE_DBGSTR_LONGLONG 96 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
102 #define START_TEST(name) \ 103 static void func_##name(void); \ 104 const struct test winetest_testlist[] = { { #name, func_##name }, { 0, 0 } }; \ 105 static void func_##name(void) 110 #define START_TEST(name) extern "C" void func_##name(void) 112 #define START_TEST(name) void func_##name(void) 117 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT) 118 #define __winetest_cdecl __cdecl 119 #define __winetest_va_list __builtin_ms_va_list 121 #define __winetest_cdecl 122 #define __winetest_va_list va_list 130 # define WINETEST_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args))) 140 # define WINETEST_PRINTF_ATTR(fmt,args) 151 #define subtest_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_subtest 152 #define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok 153 #define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip 154 #define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip 155 #define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace 157 #define subtest subtest_(__FILE__, __LINE__) 158 #define ok ok_(__FILE__, __LINE__) 159 #define skip skip_(__FILE__, __LINE__) 160 #define win_skip win_skip_(__FILE__, __LINE__) 161 #define trace trace_(__FILE__, __LINE__) 163 #define todo_if(is_todo) for (winetest_start_todo(is_todo); \ 164 winetest_loop_todo(); \ 167 #define todo_ros todo_if(!strcmp(winetest_platform, "reactos")) 168 #define todo_ros_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "reactos")) 169 #ifdef USE_WINE_TODOS 170 #define todo_wine todo_ros 171 #define todo_wine_if todo_ros_if 173 #define todo_wine todo_if(!strcmp(winetest_platform, "wine")) 174 #define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine")) 177 #define ros_skip_flaky for (winetest_start_nocount(3); \ 178 winetest_loop_nocount(); \ 179 winetest_end_nocount()) 181 #define disable_success_count for (winetest_start_nocount(1); \ 182 winetest_loop_nocount(); \ 183 winetest_end_nocount()) 185 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 187 #ifdef NONAMELESSUNION 189 # define U1(x) (x).u1 190 # define U2(x) (x).u2 191 # define U3(x) (x).u3 192 # define U4(x) (x).u4 193 # define U5(x) (x).u5 194 # define U6(x) (x).u6 195 # define U7(x) (x).u7 196 # define U8(x) (x).u8 209 #ifdef NONAMELESSSTRUCT 211 # define S1(x) (x).s1 212 # define S2(x) (x).s2 213 # define S3(x) (x).s3 214 # define S4(x) (x).s4 215 # define S5(x) (x).s5 237 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT) 238 # define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg) 239 # define __winetest_va_end(list) __builtin_ms_va_end(list) 241 # define __winetest_va_start(list,arg) va_start(list,arg) 242 # define __winetest_va_end(list) va_end(list) 247 #if defined(WINETEST_MSVC_IDE_FORMATTING) 248 # define __winetest_file_line_prefix "%s(%d)" 250 # define __winetest_file_line_prefix "%s:%d" 274 static int winetest_argc;
275 static char** winetest_argv;
277 static const struct test *current_test;
279 static LONG successes;
282 static LONG todo_successes;
283 static LONG todo_failures;
288 const char* current_file;
291 unsigned int nocount_level;
296 unsigned int context_count;
335 static void exit_process(
int code )
345 #if defined(WINETEST_MSVC_IDE_FORMATTING) 354 data->current_file++;
372 __winetest_va_end(
valist );
380 winetest_printf(
"%s", msgtype );
381 for (
i = 0;
i <
data->context_count; ++
i)
388 fprintf(
stdout, __winetest_file_line_prefix
": Subtest %s\n",
395 #ifndef USE_WINE_TODOS
415 if (
data->todo_level)
419 winetest_print_context(
"Test succeeded inside todo block: " );
421 if ((
data->nocount_level & 2) == 0)
430 winetest_print_context(
"Test marked todo: " );
433 if ((
data->nocount_level & 1) == 0)
442 winetest_print_context(
"Test failed: " );
444 if ((
data->nocount_level & 2) == 0)
452 winetest_printf(
"Test succeeded\n");
454 if ((
data->nocount_level & 1) == 0)
467 __winetest_va_end(
valist);
476 winetest_print_context(
"" );
479 __winetest_va_end(
valist);
491 __winetest_va_end(
valist);
496 winetest_print_context(
"Tests skipped: " );
506 __winetest_va_end(
valist);
514 #ifndef USE_WINE_TODOS
521 __winetest_va_end(
valist);
527 data->todo_level = (
data->todo_level << 1) | (is_todo != 0);
528 data->todo_do_loop=1;
535 data->todo_do_loop=0;
542 data->todo_level >>= 1;
556 data->todo_do_loop = 1;
563 data->todo_do_loop = 0;
570 data->nocount_level >>= 2;
582 __winetest_va_end(
valist);
583 data->context[
data->context_count][
sizeof(
data->context[
data->context_count]) - 1] = 0;
585 ++
data->context_count;
592 if (
data->context_count)
593 --
data->context_count;
598 *pargv = winetest_argv;
599 return winetest_argc;
614 while (new_failures-- > 0)
623 fprintf(
stdout,
"%s: child process wait failed\n", current_test->name );
637 current_test->name, (
unsigned)
exit_code );
651 if (!
str)
return "(null)";
671 case '\n': *
dst++ =
'\\'; *
dst++ =
'n';
break;
672 case '\r': *
dst++ =
'\\'; *
dst++ =
'r';
break;
673 case '\t': *
dst++ =
'\\'; *
dst++ =
't';
break;
674 case '"': *
dst++ =
'\\'; *
dst++ =
'"';
break;
675 case '\\': *
dst++ =
'\\'; *
dst++ =
'\\';
break;
677 if (
c >=
' ' &&
c <= 126)
702 static const char hex[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'};
705 if (!
str)
return "(null)";
713 if (
n == -1)
for (
n = 0;
str[
n];
n++) ;
721 case '\n': *
dst++ =
'\\'; *
dst++ =
'n';
break;
722 case '\r': *
dst++ =
'\\'; *
dst++ =
'r';
break;
723 case '\t': *
dst++ =
'\\'; *
dst++ =
't';
break;
724 case '"': *
dst++ =
'\\'; *
dst++ =
'"';
break;
725 case '\\': *
dst++ =
'\\'; *
dst++ =
'\\';
break;
730 *
dst++ =
hex[(
c >> 12) & 0x0f];
756 if (!
guid)
return "(null)";
758 sprintf(
res,
"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
769 if (!
point)
return "(null)";
771 #ifdef __ROS_LONG64__ 784 if (!
size)
return "(null)";
786 #ifdef __ROS_LONG64__ 799 if (!
rect)
return "(null)";
801 #ifdef __ROS_LONG64__ 810 #ifdef WINETEST_USE_DBGSTR_LONGLONG 817 sprintf(
res,
"%lx%08lx", (
unsigned long)(
ll >> 32), (
unsigned long)
ll );
826 static const struct test *find_test(
const char *
name )
846 static void list_tests(
void)
855 #if defined(_MSC_VER) 856 #pragma warning(push) 857 #pragma warning(disable:28182) 871 successes =
failures = todo_successes = todo_failures = 0;
879 fprintf(
stdout,
"\n%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
881 (
int)todo_successes, (
int)(
failures + todo_failures),
882 (
failures + todo_failures != 1) ?
"failures" :
"failure",
889 #if defined(_MSC_VER) 909 winetest_argc =
argc;
910 winetest_argv =
argv;
936 #undef exception_info 940 #define ok_hex_(file, line, expression, result) \ 942 int _value = (expression); \ 943 int _result = (result); \ 944 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \ 945 #expression, _result, _value); \ 947 #define ok_hex(expression, result) ok_hex_(__FILE__, __LINE__, expression, result) 949 #define ok_dec_(file, line, expression, result) \ 951 int _value = (expression); \ 952 int _result = (result); \ 953 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \ 954 #expression, _result, _value); \ 956 #define ok_dec(expression, result) ok_dec_(__FILE__, __LINE__, expression, result) 958 #define ok_ptr_(file, line, expression, result) \ 960 const void *_value = (expression); \ 961 const void *_result = (result); \ 962 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \ 963 #expression, _result, _value); \ 965 #define ok_ptr(expression, result) ok_ptr_(__FILE__, __LINE__, expression, result) 967 #define ok_size_t_(file, line, expression, result) \ 969 size_t _value = (expression); \ 970 size_t _result = (result); \ 971 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \ 972 #expression, _result, _value); \ 974 #define ok_size_t(expression, result) ok_size_t_(__FILE__, __LINE__, expression, result) 976 #define ok_char(expression, result) ok_hex(expression, result) 978 #define ok_err_(file, line, error) \ 979 ok_(file, line)(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError()) 980 #define ok_err(error) ok_err_(__FILE__, __LINE__, error) 982 #define ok_str_(file, line, x, y) \ 983 ok_(file, line)(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x) 984 #define ok_str(x, y) ok_str_(__FILE__, __LINE__, x, y) 986 #define ok_wstr_(file, line, x, y) \ 987 ok_(file, line)(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x) 988 #define ok_wstr(x, y) ok_wstr_(__FILE__, __LINE__, x, y) 990 #define ok_long(expression, result) ok_hex(expression, result) 991 #define ok_int(expression, result) ok_dec(expression, result) 992 #define ok_int_(file, line, expression, result) ok_dec_(file, line, expression, result) 993 #define ok_ntstatus(status, expected) ok_hex(status, expected) 994 #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)
static const char hex[16]
#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,...)
void __winetest_cdecl winetest_push_context(const char *fmt,...)
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)
void winetest_pop_context(void)
void winetest_subtest(const char *name)
#define InterlockedIncrement
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
const char * wine_dbgstr_size(const SIZE *guid)
BOOL NTAPI IsBadStringPtrW(IN LPCWSTR lpsz, IN UINT_PTR ucchMax)
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
char * strcpy(char *DstString, const char *SrcString)
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)
static const char * wine_dbgstr_a(const char *s)
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
static const char * debugstr_an(const CHAR *s, intptr_t n)
void winetest_start_nocount(unsigned int flags)
void winetest_set_location(const char *file, int line)
GLuint const GLchar * name