2020-06-11 16:47:41 +02:00
|
|
|
/*
|
|
|
|
* ntoskrnl.exe testing framework
|
|
|
|
*
|
|
|
|
* Copyright 2015 Sebastian Lackner
|
|
|
|
* Copyright 2015 Michael Müller
|
|
|
|
* Copyright 2015 Christian Costa
|
2020-06-30 16:49:00 +02:00
|
|
|
* Copyright 2020 Paul Gofman for CodeWeavers
|
2021-04-07 05:42:21 +02:00
|
|
|
* Copyright 2020-2021 Zebediah Figura for CodeWeavers
|
2020-06-11 16:47:41 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <windef.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include <winternl.h>
|
|
|
|
|
|
|
|
#include <ddk/wdm.h>
|
|
|
|
|
|
|
|
#if !defined(__WINE_USE_MSVCRT) || defined(__MINGW32__)
|
|
|
|
#define __WINE_PRINTF_ATTR(fmt,args) __attribute__((format (printf,fmt,args)))
|
|
|
|
#else
|
|
|
|
#define __WINE_PRINTF_ATTR(fmt,args)
|
|
|
|
#endif
|
|
|
|
|
2020-06-11 16:47:41 +02:00
|
|
|
static HANDLE okfile;
|
|
|
|
static LONG successes;
|
|
|
|
static LONG failures;
|
|
|
|
static LONG skipped;
|
|
|
|
static LONG todo_successes;
|
|
|
|
static LONG todo_failures;
|
2021-07-05 10:44:51 +02:00
|
|
|
static LONG muted_traces;
|
|
|
|
static LONG muted_skipped;
|
|
|
|
static LONG muted_todo_successes;
|
|
|
|
|
2020-06-11 16:47:41 +02:00
|
|
|
static int running_under_wine;
|
|
|
|
static int winetest_debug;
|
|
|
|
static int winetest_report_success;
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
/* silence todos and skips above this threshold */
|
2021-08-10 11:31:18 +02:00
|
|
|
static int winetest_mute_threshold = 42;
|
2021-07-05 10:44:51 +02:00
|
|
|
|
|
|
|
/* counts how many times a given line printed a message */
|
|
|
|
static LONG line_counters[16384];
|
|
|
|
|
|
|
|
/* The following data must be kept track of on a per-thread basis */
|
|
|
|
struct tls_data
|
|
|
|
{
|
|
|
|
HANDLE thread;
|
|
|
|
const char* current_file; /* file of current check */
|
|
|
|
int current_line; /* line of current check */
|
|
|
|
unsigned 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 */
|
|
|
|
char context[8][128]; /* data to print before messages */
|
|
|
|
unsigned int context_count; /* number of context prefixes */
|
|
|
|
};
|
|
|
|
|
|
|
|
static KSPIN_LOCK tls_data_lock;
|
|
|
|
static struct tls_data tls_data_pool[128];
|
|
|
|
static DWORD tls_data_count;
|
|
|
|
|
|
|
|
static inline struct tls_data *get_tls_data(void)
|
|
|
|
{
|
|
|
|
static struct tls_data tls_overflow;
|
|
|
|
struct tls_data *data;
|
|
|
|
HANDLE thread = PsGetCurrentThreadId();
|
|
|
|
KIRQL irql;
|
|
|
|
|
|
|
|
KeAcquireSpinLock(&tls_data_lock, &irql);
|
|
|
|
for (data = tls_data_pool; data != tls_data_pool + tls_data_count; ++data)
|
|
|
|
if (data->thread == thread) break;
|
|
|
|
if (data == tls_data_pool + ARRAY_SIZE(tls_data_pool))
|
|
|
|
data = &tls_overflow;
|
|
|
|
else if (data == tls_data_pool + tls_data_count)
|
|
|
|
{
|
|
|
|
data->thread = thread;
|
|
|
|
data->str_pos = data->strings;
|
|
|
|
tls_data_count++;
|
|
|
|
}
|
|
|
|
KeReleaseSpinLock(&tls_data_lock, irql);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void winetest_set_location( const char* file, int line )
|
|
|
|
{
|
|
|
|
struct tls_data *data = get_tls_data();
|
|
|
|
data->current_file=strrchr(file,'/');
|
|
|
|
if (data->current_file==NULL)
|
|
|
|
data->current_file=strrchr(file,'\\');
|
|
|
|
if (data->current_file==NULL)
|
|
|
|
data->current_file=file;
|
|
|
|
else
|
|
|
|
data->current_file++;
|
|
|
|
data->current_line=line;
|
|
|
|
}
|
|
|
|
|
2021-10-22 11:12:23 +02:00
|
|
|
static inline void kvprintf(const char *format, va_list ap)
|
2020-06-11 16:47:41 +02:00
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
struct tls_data *data = get_tls_data();
|
2020-06-11 16:47:41 +02:00
|
|
|
IO_STATUS_BLOCK io;
|
2021-07-05 10:44:51 +02:00
|
|
|
int len = vsnprintf(data->strings, sizeof(data->strings), format, ap);
|
|
|
|
ZwWriteFile(okfile, NULL, NULL, NULL, &io, data->strings, len, NULL, NULL);
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
static inline void WINAPIV kprintf(const char *format, ...) __WINE_PRINTF_ATTR(1,2);
|
2020-06-11 16:47:41 +02:00
|
|
|
static inline void WINAPIV kprintf(const char *format, ...)
|
|
|
|
{
|
2021-10-22 11:12:23 +02:00
|
|
|
va_list valist;
|
2020-06-11 16:47:41 +02:00
|
|
|
|
2021-10-22 11:12:23 +02:00
|
|
|
va_start(valist, format);
|
2020-06-11 16:47:41 +02:00
|
|
|
kvprintf(format, valist);
|
2021-10-22 11:12:23 +02:00
|
|
|
va_end(valist);
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
static inline void WINAPIV winetest_printf( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2);
|
|
|
|
static inline void WINAPIV winetest_printf( const char *msg, ... )
|
|
|
|
{
|
|
|
|
struct tls_data *data = get_tls_data();
|
2021-10-22 11:12:23 +02:00
|
|
|
va_list valist;
|
2021-07-05 10:44:51 +02:00
|
|
|
|
|
|
|
kprintf( "%s:%d: ", data->current_file, data->current_line );
|
2021-10-22 11:12:23 +02:00
|
|
|
va_start( valist, msg );
|
2021-07-05 10:44:51 +02:00
|
|
|
kvprintf( msg, valist );
|
2021-10-22 11:12:23 +02:00
|
|
|
va_end( valist );
|
2021-07-05 10:44:51 +02:00
|
|
|
}
|
|
|
|
|
2021-04-07 05:42:20 +02:00
|
|
|
static inline NTSTATUS winetest_init(void)
|
|
|
|
{
|
2021-04-07 05:42:21 +02:00
|
|
|
const struct test_data *data;
|
|
|
|
SIZE_T size = sizeof(*data);
|
2021-04-07 05:42:20 +02:00
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
UNICODE_STRING string;
|
|
|
|
IO_STATUS_BLOCK io;
|
2021-04-07 05:42:21 +02:00
|
|
|
void *addr = NULL;
|
|
|
|
HANDLE section;
|
|
|
|
NTSTATUS ret;
|
2021-04-07 05:42:20 +02:00
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
KeInitializeSpinLock(&tls_data_lock);
|
|
|
|
|
2021-04-07 05:42:21 +02:00
|
|
|
RtlInitUnicodeString(&string, L"\\BaseNamedObjects\\winetest_ntoskrnl_section");
|
2021-04-07 05:42:20 +02:00
|
|
|
/* OBJ_KERNEL_HANDLE is necessary for the file to be accessible from system threads */
|
|
|
|
InitializeObjectAttributes(&attr, &string, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 0, NULL);
|
2021-04-07 05:42:21 +02:00
|
|
|
if ((ret = ZwOpenSection(§ion, SECTION_MAP_READ, &attr)))
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if ((ret = ZwMapViewOfSection(section, NtCurrentProcess(), &addr,
|
|
|
|
0, 0, NULL, &size, ViewUnmap, 0, PAGE_READONLY)))
|
|
|
|
{
|
|
|
|
ZwClose(section);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
data = addr;
|
|
|
|
running_under_wine = data->running_under_wine;
|
|
|
|
winetest_debug = data->winetest_debug;
|
|
|
|
winetest_report_success = data->winetest_report_success;
|
|
|
|
|
|
|
|
ZwUnmapViewOfSection(NtCurrentProcess(), addr);
|
|
|
|
ZwClose(section);
|
|
|
|
|
|
|
|
RtlInitUnicodeString(&string, L"\\??\\C:\\windows\\winetest_ntoskrnl_okfile");
|
2021-04-07 05:42:20 +02:00
|
|
|
return ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io,
|
|
|
|
FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void winetest_cleanup(void)
|
|
|
|
{
|
2021-04-07 05:42:22 +02:00
|
|
|
struct test_data *data;
|
|
|
|
SIZE_T size = sizeof(*data);
|
|
|
|
OBJECT_ATTRIBUTES attr;
|
|
|
|
UNICODE_STRING string;
|
|
|
|
void *addr = NULL;
|
|
|
|
HANDLE section;
|
|
|
|
|
2021-04-07 05:42:20 +02:00
|
|
|
if (winetest_debug)
|
|
|
|
{
|
|
|
|
kprintf("%04x:ntoskrnl: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
|
2021-07-05 10:44:51 +02:00
|
|
|
(DWORD)(DWORD_PTR)PsGetCurrentProcessId(), successes + failures + todo_successes + todo_failures,
|
2021-04-07 05:42:20 +02:00
|
|
|
todo_successes, failures + todo_failures,
|
|
|
|
(failures + todo_failures != 1) ? "failures" : "failure", skipped );
|
|
|
|
}
|
2021-04-07 05:42:22 +02:00
|
|
|
|
|
|
|
RtlInitUnicodeString(&string, L"\\BaseNamedObjects\\winetest_ntoskrnl_section");
|
|
|
|
/* OBJ_KERNEL_HANDLE is necessary for the file to be accessible from system threads */
|
|
|
|
InitializeObjectAttributes(&attr, &string, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, 0, NULL);
|
|
|
|
|
|
|
|
if (!ZwOpenSection(§ion, SECTION_MAP_READ | SECTION_MAP_WRITE, &attr))
|
|
|
|
{
|
|
|
|
if (!ZwMapViewOfSection(section, NtCurrentProcess(), &addr,
|
|
|
|
0, 0, NULL, &size, ViewUnmap, 0, PAGE_READWRITE))
|
|
|
|
{
|
|
|
|
data = addr;
|
|
|
|
|
|
|
|
InterlockedExchangeAdd(&data->failures, failures);
|
|
|
|
InterlockedExchangeAdd(&data->todo_failures, todo_failures);
|
|
|
|
|
|
|
|
ZwUnmapViewOfSection(NtCurrentProcess(), addr);
|
|
|
|
}
|
|
|
|
ZwClose(section);
|
|
|
|
}
|
|
|
|
|
2021-04-07 05:42:20 +02:00
|
|
|
ZwClose(okfile);
|
|
|
|
}
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
static inline void winetest_print_context( const char *msgtype )
|
2020-06-11 16:47:41 +02:00
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
struct tls_data *data = get_tls_data();
|
|
|
|
unsigned int i;
|
2020-06-11 16:47:41 +02:00
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_printf( "%s", msgtype );
|
|
|
|
for (i = 0; i < data->context_count; ++i)
|
|
|
|
kprintf( "%s: ", data->context[i] );
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline LONG winetest_add_line( void )
|
|
|
|
{
|
|
|
|
struct tls_data *data;
|
|
|
|
int index, count;
|
|
|
|
|
|
|
|
if (winetest_debug > 1)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
data = get_tls_data();
|
|
|
|
index = data->current_line % ARRAY_SIZE(line_counters);
|
|
|
|
count = InterlockedIncrement(line_counters + index) - 1;
|
|
|
|
if (count == winetest_mute_threshold)
|
|
|
|
winetest_printf( "Line has been silenced after %d occurrences\n", winetest_mute_threshold );
|
2020-06-11 16:47:41 +02:00
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2021-10-22 11:12:23 +02:00
|
|
|
static inline int winetest_vok( int condition, const char *msg, va_list args )
|
2021-07-05 10:44:51 +02:00
|
|
|
{
|
|
|
|
struct tls_data *data = get_tls_data();
|
|
|
|
|
|
|
|
if (data->todo_level)
|
2020-06-11 16:47:41 +02:00
|
|
|
{
|
|
|
|
if (condition)
|
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_print_context( "Test succeeded inside todo block: " );
|
2020-06-11 16:47:41 +02:00
|
|
|
kvprintf(msg, args);
|
|
|
|
InterlockedIncrement(&todo_failures);
|
2021-07-05 10:44:51 +02:00
|
|
|
return 0;
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
if (!winetest_debug ||
|
|
|
|
winetest_add_line() < winetest_mute_threshold)
|
2020-06-11 16:47:41 +02:00
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
if (winetest_debug > 0)
|
|
|
|
{
|
|
|
|
winetest_print_context( "Test marked todo: " );
|
|
|
|
kvprintf(msg, args);
|
|
|
|
}
|
|
|
|
InterlockedIncrement(&todo_successes);
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
2021-07-05 10:44:51 +02:00
|
|
|
else
|
|
|
|
InterlockedIncrement(&muted_todo_successes);
|
|
|
|
return 1;
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!condition)
|
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_print_context( "Test failed: " );
|
2020-06-11 16:47:41 +02:00
|
|
|
kvprintf(msg, args);
|
|
|
|
InterlockedIncrement(&failures);
|
2021-07-05 10:44:51 +02:00
|
|
|
return 0;
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (winetest_report_success)
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_printf("Test succeeded\n");
|
2020-06-11 16:47:41 +02:00
|
|
|
InterlockedIncrement(&successes);
|
2021-07-05 10:44:51 +02:00
|
|
|
return 1;
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
static inline void WINAPIV winetest_ok( int condition, const char *msg, ... ) __WINE_PRINTF_ATTR(2,3);
|
|
|
|
static inline void WINAPIV winetest_ok( int condition, const char *msg, ... )
|
2020-06-11 16:47:41 +02:00
|
|
|
{
|
2021-10-22 11:12:23 +02:00
|
|
|
va_list args;
|
|
|
|
va_start(args, msg);
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_vok(condition, msg, args);
|
2021-10-22 11:12:23 +02:00
|
|
|
va_end(args);
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
2021-10-22 11:12:23 +02:00
|
|
|
static inline void winetest_vskip( const char *msg, va_list args )
|
2020-06-11 16:47:41 +02:00
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
if (winetest_add_line() < winetest_mute_threshold)
|
|
|
|
{
|
2021-09-13 10:48:59 +02:00
|
|
|
winetest_print_context( "Driver tests skipped: " );
|
2021-07-05 10:44:51 +02:00
|
|
|
kvprintf(msg, args);
|
|
|
|
InterlockedIncrement(&skipped);
|
|
|
|
}
|
2020-06-11 16:47:41 +02:00
|
|
|
else
|
2021-07-05 10:44:51 +02:00
|
|
|
InterlockedIncrement(&muted_skipped);
|
|
|
|
}
|
2020-06-11 16:47:41 +02:00
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
static inline void WINAPIV winetest_skip( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2);
|
|
|
|
static inline void WINAPIV winetest_skip( const char *msg, ... )
|
|
|
|
{
|
2021-10-22 11:12:23 +02:00
|
|
|
va_list args;
|
|
|
|
va_start(args, msg);
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_vskip(msg, args);
|
2021-10-22 11:12:23 +02:00
|
|
|
va_end(args);
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
static inline void WINAPIV winetest_win_skip( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2);
|
|
|
|
static inline void WINAPIV winetest_win_skip( const char *msg, ... )
|
2020-06-11 16:47:41 +02:00
|
|
|
{
|
2021-10-22 11:12:23 +02:00
|
|
|
va_list args;
|
|
|
|
va_start(args, msg);
|
2021-09-13 10:48:59 +02:00
|
|
|
if (!running_under_wine)
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_vskip(msg, args);
|
2020-06-11 16:47:41 +02:00
|
|
|
else
|
2021-07-05 10:44:51 +02:00
|
|
|
winetest_vok(0, msg, args);
|
2021-10-22 11:12:23 +02:00
|
|
|
va_end(args);
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
static inline void WINAPIV winetest_trace( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2);
|
|
|
|
static inline void WINAPIV winetest_trace( const char *msg, ... )
|
2021-04-14 16:40:00 +02:00
|
|
|
{
|
2021-10-22 11:12:23 +02:00
|
|
|
va_list args;
|
2021-04-14 16:40:00 +02:00
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
if (!winetest_debug)
|
|
|
|
return;
|
|
|
|
if (winetest_add_line() < winetest_mute_threshold)
|
|
|
|
{
|
|
|
|
winetest_print_context( "" );
|
2021-10-22 11:12:23 +02:00
|
|
|
va_start(args, msg);
|
2021-07-05 10:44:51 +02:00
|
|
|
kvprintf( msg, args );
|
2021-10-22 11:12:23 +02:00
|
|
|
va_end(args);
|
2021-07-05 10:44:51 +02:00
|
|
|
}
|
2021-04-14 16:40:00 +02:00
|
|
|
else
|
2021-07-05 10:44:51 +02:00
|
|
|
InterlockedIncrement(&muted_traces);
|
2021-04-14 16:40:00 +02:00
|
|
|
}
|
|
|
|
|
2020-06-11 16:47:41 +02:00
|
|
|
static inline void winetest_start_todo( int is_todo )
|
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
struct tls_data *data = get_tls_data();
|
|
|
|
data->todo_level = (data->todo_level << 1) | (is_todo != 0);
|
|
|
|
data->todo_do_loop=1;
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int winetest_loop_todo(void)
|
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
struct tls_data *data = get_tls_data();
|
|
|
|
int do_loop=data->todo_do_loop;
|
|
|
|
data->todo_do_loop=0;
|
2020-06-11 16:47:41 +02:00
|
|
|
return do_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void winetest_end_todo(void)
|
|
|
|
{
|
2021-07-05 10:44:51 +02:00
|
|
|
struct tls_data *data = get_tls_data();
|
|
|
|
data->todo_level >>= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void WINAPIV winetest_push_context( const char *fmt, ... ) __WINE_PRINTF_ATTR(1, 2);
|
|
|
|
static inline void WINAPIV winetest_push_context( const char *fmt, ... )
|
|
|
|
{
|
|
|
|
struct tls_data *data = get_tls_data();
|
2021-10-22 11:12:23 +02:00
|
|
|
va_list valist;
|
2021-07-05 10:44:51 +02:00
|
|
|
|
|
|
|
if (data->context_count < ARRAY_SIZE(data->context))
|
|
|
|
{
|
2021-10-22 11:12:23 +02:00
|
|
|
va_start(valist, fmt);
|
2021-07-05 10:44:51 +02:00
|
|
|
vsnprintf( data->context[data->context_count], sizeof(data->context[data->context_count]), fmt, valist );
|
2021-10-22 11:12:23 +02:00
|
|
|
va_end(valist);
|
2021-07-05 10:44:51 +02:00
|
|
|
data->context[data->context_count][sizeof(data->context[data->context_count]) - 1] = 0;
|
|
|
|
}
|
|
|
|
++data->context_count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void winetest_pop_context(void)
|
|
|
|
{
|
|
|
|
struct tls_data *data = get_tls_data();
|
|
|
|
|
|
|
|
if (data->context_count)
|
|
|
|
--data->context_count;
|
2020-06-11 16:47:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int broken(int condition)
|
|
|
|
{
|
|
|
|
return !running_under_wine && condition;
|
|
|
|
}
|
|
|
|
|
2021-07-05 10:44:51 +02:00
|
|
|
#ifdef WINETEST_NO_LINE_NUMBERS
|
|
|
|
# define subtest_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_subtest
|
|
|
|
# define ignore_exceptions_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_ignore_exceptions
|
|
|
|
# define ok_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_ok
|
|
|
|
# define skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_skip
|
|
|
|
# define win_skip_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_win_skip
|
|
|
|
# define trace_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_trace
|
|
|
|
# define wait_child_process_(file, line) (winetest_set_location(file, 0), 0) ? (void)0 : winetest_wait_child_process
|
|
|
|
#else
|
|
|
|
# define subtest_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_subtest
|
|
|
|
# define ignore_exceptions_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ignore_exceptions
|
|
|
|
# define ok_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_ok
|
|
|
|
# define skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_skip
|
|
|
|
# define win_skip_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_win_skip
|
|
|
|
# define trace_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_trace
|
|
|
|
# define wait_child_process_(file, line) (winetest_set_location(file, line), 0) ? (void)0 : winetest_wait_child_process
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define ok ok_(__FILE__, __LINE__)
|
|
|
|
#define skip skip_(__FILE__, __LINE__)
|
|
|
|
#define trace trace_(__FILE__, __LINE__)
|
|
|
|
#define win_skip win_skip_(__FILE__, __LINE__)
|
|
|
|
|
2020-06-11 16:47:41 +02:00
|
|
|
#define todo_if(is_todo) for (winetest_start_todo(is_todo); \
|
|
|
|
winetest_loop_todo(); \
|
|
|
|
winetest_end_todo())
|
|
|
|
#define todo_wine todo_if(running_under_wine)
|
|
|
|
#define todo_wine_if(is_todo) todo_if((is_todo) && running_under_wine)
|