ReactOS  0.4.12-dev-90-g2e2e63e
test.h
Go to the documentation of this file.
1 /*
2  * Definitions for Wine C unit tests.
3  *
4  * Copyright (C) 2002 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #ifndef __WINE_WINE_TEST_H
22 #define __WINE_WINE_TEST_H
23 
24 #include <stdarg.h>
25 #include <stdlib.h>
26 #include <windef.h>
27 #include <winbase.h>
28 
29 #ifdef __WINE_CONFIG_H
30 #error config.h should not be used in Wine tests
31 #endif
32 #ifdef __WINE_WINE_LIBRARY_H
33 #error wine/library.h should not be used in Wine tests
34 #endif
35 #ifdef __WINE_WINE_UNICODE_H
36 #error wine/unicode.h should not be used in Wine tests
37 #endif
38 #ifdef __WINE_WINE_DEBUG_H
39 #error wine/debug.h should not be used in Wine tests
40 #endif
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #ifndef INVALID_FILE_ATTRIBUTES
47 #define INVALID_FILE_ATTRIBUTES (~0u)
48 #endif
49 #ifndef INVALID_SET_FILE_POINTER
50 #define INVALID_SET_FILE_POINTER (~0u)
51 #endif
52 
53 /* debug level */
54 extern int winetest_debug;
55 
56 /* running in interactive mode? */
57 extern int winetest_interactive;
58 
59 /* current platform */
60 extern const char *winetest_platform;
61 
62 extern void winetest_set_location( const char* file, int line );
63 extern void winetest_start_todo( int is_todo );
64 extern int winetest_loop_todo(void);
65 extern void winetest_end_todo(void);
66 extern int winetest_get_mainargs( char*** pargv );
67 extern LONG winetest_get_failures(void);
68 extern void winetest_add_failures( LONG new_failures );
70 
71 extern const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n );
72 extern const char *wine_dbgstr_guid( const GUID *guid );
73 extern const char *wine_dbgstr_point( const POINT *guid );
74 extern const char *wine_dbgstr_size( const SIZE *guid );
75 extern const char *wine_dbgstr_rect( const RECT *rect );
76 #ifdef WINETEST_USE_DBGSTR_LONGLONG
77 extern const char *wine_dbgstr_longlong( ULONGLONG ll );
78 #endif
79 static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
80 
81 /* strcmpW is available for tests compiled under Wine, but not in standalone
82  * builds under Windows, so we reimplement it under a different name. */
83 static inline int winetest_strcmpW( const WCHAR *str1, const WCHAR *str2 )
84 {
85  while (*str1 && (*str1 == *str2)) { str1++; str2++; }
86  return *str1 - *str2;
87 }
88 
89 #ifdef STANDALONE
90 
91 #define START_TEST(name) \
92  static void func_##name(void); \
93  const struct test winetest_testlist[] = { { #name, func_##name }, { 0, 0 } }; \
94  static void func_##name(void)
95 
96 #else /* STANDALONE */
97 
98 #ifdef __cplusplus
99 #define START_TEST(name) extern "C" void func_##name(void)
100 #else
101 #define START_TEST(name) void func_##name(void)
102 #endif
103 
104 #endif /* STANDALONE */
105 
106 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
107 #define __winetest_cdecl __cdecl
108 #define __winetest_va_list __builtin_ms_va_list
109 #else
110 #define __winetest_cdecl
111 #define __winetest_va_list va_list
112 #endif
113 
114 extern int broken( int condition );
115 extern int winetest_vok( int condition, const char *msg, __winetest_va_list ap );
116 extern void winetest_vskip( const char *msg, __winetest_va_list ap );
117 
118 #ifdef __GNUC__
119 # define WINETEST_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
120 extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
121 extern void __winetest_cdecl winetest_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
122 extern void __winetest_cdecl winetest_win_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
123 extern void __winetest_cdecl winetest_trace( const char *msg, ... ) __attribute__((format (printf,1,2)));
124 
125 #else /* __GNUC__ */
126 # define WINETEST_PRINTF_ATTR(fmt,args)
127 extern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... );
128 extern void __winetest_cdecl winetest_skip( const char *msg, ... );
129 extern void __winetest_cdecl winetest_win_skip( const char *msg, ... );
130 extern void __winetest_cdecl winetest_trace( const char *msg, ... );
131 
132 #endif /* __GNUC__ */
133 
134 #define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
135 #define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
136 #define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
137 #define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace
138 
139 #define ok ok_(__FILE__, __LINE__)
140 #define skip skip_(__FILE__, __LINE__)
141 #define win_skip win_skip_(__FILE__, __LINE__)
142 #define trace trace_(__FILE__, __LINE__)
143 
144 #define todo_if(is_todo) for (winetest_start_todo(is_todo); \
145  winetest_loop_todo(); \
146  winetest_end_todo())
147 
148 #define todo_ros todo_if(!strcmp(winetest_platform, "reactos"))
149 #define todo_ros_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "reactos"))
150 #ifdef USE_WINE_TODOS
151 #define todo_wine todo_ros
152 #define todo_wine_if todo_ros_if
153 #else
154 #define todo_wine todo_if(!strcmp(winetest_platform, "wine"))
155 #define todo_wine_if(is_todo) todo_if((is_todo) && !strcmp(winetest_platform, "wine"))
156 #endif
157 
158 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
159 
160 #ifdef NONAMELESSUNION
161 # define U(x) (x).u
162 # define U1(x) (x).u1
163 # define U2(x) (x).u2
164 # define U3(x) (x).u3
165 # define U4(x) (x).u4
166 # define U5(x) (x).u5
167 # define U6(x) (x).u6
168 # define U7(x) (x).u7
169 # define U8(x) (x).u8
170 #else
171 # define U(x) (x)
172 # define U1(x) (x)
173 # define U2(x) (x)
174 # define U3(x) (x)
175 # define U4(x) (x)
176 # define U5(x) (x)
177 # define U6(x) (x)
178 # define U7(x) (x)
179 # define U8(x) (x)
180 #endif
181 
182 #ifdef NONAMELESSSTRUCT
183 # define S(x) (x).s
184 # define S1(x) (x).s1
185 # define S2(x) (x).s2
186 # define S3(x) (x).s3
187 # define S4(x) (x).s4
188 # define S5(x) (x).s5
189 #else
190 # define S(x) (x)
191 # define S1(x) (x)
192 # define S2(x) (x)
193 # define S3(x) (x)
194 # define S4(x) (x)
195 # define S5(x) (x)
196 #endif
197 
198 
199 /************************************************************************/
200 /* Below is the implementation of the various functions, to be included
201  * directly into the generated testlist.c file.
202  * It is done that way so that the dlls can build the test routines with
203  * different includes or flags if needed.
204  */
205 
206 #ifdef STANDALONE
207 
208 #include <stdio.h>
209 
210 #if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
211 # define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg)
212 # define __winetest_va_end(list) __builtin_ms_va_end(list)
213 #else
214 # define __winetest_va_start(list,arg) va_start(list,arg)
215 # define __winetest_va_end(list) va_end(list)
216 #endif
217 
218 /* Define WINETEST_MSVC_IDE_FORMATTING to alter the output format winetest will use for file/line numbers.
219  This alternate format makes the file/line numbers clickable in visual studio, to directly jump to them. */
220 #if defined(WINETEST_MSVC_IDE_FORMATTING)
221 # define __winetest_file_line_prefix "%s(%d)"
222 #else
223 # define __winetest_file_line_prefix "%s:%d"
224 #endif
225 
226 struct test
227 {
228  const char *name;
229  void (*func)(void);
230 };
231 
232 extern const struct test winetest_testlist[];
233 
234 /* debug level */
235 int winetest_debug = 1;
236 
237 /* interactive mode? */
238 int winetest_interactive = 0;
239 
240 /* current platform */
241 const char *winetest_platform = "windows";
242 
243 /* report successful tests (BOOL) */
244 static int report_success = 0;
245 
246 /* passing arguments around */
247 static int winetest_argc;
248 static char** winetest_argv;
249 
250 static const struct test *current_test; /* test currently being run */
251 
252 static LONG successes; /* number of successful tests */
253 static LONG failures; /* number of failures */
254 static LONG skipped; /* number of skipped test chunks */
255 static LONG todo_successes; /* number of successful tests inside todo block */
256 static LONG todo_failures; /* number of failures inside todo block */
257 
258 /* The following data must be kept track of on a per-thread basis */
259 typedef struct
260 {
261  const char* current_file; /* file of current check */
262  int current_line; /* line of current check */
263  unsigned int todo_level; /* current todo nesting level */
264  int todo_do_loop;
265  char *str_pos; /* position in debug buffer */
266  char strings[2000]; /* buffer for debug strings */
267 } tls_data;
268 static DWORD tls_index;
269 
270 static tls_data* get_tls_data(void)
271 {
272  tls_data* data;
274 
275  last_error=GetLastError();
276  data=(tls_data*)TlsGetValue(tls_index);
277  if (!data)
278  {
279  data=(tls_data*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(tls_data));
280  data->str_pos = data->strings;
281  TlsSetValue(tls_index,data);
282  }
283  SetLastError(last_error);
284  return data;
285 }
286 
287 /* allocate some tmp space for a string */
288 static char *get_temp_buffer( size_t n )
289 {
290  tls_data *data = get_tls_data();
291  char *res = data->str_pos;
292 
293  if (res + n >= &data->strings[sizeof(data->strings)]) res = data->strings;
294  data->str_pos = res + n;
295  return res;
296 }
297 
298 /* release extra space that we requested in gimme1() */
299 static void release_temp_buffer( char *ptr, size_t size )
300 {
301  tls_data *data = get_tls_data();
302  data->str_pos = ptr + size;
303 }
304 
305 static void exit_process( int code )
306 {
307  fflush( stdout );
308  ExitProcess( code );
309 }
310 
311 
312 void winetest_set_location( const char* file, int line )
313 {
314  tls_data* data=get_tls_data();
315 #if defined(WINETEST_MSVC_IDE_FORMATTING)
316  data->current_file = file;
317 #else
318  data->current_file=strrchr(file,'/');
319  if (data->current_file==NULL)
320  data->current_file=strrchr(file,'\\');
321  if (data->current_file==NULL)
322  data->current_file=file;
323  else
324  data->current_file++;
325 #endif
326  data->current_line=line;
327 }
328 
329 int broken( int condition )
330 {
331  return ((strcmp(winetest_platform, "windows") == 0)
332 #ifndef USE_WINE_TODOS
333  || (strcmp(winetest_platform, "reactos") == 0)
334 #endif
335  ) && condition;
336 }
337 
338 /*
339  * Checks condition.
340  * Parameters:
341  * - condition - condition to check;
342  * - msg test description;
343  * - file - test application source code file name of the check
344  * - line - test application source code file line number of the check
345  * Return:
346  * 0 if condition does not have the expected value, 1 otherwise
347  */
348 int winetest_vok( int condition, const char *msg, __winetest_va_list args )
349 {
350  tls_data* data=get_tls_data();
351 
352  if (data->todo_level)
353  {
354  if (condition)
355  {
356  fprintf( stdout, __winetest_file_line_prefix ": Test succeeded inside todo block: ",
357  data->current_file, data->current_line );
358  vfprintf(stdout, msg, args);
359  InterlockedIncrement(&todo_failures);
360  return 0;
361  }
362  else
363  {
364  /* show todos even if traces are disabled*/
365  /*if (winetest_debug > 0)*/
366  {
367  fprintf( stdout, __winetest_file_line_prefix ": Test marked todo: ",
368  data->current_file, data->current_line );
369  vfprintf(stdout, msg, args);
370  }
371  InterlockedIncrement(&todo_successes);
372  return 1;
373  }
374  }
375  else
376  {
377  if (!condition)
378  {
379  fprintf( stdout, __winetest_file_line_prefix ": Test failed: ",
380  data->current_file, data->current_line );
381  vfprintf(stdout, msg, args);
382  InterlockedIncrement(&failures);
383  return 0;
384  }
385  else
386  {
387  if (report_success)
388  fprintf( stdout, __winetest_file_line_prefix ": Test succeeded\n",
389  data->current_file, data->current_line);
390  InterlockedIncrement(&successes);
391  return 1;
392  }
393  }
394 }
395 
396 void __winetest_cdecl winetest_ok( int condition, const char *msg, ... )
397 {
399 
400  __winetest_va_start(valist, msg);
401  winetest_vok(condition, msg, valist);
402  __winetest_va_end(valist);
403 }
404 
405 void __winetest_cdecl winetest_trace( const char *msg, ... )
406 {
408  tls_data* data=get_tls_data();
409 
410  if (winetest_debug > 0)
411  {
412  fprintf( stdout, __winetest_file_line_prefix ": ", data->current_file, data->current_line );
413  __winetest_va_start(valist, msg);
414  vfprintf(stdout, msg, valist);
415  __winetest_va_end(valist);
416  }
417 }
418 
419 void winetest_vskip( const char *msg, __winetest_va_list args )
420 {
421  tls_data* data=get_tls_data();
422 
423  fprintf( stdout, __winetest_file_line_prefix ": Tests skipped: ", data->current_file, data->current_line );
424  vfprintf(stdout, msg, args);
425  skipped++;
426 }
427 
428 void __winetest_cdecl winetest_skip( const char *msg, ... )
429 {
431  __winetest_va_start(valist, msg);
432  winetest_vskip(msg, valist);
433  __winetest_va_end(valist);
434 }
435 
436 void __winetest_cdecl winetest_win_skip( const char *msg, ... )
437 {
439  __winetest_va_start(valist, msg);
440  if ((strcmp(winetest_platform, "windows") == 0)
441 #ifndef USE_WINE_TODOS
442  || (strcmp(winetest_platform, "reactos") == 0)
443 #endif
444  )
445  winetest_vskip(msg, valist);
446  else
447  winetest_vok(0, msg, valist);
448  __winetest_va_end(valist);
449 }
450 
451 void winetest_start_todo( int is_todo )
452 {
453  tls_data* data=get_tls_data();
454  data->todo_level = (data->todo_level << 1) | (is_todo != 0);
455  data->todo_do_loop=1;
456 }
457 
458 int winetest_loop_todo(void)
459 {
460  tls_data* data=get_tls_data();
461  int do_loop=data->todo_do_loop;
462  data->todo_do_loop=0;
463  return do_loop;
464 }
465 
466 void winetest_end_todo(void)
467 {
468  tls_data* data=get_tls_data();
469  data->todo_level >>= 1;
470 }
471 
472 int winetest_get_mainargs( char*** pargv )
473 {
474  *pargv = winetest_argv;
475  return winetest_argc;
476 }
477 
479 {
480  return failures;
481 }
482 
483 void winetest_add_failures( LONG new_failures )
484 {
485  while (new_failures-- > 0)
486  InterlockedIncrement( &failures );
487 }
488 
490 {
491  DWORD exit_code = 1;
492 
493  if (WaitForSingleObject( process, 30000 ))
494  fprintf( stdout, "%s: child process wait failed\n", current_test->name );
495  else
496  GetExitCodeProcess( process, &exit_code );
497 
498  if (exit_code)
499  {
500  if (exit_code > 255)
501  {
502  fprintf( stdout, "%s: exception 0x%08x in child process\n", current_test->name, (unsigned)exit_code );
503  InterlockedIncrement( &failures );
504  }
505  else
506  {
507  fprintf( stdout, "%s: %u failures in child process\n",
508  current_test->name, (unsigned)exit_code );
509  while (exit_code-- > 0)
510  InterlockedIncrement(&failures);
511  }
512  }
513 }
514 
515 const char *wine_dbgstr_wn( const WCHAR *str, intptr_t n )
516 {
517  char *dst, *res;
518  size_t size;
519 
520  if (!((ULONG_PTR)str >> 16))
521  {
522  if (!str) return "(null)";
523  res = get_temp_buffer( 6 );
524  sprintf( res, "#%04x", LOWORD(str) );
525  return res;
526  }
527  if (n == -1)
528  {
529  const WCHAR *end = str;
530  while (*end) end++;
531  n = end - str;
532  }
533  if (n < 0) n = 0;
534  size = 12 + min( 300, n * 5 );
535  dst = res = get_temp_buffer( size );
536  *dst++ = 'L';
537  *dst++ = '"';
538  while (n-- > 0 && dst <= res + size - 10)
539  {
540  WCHAR c = *str++;
541  switch (c)
542  {
543  case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
544  case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
545  case '\t': *dst++ = '\\'; *dst++ = 't'; break;
546  case '"': *dst++ = '\\'; *dst++ = '"'; break;
547  case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
548  default:
549  if (c >= ' ' && c <= 126)
550  *dst++ = (char)c;
551  else
552  {
553  *dst++ = '\\';
554  sprintf(dst,"%04x",c);
555  dst+=4;
556  }
557  }
558  }
559  *dst++ = '"';
560  if (n > 0)
561  {
562  *dst++ = '.';
563  *dst++ = '.';
564  *dst++ = '.';
565  }
566  *dst++ = 0;
567  release_temp_buffer( res, dst - res );
568  return res;
569 }
570 
571 const char *wine_dbgstr_guid( const GUID *guid )
572 {
573  char *res;
574 
575  if (!guid) return "(null)";
576  res = get_temp_buffer( 39 ); /* CHARS_IN_GUID */
577  sprintf( res, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
578  guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
579  guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
580  guid->Data4[5], guid->Data4[6], guid->Data4[7] );
581  return res;
582 }
583 
584 const char *wine_dbgstr_point( const POINT *point )
585 {
586  char *res;
587 
588  if (!point) return "(null)";
589  res = get_temp_buffer( 60 );
590 #ifdef __ROS_LONG64__
591  sprintf( res, "(%d,%d)", point->x, point->y );
592 #else
593  sprintf( res, "(%ld,%ld)", point->x, point->y );
594 #endif
595  release_temp_buffer( res, strlen(res) + 1 );
596  return res;
597 }
598 
599 const char *wine_dbgstr_size( const SIZE *size )
600 {
601  char *res;
602 
603  if (!size) return "(null)";
604  res = get_temp_buffer( 60 );
605 #ifdef __ROS_LONG64__
606  sprintf( res, "(%d,%d)", size->cx, size->cy );
607 #else
608  sprintf( res, "(%ld,%ld)", size->cx, size->cy );
609 #endif
610  release_temp_buffer( res, strlen(res) + 1 );
611  return res;
612 }
613 
614 const char *wine_dbgstr_rect( const RECT *rect )
615 {
616  char *res;
617 
618  if (!rect) return "(null)";
619  res = get_temp_buffer( 60 );
620 #ifdef __ROS_LONG64__
621  sprintf( res, "(%d,%d)-(%d,%d)", rect->left, rect->top, rect->right, rect->bottom );
622 #else
623  sprintf( res, "(%ld,%ld)-(%ld,%ld)", rect->left, rect->top, rect->right, rect->bottom );
624 #endif
625  release_temp_buffer( res, strlen(res) + 1 );
626  return res;
627 }
628 
629 #ifdef WINETEST_USE_DBGSTR_LONGLONG
630 const char *wine_dbgstr_longlong( ULONGLONG ll )
631 {
632  char *res;
633 
634  res = get_temp_buffer( 20 );
635  if (/*sizeof(ll) > sizeof(unsigned long) &&*/ ll >> 32) /* ULONGLONG is always > long in ReactOS */
636  sprintf( res, "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
637  else
638  sprintf( res, "%lx", (unsigned long)ll );
639  release_temp_buffer( res, strlen(res) + 1 );
640  return res;
641 }
642 #endif
643 
644 /* Find a test by name */
645 static const struct test *find_test( const char *name )
646 {
647  const struct test *test;
648  const char *p;
649  size_t len;
650 
651  if ((p = strrchr( name, '/' ))) name = p + 1;
652  if ((p = strrchr( name, '\\' ))) name = p + 1;
653  len = strlen(name);
654  if (len > 2 && !strcmp( name + len - 2, ".c" )) len -= 2;
655 
656  for (test = winetest_testlist; test->name; test++)
657  {
658  if (!strncmp( test->name, name, len ) && !test->name[len]) break;
659  }
660  return test->name ? test : NULL;
661 }
662 
663 
664 /* Display list of valid tests */
665 static void list_tests(void)
666 {
667  const struct test *test;
668 
669  fprintf( stdout, "Valid test names:\n" );
670  for (test = winetest_testlist; test->name; test++) fprintf( stdout, " %s\n", test->name );
671 }
672 
673 /* Disable false-positive claiming "test" would be NULL-dereferenced */
674 #if defined(_MSC_VER)
675 #pragma warning(push)
676 #pragma warning(disable:28182)
677 #endif
678 
679 /* Run a named test, and return exit status */
680 static int run_test( const char *name )
681 {
682  const struct test *test;
683  int status;
684 
685  if (!(test = find_test( name )))
686  {
687  fprintf( stdout, "Fatal: test '%s' does not exist.\n", name );
688  exit_process(1);
689  }
690  successes = failures = todo_successes = todo_failures = 0;
691  tls_index=TlsAlloc();
692  current_test = test;
693  test->func();
694 
695  /* show test results even if traces are disabled */
696  /*if (winetest_debug)*/
697  {
698  fprintf( stdout, "\n%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
699  test->name, (int)(successes + failures + todo_successes + todo_failures),
700  (int)todo_successes, (int)(failures + todo_failures),
701  (failures + todo_failures != 1) ? "failures" : "failure",
702  (int)skipped );
703  }
704  status = (failures + todo_failures < 255) ? failures + todo_failures : 255;
705  return status;
706 }
707 
708 #if defined(_MSC_VER)
709 #pragma warning(pop)
710 #endif
711 
712 /* Display usage and exit */
713 static void usage( const char *argv0 )
714 {
715  fprintf( stdout, "Usage: %s test_name\n\n", argv0 );
716  list_tests();
717  exit_process(1);
718 }
719 
720 
721 /* main function */
722 int main( int argc, char **argv )
723 {
724  char p[128];
725 
726  setvbuf (stdout, NULL, _IONBF, 0);
727 
728  winetest_argc = argc;
729  winetest_argv = argv;
730 
731  if (GetEnvironmentVariableA( "WINETEST_PLATFORM", p, sizeof(p) )) winetest_platform = _strdup(p);
732  if (GetEnvironmentVariableA( "WINETEST_DEBUG", p, sizeof(p) )) winetest_debug = atoi(p);
733  if (GetEnvironmentVariableA( "WINETEST_INTERACTIVE", p, sizeof(p) )) winetest_interactive = atoi(p);
734  if (GetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", p, sizeof(p) )) report_success = atoi(p);
735 
736  if (!winetest_interactive) SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX );
737 
738  if (!argv[1])
739  {
740  if (winetest_testlist[0].name && !winetest_testlist[1].name) /* only one test */
741  return run_test( winetest_testlist[0].name );
742  usage( argv[0] );
743  }
744  if (!strcmp( argv[1], "--list" ))
745  {
746  list_tests();
747  return 0;
748  }
749  return run_test(argv[1]);
750 }
751 
752 #endif /* STANDALONE */
753 
754 // hack for ntdll winetest (this is defined in excpt.h)
755 #undef exception_info
756 
757 // Some helpful definitions
758 
759 #define ok_hex(expression, result) \
760  do { \
761  int _value = (expression); \
762  ok(_value == (result), "Wrong value for '%s', expected: " #result " (0x%x), got: 0x%x\n", \
763  #expression, (int)(result), _value); \
764  } while (0)
765 
766 #define ok_dec(expression, result) \
767  do { \
768  int _value = (expression); \
769  ok(_value == (result), "Wrong value for '%s', expected: " #result " (%d), got: %d\n", \
770  #expression, (int)(result), _value); \
771  } while (0)
772 
773 #define ok_ptr(expression, result) \
774  do { \
775  void *_value = (expression); \
776  ok(_value == (result), "Wrong value for '%s', expected: " #result " (%p), got: %p\n", \
777  #expression, (void*)(result), _value); \
778  } while (0)
779 
780 #define ok_size_t(expression, result) \
781  do { \
782  size_t _value = (expression); \
783  ok(_value == (result), "Wrong value for '%s', expected: " #result " (%Ix), got: %Ix\n", \
784  #expression, (size_t)(result), _value); \
785  } while (0)
786 
787 #define ok_char(expression, result) ok_hex(expression, result)
788 
789 #define ok_err(error) \
790  ok(GetLastError() == (error), "Wrong last error. Expected " #error ", got 0x%lx\n", GetLastError())
791 
792 #define ok_str(x, y) \
793  ok(strcmp(x, y) == 0, "Wrong string. Expected '%s', got '%s'\n", y, x)
794 
795 #define ok_wstr(x, y) \
796  ok(wcscmp(x, y) == 0, "Wrong string. Expected '%S', got '%S'\n", y, x)
797 
798 #define ok_long(expression, result) ok_hex(expression, result)
799 #define ok_int(expression, result) ok_dec(expression, result)
800 #define ok_ntstatus(status, expected) ok_hex(status, expected)
801 #define ok_hdl ok_ptr
802 
803 #ifdef __cplusplus
804 } /* extern "C" */
805 #endif
806 
807 #endif /* __WINE_WINE_TEST_H */
UINT WINAPI SetErrorMode(IN UINT uMode)
Definition: except.c:753
static int argc
Definition: ServiceArgs.c:12
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 **
Definition: typeof.h:47
long y
Definition: polytest.cpp:48
#define SEM_FAILCRITICALERRORS
Definition: rtltypes.h:69
long x
Definition: polytest.cpp:48
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1199
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1198
int main(int argc, char *argv[])
Definition: atactl.cpp:1685
LONG top
Definition: windef.h:297
static char * get_temp_buffer(int size)
Definition: registry.c:62
const char * wine_dbgstr_guid(const GUID *guid)
VOID WINAPI ExitProcess(IN UINT uExitCode)
Definition: proc.c:1517
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define test
Definition: rosglue.h:37
#define run_test(info, expect_button, seq, context)
Definition: taskdialog.c:134
GLuint GLuint end
Definition: gl.h:1545
int winetest_interactive
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
LONG left
Definition: windef.h:296
#define _strdup
Definition: debug_ros.c:7
LONG right
Definition: windef.h:298
Definition: match.c:390
#define __winetest_va_list
Definition: test.h:111
int winetest_debug
POINTL point
Definition: edittest.c:50
& rect
Definition: startmenu.cpp:1413
static char ** argv
Definition: ServiceArgs.c:11
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
FILE * stdout
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLuint n
Definition: s_context.h:57
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
const GUID * guid
long LONG
Definition: pedump.c:60
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
int winetest_loop_todo(void)
static PVOID ptr
Definition: dispmode.c:27
void winetest_start_todo(int is_todo)
GLenum condition
Definition: glext.h:9255
const WCHAR * str
UINT msg
Definition: msvc.h:92
void winetest_end_todo(void)
smooth NULL
Definition: ftsmooth.c:416
unsigned char
Definition: typeof.h:27
void winetest_vskip(const char *msg, __winetest_va_list ap)
LONG cx
Definition: windef.h:324
static int winetest_strcmpW(const WCHAR *str1, const WCHAR *str2)
Definition: test.h:83
Definition: parser.c:48
TCHAR str_pos[MAX_LOADSTRING]
Definition: sndrec32.cpp:58
const char * winetest_platform
static UINT exit_code
Definition: process.c:78
void __winetest_cdecl winetest_trace(const char *msg,...)
#define __winetest_cdecl
Definition: test.h:110
const char * wine_dbgstr_point(const POINT *guid)
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define GetEnvironmentVariableA(x, y, z)
Definition: compat.h:411
static const char * wine_dbgstr_w(const WCHAR *s)
Definition: test.h:79
int intptr_t
Definition: crtdefs.h:283
void __winetest_cdecl winetest_ok(int condition, const char *msg,...)
uint64_t ULONGLONG
Definition: typedefs.h:65
const char file[]
Definition: icontest.c:11
const GLubyte * c
Definition: glext.h:8905
const char * wine_dbgstr_rect(const RECT *rect)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
int winetest_get_mainargs(char ***pargv)
GLsizei const GLchar *const * strings
Definition: glext.h:7622
char line[200]
Definition: main.c:97
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
static char argv0[MAX_PATH]
Definition: shlexec.c:56
GLdouble s
Definition: gl.h:2039
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1023
static INT do_loop(const PropSheetInfo *psInfo)
Definition: propsheet.c:2781
#define SEM_NOGPFAULTERRORBOX
Definition: rtltypes.h:70
static void release_temp_buffer(char *buffer, size_t size)
Definition: debug.c:350
void winetest_wait_child_process(HANDLE process)
#define InterlockedIncrement
Definition: armddk.h:53
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
const char * wine_dbgstr_size(const SIZE *guid)
w ll
Definition: byte_order.h:166
#define min(a, b)
Definition: monoChain.cc:55
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1163
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
Definition: name.c:36
void int int ULONGLONG int va_list * ap
Definition: winesup.h:32
GLuint res
Definition: glext.h:9613
void __winetest_cdecl winetest_skip(const char *msg,...)
#define const
Definition: zconf.h:230
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:41
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
void __winetest_cdecl winetest_win_skip(const char *msg,...)
LONG bottom
Definition: windef.h:299
_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
Definition: printf.c:59
#define _IONBF
Definition: stdio.h:130
const char * wine_dbgstr_wn(const WCHAR *str, intptr_t n)
Definition: compat.c:342
int broken(int condition)
GLfloat GLfloat p
Definition: glext.h:8902
tls_data_t * get_tls_data(void)
Definition: urlmon_main.c:62
_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
Definition: service.c:31
LONG cy
Definition: windef.h:325
#define LOWORD(l)
Definition: pedump.c:82
DWORD tls_index
#define printf
Definition: config.h:203
void winetest_set_location(const char *file, int line)
Definition: fci.c:126
GLuint const GLchar * name
Definition: glext.h:6031