test.h revision 3194da424708abdd288b28d96892b3a5f3f7df0b
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * Definitions for Wine C unit tests.
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * Copyright (C) 2002 Alexandre Julliard
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * This library is free software; you can redistribute it and/or
c58f1213e628a545081c70e26c6b67a841cff880vboxsync * modify it under the terms of the GNU Lesser General Public
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * License as published by the Free Software Foundation; either
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * version 2.1 of the License, or (at your option) any later version.
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * This library is distributed in the hope that it will be useful,
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * Lesser General Public License for more details.
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * You should have received a copy of the GNU Lesser General Public
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync * License along with this library; if not, write to the Free Software
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync#error wine/library.h should not be used in Wine tests
01ea175f55740168d1dd0af3277d3b86a30b4f91vboxsync#error wine/unicode.h should not be used in Wine tests
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync#error wine/debug.h should not be used in Wine tests
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync/* debug level */
6a008ce8150c1391d9e0dda0cdf9485b3c806034vboxsync/* running in interactive mode? */
1b959a8e2774712c95bd7628282e9e41f0c5f03evboxsync/* current platform */
6a008ce8150c1391d9e0dda0cdf9485b3c806034vboxsyncextern const char *winetest_platform;
6a008ce8150c1391d9e0dda0cdf9485b3c806034vboxsyncextern void winetest_set_location( const char* file, int line );
9040f019271f91b98e1320c0a8c38a42636e3979vboxsyncextern void winetest_start_todo( const char* platform );
6a008ce8150c1391d9e0dda0cdf9485b3c806034vboxsyncextern int winetest_loop_todo(void);
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsyncextern void winetest_end_todo( const char* platform );
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsyncextern void winetest_add_failures( LONG new_failures );
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsyncextern void winetest_wait_child_process( HANDLE process );
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsyncextern const char *wine_dbgstr_wn( const WCHAR *str, int n );
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsyncstatic inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync/* strcmpW is available for tests compiled under Wine, but not in standalone
f6bee36bd88580a116ce05e7c58e7799c599a782vboxsync * builds under Windows, so we reimplement it under a different name. */
f6bee36bd88580a116ce05e7c58e7799c599a782vboxsyncstatic inline int winetest_strcmpW( const WCHAR *str1, const WCHAR *str2 )
f6bee36bd88580a116ce05e7c58e7799c599a782vboxsync while (*str1 && (*str1 == *str2)) { str1++; str2++; }
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsync const struct test winetest_testlist[] = { { #name, func_##name }, { 0, 0 } }; \
edd67c61375d89ff863e754caff339cd1ac77b38vboxsync#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncextern int winetest_vok( int condition, const char *msg, __winetest_va_list ap );
715e49c31b15c23c17a9ce3be42a75e7c48d4b78vboxsyncextern void winetest_vskip( const char *msg, __winetest_va_list ap );
fe0826de96da565f5a285504b2210f269b8a2de9vboxsyncextern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
fe0826de96da565f5a285504b2210f269b8a2de9vboxsyncextern void __winetest_cdecl winetest_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
fe0826de96da565f5a285504b2210f269b8a2de9vboxsyncextern void __winetest_cdecl winetest_win_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
fe0826de96da565f5a285504b2210f269b8a2de9vboxsyncextern void __winetest_cdecl winetest_trace( const char *msg, ... ) __attribute__((format (printf,1,2)));
339a5a0150dcebd28f8aab6f2e3c293d95405ca9vboxsync#else /* __GNUC__ */
c285785ffc9f35513e0c6e7e2a05df3090dc919cvboxsyncextern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... );
fe0826de96da565f5a285504b2210f269b8a2de9vboxsyncextern void __winetest_cdecl winetest_skip( const char *msg, ... );
fe0826de96da565f5a285504b2210f269b8a2de9vboxsyncextern void __winetest_cdecl winetest_win_skip( const char *msg, ... );
fe0826de96da565f5a285504b2210f269b8a2de9vboxsyncextern void __winetest_cdecl winetest_trace( const char *msg, ... );
fe0826de96da565f5a285504b2210f269b8a2de9vboxsync#endif /* __GNUC__ */
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync#define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
winetest_loop_todo(); \
#ifdef NONAMELESSUNION
# 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)
#ifdef NONAMELESSSTRUCT
# define S1(x) (x)
# define S2(x) (x)
# define S3(x) (x)
# define S4(x) (x)
# define S5(x) (x)
* directly into the generated testlist.c file.
#ifdef STANDALONE
#include <stdio.h>
#include <excpt.h>
struct test
const char *name;
void (*func)(void);
int winetest_interactive = 0;
static int report_success = 0;
static int winetest_argc;
static char** winetest_argv;
int todo_do_loop;
} tls_data;
if (!data)
return data;
return res;
if (condition)
if (winetest_debug > 0)
if (!condition)
if (report_success)
if (winetest_debug > 0)
skipped++;
int winetest_loop_todo(void)
return do_loop;
return winetest_argc;
return failures;
while (new_failures-- > 0)
if (exit_code)
while (exit_code-- > 0)
return res;
*dst++ = c;
*dst++ = 0;
return res;
static void list_tests(void)
int status;
if (winetest_debug)
skipped );
return status;
list_tests();
return EXCEPTION_EXECUTE_HANDLER;
#ifdef __GNUC__
if (GetEnvironmentVariableA( "WINETEST_INTERACTIVE", p, sizeof(p) )) winetest_interactive = atoi(p);
list_tests();