mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 09:25:10 +00:00
sync test.h with wine 1.1.28
svn path=/trunk/; revision=42847
This commit is contained in:
parent
e6ac1a3fa7
commit
fb79881787
1 changed files with 82 additions and 1 deletions
|
@ -62,6 +62,9 @@ extern void winetest_end_todo( const char* platform );
|
|||
extern int winetest_get_mainargs( char*** pargv );
|
||||
extern void winetest_wait_child_process( HANDLE process );
|
||||
|
||||
extern const char *wine_dbgstr_wn( const WCHAR *str, int n );
|
||||
static inline const char *wine_dbgstr_w( const WCHAR *s ) { return wine_dbgstr_wn( s, -1 ); }
|
||||
|
||||
#ifdef STANDALONE
|
||||
#define START_TEST(name) \
|
||||
static void func_##name(void); \
|
||||
|
@ -196,6 +199,8 @@ typedef struct
|
|||
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 */
|
||||
char strings[2000]; /* buffer for debug strings */
|
||||
} tls_data;
|
||||
static DWORD tls_index;
|
||||
|
||||
|
@ -208,13 +213,33 @@ static tls_data* get_tls_data(void)
|
|||
data=TlsGetValue(tls_index);
|
||||
if (!data)
|
||||
{
|
||||
data=HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(tls_data));
|
||||
data=HeapAlloc(GetProcessHeap(), 0, sizeof(tls_data));
|
||||
data->todo_level = 0;
|
||||
data->str_pos = data->strings;
|
||||
TlsSetValue(tls_index,data);
|
||||
}
|
||||
SetLastError(last_error);
|
||||
return data;
|
||||
}
|
||||
|
||||
/* allocate some tmp space for a string */
|
||||
static char *get_temp_buffer( size_t n )
|
||||
{
|
||||
tls_data *data = get_tls_data();
|
||||
char *res = data->str_pos;
|
||||
|
||||
if (res + n >= &data->strings[sizeof(data->strings)]) res = data->strings;
|
||||
data->str_pos = res + n;
|
||||
return res;
|
||||
}
|
||||
|
||||
/* release extra space that we requested in gimme1() */
|
||||
static void release_temp_buffer( char *ptr, size_t size )
|
||||
{
|
||||
tls_data *data = get_tls_data();
|
||||
data->str_pos = ptr + size;
|
||||
}
|
||||
|
||||
static void exit_process( int code )
|
||||
{
|
||||
fflush( stdout );
|
||||
|
@ -407,6 +432,62 @@ void winetest_wait_child_process( HANDLE process )
|
|||
}
|
||||
}
|
||||
|
||||
const char *wine_dbgstr_wn( const WCHAR *str, int n )
|
||||
{
|
||||
char *dst, *res;
|
||||
size_t size;
|
||||
|
||||
if (!((ULONG_PTR)str >> 16))
|
||||
{
|
||||
if (!str) return "(null)";
|
||||
res = get_temp_buffer( 6 );
|
||||
sprintf( res, "#%04x", LOWORD(str) );
|
||||
return res;
|
||||
}
|
||||
if (n == -1)
|
||||
{
|
||||
const WCHAR *end = str;
|
||||
while (*end) end++;
|
||||
n = end - str;
|
||||
}
|
||||
if (n < 0) n = 0;
|
||||
size = 12 + min( 300, n * 5 );
|
||||
dst = res = get_temp_buffer( size );
|
||||
*dst++ = 'L';
|
||||
*dst++ = '"';
|
||||
while (n-- > 0 && dst <= res + size - 10)
|
||||
{
|
||||
WCHAR c = *str++;
|
||||
switch (c)
|
||||
{
|
||||
case '\n': *dst++ = '\\'; *dst++ = 'n'; break;
|
||||
case '\r': *dst++ = '\\'; *dst++ = 'r'; break;
|
||||
case '\t': *dst++ = '\\'; *dst++ = 't'; break;
|
||||
case '"': *dst++ = '\\'; *dst++ = '"'; break;
|
||||
case '\\': *dst++ = '\\'; *dst++ = '\\'; break;
|
||||
default:
|
||||
if (c >= ' ' && c <= 126)
|
||||
*dst++ = c;
|
||||
else
|
||||
{
|
||||
*dst++ = '\\';
|
||||
sprintf(dst,"%04x",c);
|
||||
dst+=4;
|
||||
}
|
||||
}
|
||||
}
|
||||
*dst++ = '"';
|
||||
if (n > 0)
|
||||
{
|
||||
*dst++ = '.';
|
||||
*dst++ = '.';
|
||||
*dst++ = '.';
|
||||
}
|
||||
*dst++ = 0;
|
||||
release_temp_buffer( res, dst - res );
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Find a test by name */
|
||||
static const struct test *find_test( const char *name )
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue