Signed-off-by: Zebediah Figura z.figura12@gmail.com --- The idea of this series is twofold: first, to make it possible to use ok() almost everywhere (including in the driver initialization and unload routines), and secondly, to reduce the programming overhead of communicating test results, which is especially useful as we add more and more test drivers.
dlls/ntoskrnl.exe/tests/driver.c | 23 +++++------------------ dlls/ntoskrnl.exe/tests/driver_netio.c | 22 +++++----------------- dlls/ntoskrnl.exe/tests/utils.h | 25 +++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 35 deletions(-)
diff --git a/dlls/ntoskrnl.exe/tests/driver.c b/dlls/ntoskrnl.exe/tests/driver.c index 179d2d5e02d..1d78f576ecf 100644 --- a/dlls/ntoskrnl.exe/tests/driver.c +++ b/dlls/ntoskrnl.exe/tests/driver.c @@ -1782,15 +1782,7 @@ static void WINAPI main_test_task(DEVICE_OBJECT *device, void *context) test_stack_limits(); test_completion();
- /* print process report */ - 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, - todo_successes, failures + todo_failures, - (failures + todo_failures != 1) ? "failures" : "failure", skipped ); - } - ZwClose(okfile); + winetest_cleanup();
*((LONG *)buffer) = failures; irp->IoStatus.Status = STATUS_SUCCESS; @@ -2116,24 +2108,19 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength; void *buffer = irp->AssociatedIrp.SystemBuffer; struct test_input *test_input = (struct test_input *)buffer; - OBJECT_ATTRIBUTES attr = {0}; - UNICODE_STRING pathU; - IO_STATUS_BLOCK io; + NTSTATUS status;
if (!buffer) return STATUS_ACCESS_VIOLATION; if (length < sizeof(failures)) return STATUS_BUFFER_TOO_SMALL;
- attr.Length = sizeof(attr); - RtlInitUnicodeString(&pathU, L"\??\C:\windows\winetest_ntoskrnl_okfile"); running_under_wine = test_input->running_under_wine; winetest_debug = test_input->winetest_debug; winetest_report_success = test_input->winetest_report_success; - attr.ObjectName = &pathU; - attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */ - ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io, - FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT); + + if ((status = winetest_init())) + return status;
pExEventObjectType = get_proc_address("ExEventObjectType"); ok(!!pExEventObjectType, "ExEventObjectType not found\n"); diff --git a/dlls/ntoskrnl.exe/tests/driver_netio.c b/dlls/ntoskrnl.exe/tests/driver_netio.c index 3d783dbef0d..98392c9c7fd 100644 --- a/dlls/ntoskrnl.exe/tests/driver_netio.c +++ b/dlls/ntoskrnl.exe/tests/driver_netio.c @@ -468,38 +468,26 @@ static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *st ULONG length = stack->Parameters.DeviceIoControl.OutputBufferLength; void *buffer = irp->AssociatedIrp.SystemBuffer; struct test_input *test_input = buffer; - OBJECT_ATTRIBUTES attr = {0}; - UNICODE_STRING pathU; - IO_STATUS_BLOCK io; + NTSTATUS status;
if (!buffer) return STATUS_ACCESS_VIOLATION; if (length < sizeof(failures)) return STATUS_BUFFER_TOO_SMALL;
- attr.Length = sizeof(attr); - RtlInitUnicodeString(&pathU, L"\??\C:\winetest_ntoskrnl_okfile"); running_under_wine = test_input->running_under_wine; winetest_debug = test_input->winetest_debug; winetest_report_success = test_input->winetest_report_success; - attr.ObjectName = &pathU; - attr.Attributes = OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE; /* needed to be accessible from system threads */ - ZwOpenFile(&okfile, FILE_APPEND_DATA | SYNCHRONIZE, &attr, &io, - FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_SYNCHRONOUS_IO_NONALERT); + + if ((status = winetest_init())) + return status;
netio_init(); test_wsk_get_address_info(); test_wsk_listen_socket(); test_wsk_connect_socket();
- 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, - todo_successes, failures + todo_failures, - (failures + todo_failures != 1) ? "failures" : "failure", skipped ); - } - ZwClose(okfile); + winetest_cleanup();
*((LONG *)buffer) = failures; irp->IoStatus.Information = sizeof(failures); diff --git a/dlls/ntoskrnl.exe/tests/utils.h b/dlls/ntoskrnl.exe/tests/utils.h index be0f58f837c..508346ef9bf 100644 --- a/dlls/ntoskrnl.exe/tests/utils.h +++ b/dlls/ntoskrnl.exe/tests/utils.h @@ -49,6 +49,31 @@ static inline void WINAPIV kprintf(const char *format, ...) __ms_va_end(valist); }
+static inline NTSTATUS winetest_init(void) +{ + OBJECT_ATTRIBUTES attr; + UNICODE_STRING string; + IO_STATUS_BLOCK io; + + RtlInitUnicodeString(&string, L"\??\C:\windows\winetest_ntoskrnl_okfile"); + /* 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); + 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) +{ + 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, + todo_successes, failures + todo_failures, + (failures + todo_failures != 1) ? "failures" : "failure", skipped ); + } + ZwClose(okfile); +} + static inline void WINAPIV vok_(const char *file, int line, int condition, const char *msg, __ms_va_list args) { const char *current_file;