3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/*
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Definitions for Wine C unit tests.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Copyright (C) 2002 Alexandre Julliard
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * This library is free software; you can redistribute it and/or
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * modify it under the terms of the GNU Lesser General Public
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * License as published by the Free Software Foundation; either
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * version 2.1 of the License, or (at your option) any later version.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * This library is distributed in the hope that it will be useful,
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * but WITHOUT ANY WARRANTY; without even the implied warranty of
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Lesser General Public License for more details.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * You should have received a copy of the GNU Lesser General Public
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * License along with this library; if not, write to the Free Software
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync/*
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * other than GPL or LGPL is available it will apply instead, Oracle elects to use only
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * a choice of LGPL license versions is made available with the language indicating
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * that LGPLv2 or any later version may be used, or where a choice of which version
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync * of the LGPL is applied is otherwise unspecified.
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync */
930b5f872e89407f445d4000d4e4aaecaa6a0998vboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifndef __WINE_WINE_TEST_H
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define __WINE_WINE_TEST_H
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include <stdarg.h>
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include <stdlib.h>
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include <windef.h>
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include <winbase.h>
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef __WINE_CONFIG_H
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#error config.h should not be used in Wine tests
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef __WINE_WINE_LIBRARY_H
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#error wine/library.h should not be used in Wine tests
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef __WINE_WINE_UNICODE_H
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#error wine/unicode.h should not be used in Wine tests
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef __WINE_WINE_DEBUG_H
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#error wine/debug.h should not be used in Wine tests
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifndef INVALID_FILE_ATTRIBUTES
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define INVALID_FILE_ATTRIBUTES (~0u)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifndef INVALID_SET_FILE_POINTER
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define INVALID_SET_FILE_POINTER (~0u)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* debug level */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern int winetest_debug;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* running in interactive mode? */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern int winetest_interactive;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* current platform */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern const char *winetest_platform;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void winetest_set_location( const char* file, int line );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void winetest_start_todo( const char* platform );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern int winetest_loop_todo(void);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void winetest_end_todo( const char* platform );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern int winetest_get_mainargs( char*** pargv );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern LONG winetest_get_failures(void);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void winetest_add_failures( LONG new_failures );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void winetest_wait_child_process( HANDLE process );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern const char *wine_dbgstr_wn( const WCHAR *str, int n );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* strcmpW is available for tests compiled under Wine, but not in standalone
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * builds under Windows, so we reimplement it under a different name. */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic inline int winetest_strcmpW( const WCHAR *str1, const WCHAR *str2 )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync while (*str1 && (*str1 == *str2)) { str1++; str2++; }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return *str1 - *str2;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef STANDALONE
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define START_TEST(name) \
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync static void func_##name(void); \
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const struct test winetest_testlist[] = { { #name, func_##name }, { 0, 0 } }; \
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync static void func_##name(void)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define START_TEST(name) void func_##name(void)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define __winetest_cdecl __cdecl
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define __winetest_va_list __builtin_ms_va_list
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define __winetest_cdecl
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define __winetest_va_list va_list
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern int broken( int condition );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern int winetest_vok( int condition, const char *msg, __winetest_va_list ap );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void winetest_vskip( const char *msg, __winetest_va_list ap );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef __GNUC__
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... ) __attribute__((format (printf,2,3) ));
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_win_skip( const char *msg, ... ) __attribute__((format (printf,1,2)));
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_trace( const char *msg, ... ) __attribute__((format (printf,1,2)));
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#else /* __GNUC__ */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_ok( int condition, const char *msg, ... );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_skip( const char *msg, ... );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_win_skip( const char *msg, ... );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern void __winetest_cdecl winetest_trace( const char *msg, ... );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif /* __GNUC__ */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define ok ok_(__FILE__, __LINE__)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define skip skip_(__FILE__, __LINE__)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define win_skip win_skip_(__FILE__, __LINE__)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define trace trace_(__FILE__, __LINE__)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define todo(platform) for (winetest_start_todo(platform); \
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_loop_todo(); \
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_end_todo(platform))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#define todo_wine todo("wine")
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef NONAMELESSUNION
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U(x) (x).u
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U1(x) (x).u1
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U2(x) (x).u2
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U3(x) (x).u3
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U4(x) (x).u4
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U5(x) (x).u5
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U6(x) (x).u6
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U7(x) (x).u7
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U8(x) (x).u8
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U1(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U2(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U3(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U4(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U5(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U6(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U7(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define U8(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef NONAMELESSSTRUCT
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S(x) (x).s
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S1(x) (x).s1
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S2(x) (x).s2
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S3(x) (x).s3
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S4(x) (x).s4
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S5(x) (x).s5
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S1(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S2(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S3(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S4(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define S5(x) (x)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/************************************************************************/
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* Below is the implementation of the various functions, to be included
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * directly into the generated testlist.c file.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * It is done that way so that the dlls can build the test routines with
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * different includes or flags if needed.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef STANDALONE
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include <stdio.h>
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#include <excpt.h>
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#if defined(__x86_64__) && defined(__GNUC__) && defined(__WINE_USE_MSVCRT)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define __winetest_va_start(list,arg) __builtin_ms_va_start(list,arg)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define __winetest_va_end(list) __builtin_ms_va_end(list)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define __winetest_va_start(list,arg) va_start(list,arg)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync# define __winetest_va_end(list) va_end(list)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstruct test
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const char *name;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync void (*func)(void);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync};
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncextern const struct test winetest_testlist[];
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* debug level */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint winetest_debug = 1;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* interactive mode? */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint winetest_interactive = 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* current platform */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncconst char *winetest_platform = "windows";
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* report successful tests (BOOL) */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic int report_success = 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* passing arguments around */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic int winetest_argc;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic char** winetest_argv;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic const struct test *current_test; /* test currently being run */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic LONG successes; /* number of successful tests */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic LONG failures; /* number of failures */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic LONG skipped; /* number of skipped test chunks */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic LONG todo_successes; /* number of successful tests inside todo block */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic LONG todo_failures; /* number of failures inside todo block */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* The following data must be kept track of on a per-thread basis */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsynctypedef struct
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const char* current_file; /* file of current check */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync int current_line; /* line of current check */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync int todo_level; /* current todo nesting level */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync int todo_do_loop;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync char *str_pos; /* position in debug buffer */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync char strings[2000]; /* buffer for debug strings */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync} tls_data;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic DWORD tls_index;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic tls_data* get_tls_data(void)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync DWORD last_error;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync last_error=GetLastError();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data=TlsGetValue(tls_index);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!data)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data=HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(tls_data));
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->str_pos = data->strings;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync TlsSetValue(tls_index,data);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync SetLastError(last_error);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return data;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* allocate some tmp space for a string */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic char *get_temp_buffer( size_t n )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data *data = get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync char *res = data->str_pos;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (res + n >= &data->strings[sizeof(data->strings)]) res = data->strings;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->str_pos = res + n;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return res;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* release extra space that we requested in gimme1() */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic void release_temp_buffer( char *ptr, size_t size )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data *data = get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->str_pos = ptr + size;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic void exit_process( int code )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fflush( stdout );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ExitProcess( code );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid winetest_set_location( const char* file, int line )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data=get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file=strrchr(file,'/');
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (data->current_file==NULL)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file=strrchr(file,'\\');
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (data->current_file==NULL)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file=file;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file++;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_line=line;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint broken( int condition )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return (strcmp(winetest_platform, "windows") == 0) && condition;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/*
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Checks condition.
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Parameters:
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * - condition - condition to check;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * - msg test description;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * - file - test application source code file name of the check
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * - line - test application source code file line number of the check
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * Return:
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync * 0 if condition does not have the expected value, 1 otherwise
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint winetest_vok( int condition, const char *msg, __winetest_va_list args )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data=get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (data->todo_level)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (condition)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s:%d: Test succeeded inside todo block: ",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file, data->current_line );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vfprintf(stdout, msg, args);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync InterlockedIncrement(&todo_failures);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (winetest_debug > 0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s:%d: Test marked todo: ",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file, data->current_line );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vfprintf(stdout, msg, args);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync InterlockedIncrement(&todo_successes);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 1;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!condition)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s:%d: Test failed: ",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file, data->current_line );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vfprintf(stdout, msg, args);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync InterlockedIncrement(&failures);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (report_success)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s:%d: Test succeeded\n",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file, data->current_line);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync InterlockedIncrement(&successes);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 1;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid __winetest_cdecl winetest_ok( int condition, const char *msg, ... )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_list valist;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_start(valist, msg);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_vok(condition, msg, valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_end(valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid __winetest_cdecl winetest_trace( const char *msg, ... )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_list valist;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data=get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (winetest_debug > 0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s:%d: ", data->current_file, data->current_line );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_start(valist, msg);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vfprintf(stdout, msg, valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_end(valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid winetest_vskip( const char *msg, __winetest_va_list args )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data=get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s:%d: Tests skipped: ", data->current_file, data->current_line );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync vfprintf(stdout, msg, args);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync skipped++;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid __winetest_cdecl winetest_skip( const char *msg, ... )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_list valist;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_start(valist, msg);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_vskip(msg, valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_end(valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid __winetest_cdecl winetest_win_skip( const char *msg, ... )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_list valist;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_start(valist, msg);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (strcmp(winetest_platform, "windows") == 0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_vskip(msg, valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_vok(0, msg, valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync __winetest_va_end(valist);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid winetest_start_todo( const char* platform )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data=get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (strcmp(winetest_platform,platform)==0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->todo_level++;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->todo_do_loop=1;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint winetest_loop_todo(void)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data=get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync int do_loop=data->todo_do_loop;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->todo_do_loop=0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return do_loop;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid winetest_end_todo( const char* platform )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (strcmp(winetest_platform,platform)==0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data* data=get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->todo_level--;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint winetest_get_mainargs( char*** pargv )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *pargv = winetest_argv;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return winetest_argc;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncLONG winetest_get_failures(void)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return failures;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid winetest_add_failures( LONG new_failures )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync while (new_failures-- > 0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync InterlockedIncrement( &failures );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid winetest_wait_child_process( HANDLE process )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync DWORD exit_code = 1;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (WaitForSingleObject( process, 30000 ))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s: child process wait failed\n", current_test->name );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync GetExitCodeProcess( process, &exit_code );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (exit_code)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (exit_code > 255)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s: exception 0x%08x in child process\n", current_test->name, exit_code );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync InterlockedIncrement( &failures );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s: %u failures in child process\n",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync current_test->name, exit_code );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync while (exit_code-- > 0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync InterlockedIncrement(&failures);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncconst char *wine_dbgstr_wn( const WCHAR *str, int n )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync char *dst, *res;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync size_t size;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!((ULONG_PTR)str >> 16))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!str) return "(null)";
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync res = get_temp_buffer( 6 );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync sprintf( res, "#%04x", LOWORD(str) );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return res;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (n == -1)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const WCHAR *end = str;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync while (*end) end++;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync n = end - str;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (n < 0) n = 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync size = 12 + min( 300, n * 5 );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync dst = res = get_temp_buffer( size );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = 'L';
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = '"';
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync while (n-- > 0 && dst <= res + size - 10)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync WCHAR c = *str++;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync switch (c)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync case '\t': *dst++ = '\\'; *dst++ = 't'; break;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync case '"': *dst++ = '\\'; *dst++ = '"'; break;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync default:
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (c >= ' ' && c <= 126)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = c;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync else
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = '\\';
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync sprintf(dst,"%04x",c);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync dst+=4;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = '"';
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (n > 0)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = '.';
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = '.';
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = '.';
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync *dst++ = 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync release_temp_buffer( res, dst - res );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return res;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* Find a test by name */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic const struct test *find_test( const char *name )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const struct test *test;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const char *p;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync size_t len;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if ((p = strrchr( name, '/' ))) name = p + 1;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if ((p = strrchr( name, '\\' ))) name = p + 1;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync len = strlen(name);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (len > 2 && !strcmp( name + len - 2, ".c" )) len -= 2;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync for (test = winetest_testlist; test->name; test++)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!strncmp( test->name, name, len ) && !test->name[len]) break;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return test->name ? test : NULL;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* Display list of valid tests */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic void list_tests(void)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const struct test *test;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "Valid test names:\n" );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync for (test = winetest_testlist; test->name; test++) fprintf( stdout, " %s\n", test->name );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* Run a named test, and return exit status */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic int run_test( const char *name )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync const struct test *test;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync int status;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!(test = find_test( name )))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "Fatal: test '%s' does not exist.\n", name );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync exit_process(1);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync successes = failures = todo_successes = todo_failures = 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_index=TlsAlloc();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync current_test = test;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync test->func();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (winetest_debug)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync test->name, successes + failures + todo_successes + todo_failures,
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync todo_successes, failures + todo_failures,
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync (failures + todo_failures != 1) ? "failures" : "failure",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync skipped );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync status = (failures + todo_failures < 255) ? failures + todo_failures : 255;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return status;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* Display usage and exit */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic void usage( const char *argv0 )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "Usage: %s test_name\n\n", argv0 );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync list_tests();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync exit_process(1);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* trap unhandled exceptions */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncstatic LONG CALLBACK exc_filter( EXCEPTION_POINTERS *ptrs )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync tls_data *data = get_tls_data();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (data->current_file)
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s:%d: this is the last test seen before the exception\n",
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync data->current_file, data->current_line );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fprintf( stdout, "%s: unhandled exception %08x at %p\n", current_test->name,
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync ptrs->ExceptionRecord->ExceptionCode, ptrs->ExceptionRecord->ExceptionAddress );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync fflush( stdout );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return EXCEPTION_EXECUTE_HANDLER;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#ifdef __GNUC__
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncvoid _fpreset(void) {} /* override the mingw fpu init code */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync/* main function */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsyncint main( int argc, char **argv )
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync{
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync char p[128];
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync setvbuf (stdout, NULL, _IONBF, 0);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_argc = argc;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync winetest_argv = argv;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (GetEnvironmentVariableA( "WINETEST_PLATFORM", p, sizeof(p) )) winetest_platform = strdup(p);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (GetEnvironmentVariableA( "WINETEST_DEBUG", p, sizeof(p) )) winetest_debug = atoi(p);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (GetEnvironmentVariableA( "WINETEST_INTERACTIVE", p, sizeof(p) )) winetest_interactive = atoi(p);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (GetEnvironmentVariableA( "WINETEST_REPORT_SUCCESS", p, sizeof(p) )) report_success = atoi(p);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!strcmp( winetest_platform, "windows" )) SetUnhandledExceptionFilter( exc_filter );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!winetest_interactive) SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!argv[1])
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (winetest_testlist[0].name && !winetest_testlist[1].name) /* only one test */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return run_test( winetest_testlist[0].name );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync usage( argv[0] );
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync if (!strcmp( argv[1], "--list" ))
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync {
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync list_tests();
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return 0;
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync }
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync return run_test(argv[1]);
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync}
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif /* STANDALONE */
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync
3194da424708abdd288b28d96892b3a5f3f7df0bvboxsync#endif /* __WINE_WINE_TEST_H */