test.h revision 930b5f872e89407f445d4000d4e4aaecaa6a0998
/*
* Definitions for Wine C unit tests.
*
* Copyright (C) 2002 Alexandre Julliard
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#ifndef __WINE_WINE_TEST_H
#define __WINE_WINE_TEST_H
#include <stdarg.h>
#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#ifdef __WINE_CONFIG_H
#endif
#ifdef __WINE_WINE_LIBRARY_H
#endif
#ifdef __WINE_WINE_UNICODE_H
#endif
#ifdef __WINE_WINE_DEBUG_H
#endif
#ifndef INVALID_FILE_ATTRIBUTES
#define INVALID_FILE_ATTRIBUTES (~0u)
#endif
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER (~0u)
#endif
/* debug level */
extern int winetest_debug;
/* running in interactive mode? */
extern int winetest_interactive;
/* current platform */
extern const char *winetest_platform;
extern void winetest_start_todo( const char* platform );
extern int winetest_loop_todo(void);
extern void winetest_end_todo( const char* platform );
extern int winetest_get_mainargs( char*** pargv );
extern LONG winetest_get_failures(void);
/* strcmpW is available for tests compiled under Wine, but not in standalone
* builds under Windows, so we reimplement it under a different name. */
{
}
#ifdef STANDALONE
#define START_TEST(name) \
#else
#endif
#define __winetest_cdecl __cdecl
#else
#define __winetest_cdecl
#define __winetest_va_list va_list
#endif
#ifdef __GNUC__
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__ */
#endif /* __GNUC__ */
winetest_loop_todo(); \
#ifdef NONAMELESSUNION
# define U(x) (x).u
#else
# define U(x) (x)
# define U1(x) (x)
# define U2(x) (x)
# define U3(x) (x)
# define U4(x) (x)
# define U5(x) (x)
# define U6(x) (x)
# define U7(x) (x)
# define U8(x) (x)
#endif
#ifdef NONAMELESSSTRUCT
# define S(x) (x).s
#else
# define S(x) (x)
# define S1(x) (x)
# define S2(x) (x)
# define S3(x) (x)
# define S4(x) (x)
# define S5(x) (x)
#endif
/************************************************************************/
/* Below is the implementation of the various functions, to be included
* directly into the generated testlist.c file.
* It is done that way so that the dlls can build the test routines with
* different includes or flags if needed.
*/
#ifdef STANDALONE
#include <stdio.h>
#include <excpt.h>
#else
#endif
struct test
{
const char *name;
void (*func)(void);
};
extern const struct test winetest_testlist[];
/* debug level */
int winetest_debug = 1;
/* interactive mode? */
int winetest_interactive = 0;
/* current platform */
const char *winetest_platform = "windows";
/* report successful tests (BOOL) */
static int report_success = 0;
/* passing arguments around */
static int winetest_argc;
static char** winetest_argv;
/* The following data must be kept track of on a per-thread basis */
typedef struct
{
const char* current_file; /* file of current check */
int current_line; /* line of current check */
int todo_level; /* current todo nesting level */
int todo_do_loop;
char *str_pos; /* position in debug buffer */
} tls_data;
static tls_data* get_tls_data(void)
{
if (!data)
{
}
return data;
}
/* allocate some tmp space for a string */
static char *get_temp_buffer( size_t n )
{
return res;
}
/* release extra space that we requested in gimme1() */
{
}
static void exit_process( int code )
{
ExitProcess( code );
}
{
else
data->current_file++;
}
{
}
/*
* Checks condition.
* Parameters:
* - condition - condition to check;
* - msg test description;
* - file - test application source code file name of the check
* - line - test application source code file line number of the check
* Return:
* 0 if condition does not have the expected value, 1 otherwise
*/
{
if (data->todo_level)
{
if (condition)
{
return 0;
}
else
{
if (winetest_debug > 0)
{
}
return 1;
}
}
else
{
if (!condition)
{
return 0;
}
else
{
if (report_success)
return 1;
}
}
}
{
}
{
if (winetest_debug > 0)
{
}
}
{
skipped++;
}
{
}
{
else
}
void winetest_start_todo( const char* platform )
{
data->todo_level++;
}
int winetest_loop_todo(void)
{
data->todo_do_loop=0;
return do_loop;
}
void winetest_end_todo( const char* platform )
{
{
data->todo_level--;
}
}
int winetest_get_mainargs( char*** pargv )
{
*pargv = winetest_argv;
return winetest_argc;
}
LONG winetest_get_failures(void)
{
return failures;
}
{
while (new_failures-- > 0)
}
{
else
if (exit_code)
{
if (exit_code > 255)
{
}
else
{
while (exit_code-- > 0)
}
}
}
{
{
if (!str) return "(null)";
return res;
}
if (n == -1)
{
}
if (n < 0) n = 0;
*dst++ = 'L';
*dst++ = '"';
{
switch (c)
{
default:
if (c >= ' ' && c <= 126)
*dst++ = c;
else
{
*dst++ = '\\';
dst+=4;
}
}
}
*dst++ = '"';
if (n > 0)
{
*dst++ = '.';
*dst++ = '.';
*dst++ = '.';
}
*dst++ = 0;
return res;
}
/* Find a test by name */
{
const char *p;
{
}
}
/* Display list of valid tests */
static void list_tests(void)
{
}
/* Run a named test, and return exit status */
{
int status;
{
exit_process(1);
}
current_test = test;
if (winetest_debug)
{
skipped );
}
return status;
}
/* Display usage and exit */
{
list_tests();
exit_process(1);
}
/* trap unhandled exceptions */
{
if (data->current_file)
return EXCEPTION_EXECUTE_HANDLER;
}
#ifdef __GNUC__
void _fpreset(void) {} /* override the mingw fpu init code */
#endif
/* main function */
{
char p[128];
if (GetEnvironmentVariableA( "WINETEST_INTERACTIVE", p, sizeof(p) )) winetest_interactive = atoi(p);
if (!argv[1])
{
}
{
list_tests();
return 0;
}
}
#endif /* STANDALONE */
#endif /* __WINE_WINE_TEST_H */