Adding support for thread local test data and context.
Signed-off-by: Rémi Bernon <rbernon(a)codeweavers.com>
---
v2: Adapt wine/test.h code instead of copying it and including
wine/test.h
dlls/ntoskrnl.exe/tests/Makefile.in | 10 +-
dlls/ntoskrnl.exe/tests/driver.c | 32 +--
dlls/ntoskrnl.exe/tests/driver.h | 10 +-
dlls/ntoskrnl.exe/tests/driver_netio.c | 2 +-
dlls/ntoskrnl.exe/tests/ntoskrnl.c | 1 +
dlls/ntoskrnl.exe/tests/utils.h | 290 ++++++++++++++++++++-----
6 files changed, 258 insertions(+), 87 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/Makefile.in b/dlls/ntoskrnl.exe/tests/Makefile.in
index 863fad30f63..85a6925138a 100644
--- a/dlls/ntoskrnl.exe/tests/Makefile.in
+++ b/dlls/ntoskrnl.exe/tests/Makefile.in
@@ -1,15 +1,15 @@
TESTDLL = ntoskrnl.exe
IMPORTS = advapi32 crypt32 newdev setupapi user32 wintrust ws2_32 hid
-driver_IMPORTS = winecrt0 ntoskrnl
+driver_IMPORTS = winecrt0 ntoskrnl hal
driver_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
-driver2_IMPORTS = winecrt0 ntoskrnl
+driver2_IMPORTS = winecrt0 ntoskrnl hal
driver2_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
-driver3_IMPORTS = winecrt0 ntoskrnl
+driver3_IMPORTS = winecrt0 ntoskrnl hal
driver3_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
-driver_hid_IMPORTS = winecrt0 ntoskrnl hidclass
+driver_hid_IMPORTS = winecrt0 ntoskrnl hal hidclass
driver_hid_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
-driver_netio_IMPORTS = winecrt0 ntoskrnl netio
+driver_netio_IMPORTS = winecrt0 ntoskrnl hal netio
driver_netio_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
driver_pnp_IMPORTS = winecrt0 ntoskrnl hal
driver_pnp_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c
index 94139b4b654..1fe3ec2e558 100644
--- a/dlls/ntoskrnl.exe/tests/driver.c
+++ b/dlls/ntoskrnl.exe/tests/driver.c
@@ -999,41 +999,41 @@ static void test_call_driver(DEVICE_OBJECT *device)
irp = IoBuildAsynchronousFsdRequest(IRP_MJ_FLUSH_BUFFERS, device, NULL, 0, NULL, &iosb);
ok(irp->UserIosb == &iosb, "unexpected UserIosb\n");
ok(!irp->Cancel, "Cancel = %x\n", irp->Cancel);
- ok(!irp->CancelRoutine, "CancelRoutine = %x\n", irp->CancelRoutine);
+ ok(!irp->CancelRoutine, "CancelRoutine = %p\n", irp->CancelRoutine);
ok(!irp->UserEvent, "UserEvent = %p\n", irp->UserEvent);
ok(irp->CurrentLocation == 2, "CurrentLocation = %u\n", irp->CurrentLocation);
ok(irp->Tail.Overlay.Thread == (PETHREAD)KeGetCurrentThread(),
"IRP thread is not the current thread\n");
ok(!irp->IoStatus.Status, "got status %#x\n", irp->IoStatus.Status);
- ok(!irp->IoStatus.Information, "got information %#x\n", irp->IoStatus.Information);
+ ok(!irp->IoStatus.Information, "got information %#I64x\n", (UINT64)irp->IoStatus.Information);
ok(iosb.Status == 0xdeadbeef, "got status %#x\n", iosb.Status);
- ok(iosb.Information == 0xdeadbeef, "got information %#x\n", iosb.Information);
+ ok(iosb.Information == 0xdeadbeef, "got information %#I64x\n", (UINT64)iosb.Information);
irpsp = IoGetNextIrpStackLocation(irp);
ok(irpsp->MajorFunction == IRP_MJ_FLUSH_BUFFERS, "MajorFunction = %u\n", irpsp->MajorFunction);
- ok(!irpsp->DeviceObject, "DeviceObject = %u\n", irpsp->DeviceObject);
- ok(!irpsp->FileObject, "FileObject = %u\n", irpsp->FileObject);
+ ok(!irpsp->DeviceObject, "DeviceObject = %p\n", irpsp->DeviceObject);
+ ok(!irpsp->FileObject, "FileObject = %p\n", irpsp->FileObject);
ok(!irpsp->CompletionRoutine, "CompletionRoutine = %p\n", irpsp->CompletionRoutine);
status = IoCallDriver(device, irp);
ok(status == STATUS_PENDING, "IoCallDriver returned %#x\n", status);
ok(!irp->IoStatus.Status, "got status %#x\n", irp->IoStatus.Status);
- ok(!irp->IoStatus.Information, "got information %#x\n", irp->IoStatus.Information);
+ ok(!irp->IoStatus.Information, "got information %#I64x\n", (UINT64)irp->IoStatus.Information);
ok(iosb.Status == 0xdeadbeef, "got status %#x\n", iosb.Status);
- ok(iosb.Information == 0xdeadbeef, "got information %#x\n", iosb.Information);
+ ok(iosb.Information == 0xdeadbeef, "got information %#I64x\n", (UINT64)iosb.Information);
irp->IoStatus.Status = STATUS_SUCCESS;
irp->IoStatus.Information = 123;
IoCompleteRequest(irp, IO_NO_INCREMENT);
ok(iosb.Status == STATUS_SUCCESS, "got status %#x\n", iosb.Status);
- ok(iosb.Information == 123, "got information %#x\n", iosb.Information);
+ ok(iosb.Information == 123, "got information %#I64x\n", (UINT64)iosb.Information);
KeInitializeEvent(&event, NotificationEvent, FALSE);
irp = IoBuildSynchronousFsdRequest(IRP_MJ_FLUSH_BUFFERS, device, NULL, 0, NULL, &event, &iosb);
ok(irp->UserIosb == &iosb, "unexpected UserIosb\n");
ok(!irp->Cancel, "Cancel = %x\n", irp->Cancel);
- ok(!irp->CancelRoutine, "CancelRoutine = %x\n", irp->CancelRoutine);
+ ok(!irp->CancelRoutine, "CancelRoutine = %p\n", irp->CancelRoutine);
ok(irp->UserEvent == &event, "UserEvent = %p\n", irp->UserEvent);
ok(irp->CurrentLocation == 2, "CurrentLocation = %u\n", irp->CurrentLocation);
ok(irp->Tail.Overlay.Thread == (PETHREAD)KeGetCurrentThread(),
@@ -1041,8 +1041,8 @@ static void test_call_driver(DEVICE_OBJECT *device)
irpsp = IoGetNextIrpStackLocation(irp);
ok(irpsp->MajorFunction == IRP_MJ_FLUSH_BUFFERS, "MajorFunction = %u\n", irpsp->MajorFunction);
- ok(!irpsp->DeviceObject, "DeviceObject = %u\n", irpsp->DeviceObject);
- ok(!irpsp->FileObject, "FileObject = %u\n", irpsp->FileObject);
+ ok(!irpsp->DeviceObject, "DeviceObject = %p\n", irpsp->DeviceObject);
+ ok(!irpsp->FileObject, "FileObject = %p\n", irpsp->FileObject);
ok(!irpsp->CompletionRoutine, "CompletionRoutine = %p\n", irpsp->CompletionRoutine);
status = wait_single(&event, 0);
@@ -1118,7 +1118,7 @@ static void test_cancel_irp(DEVICE_OBJECT *device)
ok(irp->CurrentLocation == 1, "CurrentLocation = %u\n", irp->CurrentLocation);
irpsp = IoGetCurrentIrpStackLocation(irp);
- ok(irpsp->DeviceObject == device, "DeviceObject = %u\n", irpsp->DeviceObject);
+ ok(irpsp->DeviceObject == device, "DeviceObject = %p\n", irpsp->DeviceObject);
IoSetCancelRoutine(irp, cancel_irp);
cancel_cnt = 0;
@@ -1432,16 +1432,16 @@ static void check_resource_(int line, ERESOURCE *resource, ULONG exclusive_waite
ULONG count;
count = ExGetExclusiveWaiterCount(resource);
- ok_(__FILE__, line, count == exclusive_waiters,
+ ok_(__FILE__, line)(count == exclusive_waiters,
"expected %u exclusive waiters, got %u\n", exclusive_waiters, count);
count = ExGetSharedWaiterCount(resource);
- ok_(__FILE__, line, count == shared_waiters,
+ ok_(__FILE__, line)(count == shared_waiters,
"expected %u shared waiters, got %u\n", shared_waiters, count);
ret = ExIsResourceAcquiredExclusiveLite(resource);
- ok_(__FILE__, line, ret == exclusive,
+ ok_(__FILE__, line)(ret == exclusive,
"expected exclusive %u, got %u\n", exclusive, ret);
count = ExIsResourceAcquiredSharedLite(resource);
- ok_(__FILE__, line, count == shared_count,
+ ok_(__FILE__, line)(count == shared_count,
"expected shared %u, got %u\n", shared_count, count);
}
#define check_resource(a,b,c,d,e) check_resource_(__LINE__,a,b,c,d,e)
diff --git a/dlls/ntoskrnl.exe/tests/driver.h b/dlls/ntoskrnl.exe/tests/driver.h
index 455695ad36b..8c41010c503 100644
--- a/dlls/ntoskrnl.exe/tests/driver.h
+++ b/dlls/ntoskrnl.exe/tests/driver.h
@@ -54,7 +54,8 @@ struct test_data
int running_under_wine;
int winetest_report_success;
int winetest_debug;
- int successes, failures, skipped, todo_successes, todo_failures;
+ int failures;
+ int todo_failures;
};
struct main_test_input
@@ -64,13 +65,6 @@ struct main_test_input
ULONG64 *modified_value;
};
-static inline char *drv_strrchr( const char *str, char ch )
-{
- char *ret = NULL;
- do { if (*str == ch) ret = (char *)(ULONG_PTR)str; } while (*str++);
- return ret;
-}
-
static const GUID control_class = {0xdeadbeef, 0x29ef, 0x4538, {0xa5, 0xfd, 0xb6, 0x95, 0x73, 0xa3, 0x62, 0xc0}};
#define SERVER_LISTEN_PORT 9374
diff --git a/dlls/ntoskrnl.exe/tests/driver_netio.c b/dlls/ntoskrnl.exe/tests/driver_netio.c
index ea9cfd1a4c5..4ebacc7cf14 100644
--- a/dlls/ntoskrnl.exe/tests/driver_netio.c
+++ b/dlls/ntoskrnl.exe/tests/driver_netio.c
@@ -141,7 +141,7 @@ static void test_wsk_get_address_info(void)
{
struct sockaddr_in *addr = (struct sockaddr_in *)addr_info->ai_addr;
- ok(addr_info->ai_addrlen == sizeof(*addr), "Got unexpected ai_addrlen %u.\n", addr_info->ai_addrlen);
+ ok(addr_info->ai_addrlen == sizeof(*addr), "Got unexpected ai_addrlen %I64u.\n", (UINT64)addr_info->ai_addrlen);
ok(addr->sin_family == AF_INET, "Got unexpected sin_family %u.\n", addr->sin_family);
ok(ntohs(addr->sin_port) == 12345, "Got unexpected sin_port %u.\n", ntohs(addr->sin_port));
ok(ntohl(addr->sin_addr.s_addr) == 0x7f000001, "Got unexpected sin_addr %#x.\n",
diff --git a/dlls/ntoskrnl.exe/tests/ntoskrnl.c b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
index 71dbfe1a5e9..797421904c8 100644
--- a/dlls/ntoskrnl.exe/tests/ntoskrnl.c
+++ b/dlls/ntoskrnl.exe/tests/ntoskrnl.c
@@ -386,6 +386,7 @@ static void cat_okfile(void)
SetEndOfFile(okfile);
winetest_add_failures(InterlockedExchange(&test_data->failures, 0));
+ winetest_add_failures(InterlockedExchange(&test_data->todo_failures, 0));
}
static ULONG64 modified_value;
diff --git a/dlls/ntoskrnl.exe/tests/utils.h b/dlls/ntoskrnl.exe/tests/utils.h
index 6a0e00428a5..f73f6f938ca 100644
--- a/dlls/ntoskrnl.exe/tests/utils.h
+++ b/dlls/ntoskrnl.exe/tests/utils.h
@@ -22,25 +22,103 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#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
+
static HANDLE okfile;
static LONG successes;
static LONG failures;
static LONG skipped;
static LONG todo_successes;
static LONG todo_failures;
-static int todo_level, todo_do_loop;
+static LONG muted_traces;
+static LONG muted_skipped;
+static LONG muted_todo_successes;
+
static int running_under_wine;
static int winetest_debug;
static int winetest_report_success;
+/* silence todos and skips above this threshold */
+static int winetest_mute_threshold = 42;
+
+/* 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;
+}
+
static inline void kvprintf(const char *format, __ms_va_list ap)
{
- static char buffer[512];
+ struct tls_data *data = get_tls_data();
IO_STATUS_BLOCK io;
- int len = vsnprintf(buffer, sizeof(buffer), format, ap);
- ZwWriteFile(okfile, NULL, NULL, NULL, &io, buffer, len, NULL, NULL);
+ int len = vsnprintf(data->strings, sizeof(data->strings), format, ap);
+ ZwWriteFile(okfile, NULL, NULL, NULL, &io, data->strings, len, NULL, NULL);
}
+static inline void WINAPIV kprintf(const char *format, ...) __WINE_PRINTF_ATTR(1,2);
static inline void WINAPIV kprintf(const char *format, ...)
{
__ms_va_list valist;
@@ -50,6 +128,18 @@ static inline void WINAPIV kprintf(const char *format, ...)
__ms_va_end(valist);
}
+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();
+ __ms_va_list valist;
+
+ kprintf( "%s:%d: ", data->current_file, data->current_line );
+ __ms_va_start( valist, msg );
+ kvprintf( msg, valist );
+ __ms_va_end( valist );
+}
+
static inline NTSTATUS winetest_init(void)
{
const struct test_data *data;
@@ -61,6 +151,8 @@ static inline NTSTATUS winetest_init(void)
HANDLE section;
NTSTATUS ret;
+ KeInitializeSpinLock(&tls_data_lock);
+
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);
@@ -98,7 +190,7 @@ static inline void winetest_cleanup(void)
if (winetest_debug)
{
kprintf("%04x:ntoskrnl: %d tests executed (%d marked as todo, %d %s), %d skipped.\n",
- PsGetCurrentProcessId(), successes + failures + todo_successes + todo_failures,
+ (DWORD)(DWORD_PTR)PsGetCurrentProcessId(), successes + failures + todo_successes + todo_failures,
todo_successes, failures + todo_failures,
(failures + todo_failures != 1) ? "failures" : "failure", skipped );
}
@@ -114,10 +206,7 @@ static inline void winetest_cleanup(void)
{
data = addr;
- InterlockedExchangeAdd(&data->successes, successes);
InterlockedExchangeAdd(&data->failures, failures);
- InterlockedExchangeAdd(&data->skipped, skipped);
- InterlockedExchangeAdd(&data->todo_successes, todo_successes);
InterlockedExchangeAdd(&data->todo_failures, todo_failures);
ZwUnmapViewOfSection(NtCurrentProcess(), addr);
@@ -128,118 +217,185 @@ static inline void winetest_cleanup(void)
ZwClose(okfile);
}
-static inline void WINAPIV vok_(const char *file, int line, int condition, const char *msg, __ms_va_list args)
+static inline void winetest_print_context( const char *msgtype )
{
- const char *current_file;
+ struct tls_data *data = get_tls_data();
+ unsigned int i;
- if (!(current_file = drv_strrchr(file, '/')) &&
- !(current_file = drv_strrchr(file, '\\')))
- current_file = file;
- else
- current_file++;
+ 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 );
- if (todo_level)
+ return count;
+}
+
+static inline int winetest_vok( int condition, const char *msg, __ms_va_list args )
+{
+ struct tls_data *data = get_tls_data();
+
+ if (data->todo_level)
{
if (condition)
{
- kprintf("%s:%d: Test succeeded inside todo block: ", current_file, line);
+ winetest_print_context( "Test succeeded inside todo block: " );
kvprintf(msg, args);
InterlockedIncrement(&todo_failures);
+ return 0;
}
else
{
- if (winetest_debug > 0)
+ if (!winetest_debug ||
+ winetest_add_line() < winetest_mute_threshold)
{
- kprintf("%s:%d: Test marked todo: ", current_file, line);
- kvprintf(msg, args);
+ if (winetest_debug > 0)
+ {
+ winetest_print_context( "Test marked todo: " );
+ kvprintf(msg, args);
+ }
+ InterlockedIncrement(&todo_successes);
}
- InterlockedIncrement(&todo_successes);
+ else
+ InterlockedIncrement(&muted_todo_successes);
+ return 1;
}
}
else
{
if (!condition)
{
- kprintf("%s:%d: Test failed: ", current_file, line);
+ winetest_print_context( "Test failed: " );
kvprintf(msg, args);
InterlockedIncrement(&failures);
+ return 0;
}
else
{
if (winetest_report_success)
- kprintf("%s:%d: Test succeeded\n", current_file, line);
+ winetest_printf("Test succeeded\n");
InterlockedIncrement(&successes);
+ return 1;
}
}
}
-static inline void WINAPIV ok_(const char *file, int line, int condition, const char *msg, ...)
+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, ... )
{
__ms_va_list args;
__ms_va_start(args, msg);
- vok_(file, line, condition, msg, args);
+ winetest_vok(condition, msg, args);
__ms_va_end(args);
}
-static inline void vskip_(const char *file, int line, const char *msg, __ms_va_list args)
+static inline void winetest_vskip( const char *msg, __ms_va_list args )
{
- const char *current_file;
-
- if (!(current_file = drv_strrchr(file, '/')) &&
- !(current_file = drv_strrchr(file, '\\')))
- current_file = file;
+ if (winetest_add_line() < winetest_mute_threshold)
+ {
+ winetest_print_context( "Tests skipped: " );
+ kvprintf(msg, args);
+ InterlockedIncrement(&skipped);
+ }
else
- current_file++;
+ InterlockedIncrement(&muted_skipped);
+}
- kprintf("%s:%d: Tests skipped: ", current_file, line);
- kvprintf(msg, args);
- skipped++;
+static inline void WINAPIV winetest_skip( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2);
+static inline void WINAPIV winetest_skip( const char *msg, ... )
+{
+ __ms_va_list args;
+ __ms_va_start(args, msg);
+ winetest_vskip(msg, args);
+ __ms_va_end(args);
}
-static inline void WINAPIV win_skip_(const char *file, int line, const char *msg, ...)
+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, ... )
{
__ms_va_list args;
__ms_va_start(args, msg);
if (running_under_wine)
- vok_(file, line, 0, msg, args);
+ winetest_vskip(msg, args);
else
- vskip_(file, line, msg, args);
+ winetest_vok(0, msg, args);
__ms_va_end(args);
}
-static inline void WINAPIV trace_(const char *file, int line, const char *msg, ...)
+static inline void WINAPIV winetest_trace( const char *msg, ... ) __WINE_PRINTF_ATTR(1,2);
+static inline void WINAPIV winetest_trace( const char *msg, ... )
{
- const char *current_file;
__ms_va_list args;
- if (!(current_file = drv_strrchr(file, '/')) &&
- !(current_file = drv_strrchr(file, '\\')))
- current_file = file;
+ if (!winetest_debug)
+ return;
+ if (winetest_add_line() < winetest_mute_threshold)
+ {
+ winetest_print_context( "" );
+ __ms_va_start(args, msg);
+ kvprintf( msg, args );
+ __ms_va_end(args);
+ }
else
- current_file++;
-
- __ms_va_start(args, msg);
- kprintf("%s:%d: ", current_file, line);
- kvprintf(msg, args);
- __ms_va_end(args);
+ InterlockedIncrement(&muted_traces);
}
static inline void winetest_start_todo( int is_todo )
{
- todo_level = (todo_level << 1) | (is_todo != 0);
- todo_do_loop=1;
+ struct tls_data *data = get_tls_data();
+ data->todo_level = (data->todo_level << 1) | (is_todo != 0);
+ data->todo_do_loop=1;
}
static inline int winetest_loop_todo(void)
{
- int do_loop=todo_do_loop;
- todo_do_loop=0;
+ struct tls_data *data = get_tls_data();
+ int do_loop=data->todo_do_loop;
+ data->todo_do_loop=0;
return do_loop;
}
static inline void winetest_end_todo(void)
{
- todo_level >>= 1;
+ 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();
+ __ms_va_list valist;
+
+ if (data->context_count < ARRAY_SIZE(data->context))
+ {
+ __ms_va_start(valist, fmt);
+ vsnprintf( data->context[data->context_count], sizeof(data->context[data->context_count]), fmt, valist );
+ __ms_va_end(valist);
+ 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;
}
static inline int broken(int condition)
@@ -247,11 +403,31 @@ static inline int broken(int condition)
return !running_under_wine && condition;
}
-#define ok(condition, ...) ok_(__FILE__, __LINE__, condition, __VA_ARGS__)
+#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__)
+
#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)
-#define win_skip(...) win_skip_(__FILE__, __LINE__, __VA_ARGS__)
-#define trace(...) trace_(__FILE__, __LINE__, __VA_ARGS__)
--
2.32.0