21#ifndef __WINE_WINE_TEST_H
22#define __WINE_WINE_TEST_H
31#error config.h should not be used in Wine tests
33#ifdef __WINE_WINE_LIBRARY_H
34#error wine/library.h should not be used in Wine tests
36#ifdef __WINE_WINE_UNICODE_H
37#error wine/unicode.h should not be used in Wine tests
39#ifdef __WINE_WINE_DEBUG_H
40#error wine/debug.h should not be used in Wine tests
47#ifndef INVALID_FILE_ATTRIBUTES
48#define INVALID_FILE_ATTRIBUTES (~0u)
50#ifndef INVALID_SET_FILE_POINTER
51#define INVALID_SET_FILE_POINTER (~0u)
85#ifdef WINETEST_USE_DBGSTR_LONGLONG
99 while (*str1 && (*str1 == *str2)) { str1++; str2++; }
100 return *str1 - *str2;
105#define START_TEST(name) \
106 static void func_##name(void); \
107 const struct test winetest_testlist[] = { { #name, func_##name }, { 0, 0 } }; \
108 static void func_##name(void)
113#define START_TEST(name) extern "C" void func_##name(void)
115#define START_TEST(name) void func_##name(void)
120#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
121#define __winetest_cdecl __cdecl
122#define __winetest_va_list __builtin_ms_va_list
124#define __winetest_cdecl
125#define __winetest_va_list va_list
133# define WINETEST_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
143# define WINETEST_PRINTF_ATTR(fmt,args)
154#define subtest_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_subtest
155#define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
156#define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
157#define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
158#define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace
160#define subtest subtest_(__FILE__, __LINE__)
161#define ok ok_(__FILE__, __LINE__)
162#define skip skip_(__FILE__, __LINE__)
163#define win_skip win_skip_(__FILE__, __LINE__)
164#define trace trace_(__FILE__, __LINE__)
166#define todo_if(is_todo) for (winetest_start_todo(is_todo); \
167 winetest_loop_todo(); \
170#define todo_ros todo_if(!strcmp(winetest_platform, "reactos"))
171#define todo_ros_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "reactos"))
173#define todo_wine todo_ros
174#define todo_wine_if todo_ros_if
176#define todo_wine todo_if(!strcmp(winetest_platform, "wine"))
177#define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine"))
180#define ros_skip_flaky for (winetest_start_nocount(3); \
181 winetest_loop_nocount(); \
182 winetest_end_nocount())
184#define disable_success_count for (winetest_start_nocount(1); \
185 winetest_loop_nocount(); \
186 winetest_end_nocount())
188#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
190#ifdef NONAMELESSUNION
212#ifdef NONAMELESSSTRUCT
240#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
241# define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg)
242# define __winetest_va_end(list) __builtin_ms_va_end(list)
244# define __winetest_va_start(list,arg) va_start(list,arg)
245# define __winetest_va_end(list) va_end(list)
250#if defined(WINETEST_MSVC_IDE_FORMATTING)
251# define __winetest_file_line_prefix "%s(%d)"
253# define __winetest_file_line_prefix "%s:%d"
277static int winetest_argc;
278static char** winetest_argv;
280static const struct test *current_test;
282static LONG successes;
285static LONG todo_successes;
286static LONG todo_failures;
291 const char* current_file;
294 unsigned int nocount_level;
299 unsigned int context_count;
338static void exit_process(
int code )
348#if defined(WINETEST_MSVC_IDE_FORMATTING)
357 data->current_file++;
375 __winetest_va_end(
valist );
383 winetest_printf(
"%s", msgtype );
384 for (
i = 0;
i <
data->context_count; ++
i)
391 fprintf(
stdout, __winetest_file_line_prefix
": Subtest %s\n",
398#ifndef USE_WINE_TODOS
418 if (
data->todo_level)
422 winetest_print_context(
"Test succeeded inside todo block: " );
424 if ((
data->nocount_level & 2) == 0)
433 winetest_print_context(
"Test marked todo: " );
436 if ((
data->nocount_level & 1) == 0)
445 winetest_print_context(
"Test failed: " );
447 if ((
data->nocount_level & 2) == 0)
455 winetest_printf(
"Test succeeded\n");
457 if ((
data->nocount_level & 1) == 0)
470 __winetest_va_end(
valist);
479 winetest_print_context(
"" );
482 __winetest_va_end(
valist);
494 __winetest_va_end(
valist);
499 winetest_print_context(
"Tests skipped: " );
509 __winetest_va_end(
valist);
517#ifndef USE_WINE_TODOS
524 __winetest_va_end(
valist);
530 data->todo_level = (
data->todo_level << 1) | (is_todo != 0);
531 data->todo_do_loop=1;
538 data->todo_do_loop=0;
545 data->todo_level >>= 1;
559 data->todo_do_loop = 1;
566 data->todo_do_loop = 0;
573 data->nocount_level >>= 2;
585 __winetest_va_end(
valist);
586 data->context[
data->context_count][
sizeof(
data->context[
data->context_count]) - 1] = 0;
588 ++
data->context_count;
595 if (
data->context_count)
596 --
data->context_count;
601 *pargv = winetest_argv;
602 return winetest_argc;
617 while (new_failures-- > 0)
626 fprintf(
stdout,
"%s: child process wait failed\n", current_test->name );
640 current_test->name, (
unsigned)
exit_code );
654 if (!
str)
return "(null)";
674 case '\n': *
dst++ =
'\\'; *
dst++ =
'n';
break;
675 case '\r': *
dst++ =
'\\'; *
dst++ =
'r';
break;
676 case '\t': *
dst++ =
'\\'; *
dst++ =
't';
break;
677 case '"': *
dst++ =
'\\'; *
dst++ =
'"';
break;
678 case '\\': *
dst++ =
'\\'; *
dst++ =
'\\';
break;
680 if (
c >=
' ' &&
c <= 126)
705 static const char hex[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'};
708 if (!
str)
return "(null)";
716 if (
n == -1)
for (
n = 0;
str[
n];
n++) ;
724 case '\n': *
dst++ =
'\\'; *
dst++ =
'n';
break;
725 case '\r': *
dst++ =
'\\'; *
dst++ =
'r';
break;
726 case '\t': *
dst++ =
'\\'; *
dst++ =
't';
break;
727 case '"': *
dst++ =
'\\'; *
dst++ =
'"';
break;
728 case '\\': *
dst++ =
'\\'; *
dst++ =
'\\';
break;
730 if (
c <
' ' ||
c >= 127)
733 *
dst++ =
hex[(
c >> 12) & 0x0f];
759 if (!
guid)
return "(null)";
761 sprintf(
res,
"{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
772 if (!
point)
return "(null)";
787 if (!
size)
return "(null)";
802 if (!
rect)
return "(null)";
813#ifdef WINETEST_USE_DBGSTR_LONGLONG
820 sprintf(
res,
"%lx%08lx", (
unsigned long)(
ll >> 32), (
unsigned long)
ll );
829static const struct test *find_test(
const char *
name )
849static void list_tests(
void)
860#pragma warning(disable:28182)
874 successes =
failures = todo_successes = todo_failures = 0;
882 fprintf(
stdout,
"\n%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
884 (
int)todo_successes, (
int)(
failures + todo_failures),
885 (
failures + todo_failures != 1) ?
"failures" :
"failure",
912 winetest_argc =
argc;
913 winetest_argv =
argv;
943#define ok_hex_(file, line, expression, result) \
945 int _value = (expression); \
946 int _result = (result); \
947 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
948 #expression, _result, _value); \
950#define ok_hex(expression, result) ok_hex_(__FILE__, __LINE__, expression, result)
952#define ok_dec_(file, line, expression, result) \
954 int _value = (expression); \
955 int _result = (result); \
956 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \
957 #expression, _result, _value); \
959#define ok_dec(expression, result) ok_dec_(__FILE__, __LINE__, expression, result)
961#define ok_ptr_(file, line, expression, result) \
963 const void *_value = (expression); \
964 const void *_result = (result); \
965 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
966 #expression, _result, _value); \
968#define ok_ptr(expression, result) ok_ptr_(__FILE__, __LINE__, expression, result)
970#define ok_size_t_(file, line, expression, result) \
972 size_t _value = (expression); \
973 size_t _result = (result); \
974 ok_(file, line)(_value == _result, "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \
975 #expression, _result, _value); \
977#define ok_size_t(expression, result) ok_size_t_(__FILE__, __LINE__, expression, result)
979#define ok_char(expression, result) ok_hex(expression, result)
981#define ok_err_(file, line, error) \
982 ok_(file, line)(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError())
983#define ok_err(error) ok_err_(__FILE__, __LINE__, error)
985#define ok_str_(file, line, x, y) \
986 ok_(file, line)(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)
987#define ok_str(x, y) ok_str_(__FILE__, __LINE__, x, y)
989#define ok_wstr_(file, line, x, y) \
990 ok_(file, line)(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
991#define ok_wstr(x, y) ok_wstr_(__FILE__, __LINE__, x, y)
993#define ok_long(expression, result) ok_hex(expression, result)
994#define ok_int(expression, result) ok_dec(expression, result)
995#define ok_int_(file, line, expression, result) ok_dec_(file, line, expression, result)
996#define ok_ntstatus(status, expected) ok_hex(status, expected)
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strcpy(char *DstString, const char *SrcString)
#define InterlockedIncrement
static INT do_loop(const PropSheetInfo *psInfo)
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
#define GetEnvironmentVariableA(x, y, z)
UINT WINAPI SetErrorMode(IN UINT uMode)
BOOL NTAPI IsBadStringPtrW(IN LPCWSTR lpsz, IN UINT_PTR ucchMax)
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
VOID WINAPI ExitProcess(IN UINT uExitCode)
LPVOID WINAPI TlsGetValue(IN DWORD Index)
DWORD WINAPI TlsAlloc(VOID)
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
static LPSTR get_temp_buffer(void)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLsizei const GLchar *const * strings
GLsizeiptr const GLvoid GLenum usage
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 fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_opt_ _CRTIMP int __cdecl setvbuf(_Inout_ FILE *_File, _Inout_updates_opt_z_(_Size) char *_Buf, _In_ int _Mode, _In_ size_t _Size)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define sprintf(buf, format,...)
static __ms_va_list valist
#define SEM_FAILCRITICALERRORS
#define SEM_NOGPFAULTERRORBOX
const struct test winetest_testlist[]
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
void winetest_start_todo(int is_todo)
const char * winetest_platform
const char * wine_dbgstr_size(const SIZE *guid)
void __winetest_cdecl winetest_push_context(const char *fmt,...)
LONG winetest_get_failures(void)
void __winetest_cdecl winetest_win_skip(const char *msg,...)
LONG winetest_get_successes(void)
const char * wine_dbgstr_rect(const RECT *rect)
const char * wine_dbgstr_wn(const WCHAR *str, intptr_t n)
void winetest_set_location(const char *file, int line)
void __winetest_cdecl winetest_skip(const char *msg,...)
void winetest_vskip(const char *msg, __winetest_va_list ap)
void winetest_end_nocount(void)
static int winetest_strcmpW(const WCHAR *str1, const WCHAR *str2)
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
const char * wine_dbgstr_guid(const GUID *guid)
int winetest_get_mainargs(char ***pargv)
int winetest_vok(int condition, const char *msg, __winetest_va_list ap)
void winetest_start_nocount(unsigned int flags)
void winetest_wait_child_process(HANDLE process)
void winetest_subtest(const char *name)
const char * wine_dbgstr_point(const POINT *guid)
void winetest_end_todo(void)
int winetest_loop_nocount(void)
static const char * wine_dbgstr_a(const char *s)
#define __winetest_va_list
static const char * debugstr_an(const CHAR *s, intptr_t n)
int winetest_loop_todo(void)
const char * wine_dbgstr_an(const CHAR *str, intptr_t n)
void __winetest_cdecl winetest_print(const char *msg,...)
void winetest_add_failures(LONG new_failures)
void winetest_pop_context(void)
void __winetest_cdecl winetest_trace(const char *msg,...)
static void release_temp_buffer(char *buffer, size_t size)
static char argv0[MAX_PATH]
TCHAR str_pos[MAX_LOADSTRING]
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
tls_data_t * get_tls_data(void)
DWORD WINAPI GetLastError(void)
void int int ULONGLONG int va_list * ap