Commit e3ca290a authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ntoskrnl/tests: Keep the test output file open for the entire duration each driver is loaded.

parent cfa7006f
......@@ -1781,8 +1781,6 @@ static void WINAPI main_test_task(DEVICE_OBJECT *device, void *context)
test_stack_limits();
test_completion();
winetest_cleanup();
irp->IoStatus.Status = STATUS_SUCCESS;
irp->IoStatus.Information = 0;
IoCompleteRequest(irp, IO_NO_INCREMENT);
......@@ -2104,15 +2102,11 @@ static void test_permanence(void)
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack)
{
void *buffer = irp->AssociatedIrp.SystemBuffer;
struct main_test_input *test_input = (struct main_test_input *)buffer;
NTSTATUS status;
struct main_test_input *test_input = buffer;
if (!buffer)
return STATUS_ACCESS_VIOLATION;
if ((status = winetest_init()))
return status;
pExEventObjectType = get_proc_address("ExEventObjectType");
ok(!!pExEventObjectType, "ExEventObjectType not found\n");
......@@ -2520,6 +2514,8 @@ static VOID WINAPI driver_Unload(DRIVER_OBJECT *driver)
IoDeleteDevice(upper_device);
IoDeleteDevice(lower_device);
winetest_cleanup();
}
NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
......@@ -2528,6 +2524,9 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
NTSTATUS status;
void *obj;
if ((status = winetest_init()))
return status;
DbgPrint("loading driver\n");
driver_obj = driver;
......@@ -2547,38 +2546,26 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
pIoDriverObjectType = MmGetSystemRoutineAddress(&nameW);
RtlInitUnicodeString(&nameW, L"\\Driver\\WineTestDriver");
if ((status = ObReferenceObjectByName(&nameW, 0, NULL, 0, *pIoDriverObjectType, KernelMode, NULL, &obj)))
return status;
if (obj != driver)
{
ObDereferenceObject(obj);
return STATUS_UNSUCCESSFUL;
}
status = ObReferenceObjectByName(&nameW, 0, NULL, 0, *pIoDriverObjectType, KernelMode, NULL, &obj);
ok(!status, "got %#x\n", status);
ok(obj == driver, "expected %p, got %p\n", driver, obj);
ObDereferenceObject(obj);
RtlInitUnicodeString(&nameW, L"\\Device\\WineTestDriver");
RtlInitUnicodeString(&linkW, L"\\DosDevices\\WineTestDriver");
if (!(status = IoCreateDevice(driver, 0, &nameW, FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN, FALSE, &lower_device)))
{
status = IoCreateSymbolicLink(&linkW, &nameW);
lower_device->Flags &= ~DO_DEVICE_INITIALIZING;
}
if (!status)
{
RtlInitUnicodeString(&nameW, L"\\Device\\WineTestUpper");
status = IoCreateDevice(driver, 0, &nameW, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &lower_device);
ok(!status, "failed to create device, status %#x\n", status);
status = IoCreateSymbolicLink(&linkW, &nameW);
ok(!status, "failed to create link, status %#x\n", status);
lower_device->Flags &= ~DO_DEVICE_INITIALIZING;
status = IoCreateDevice(driver, 0, &nameW, FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN, FALSE, &upper_device);
}
RtlInitUnicodeString(&nameW, L"\\Device\\WineTestUpper");
status = IoCreateDevice(driver, 0, &nameW, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &upper_device);
ok(!status, "failed to create device, status %#x\n", status);
if (!status)
{
IoAttachDeviceToDeviceStack(upper_device, lower_device);
upper_device->Flags &= ~DO_DEVICE_INITIALIZING;
}
IoAttachDeviceToDeviceStack(upper_device, lower_device);
upper_device->Flags &= ~DO_DEVICE_INITIALIZING;
return status;
return STATUS_SUCCESS;
}
......@@ -466,21 +466,15 @@ static void test_wsk_connect_socket(void)
static NTSTATUS main_test(DEVICE_OBJECT *device, IRP *irp, IO_STACK_LOCATION *stack)
{
void *buffer = irp->AssociatedIrp.SystemBuffer;
NTSTATUS status;
if (!buffer)
return STATUS_ACCESS_VIOLATION;
if ((status = winetest_init()))
return status;
netio_init();
test_wsk_get_address_info();
test_wsk_listen_socket();
test_wsk_connect_socket();
winetest_cleanup();
irp->IoStatus.Information = 0;
return STATUS_SUCCESS;
}
......@@ -533,6 +527,8 @@ static VOID WINAPI driver_unload(DRIVER_OBJECT *driver)
IoDeleteSymbolicLink(&linkW);
IoDeleteDevice(device_obj);
winetest_cleanup();
}
NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
......@@ -540,6 +536,9 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
UNICODE_STRING nameW, linkW;
NTSTATUS status;
if ((status = winetest_init()))
return status;
DbgPrint("Loading driver.\n");
driver_obj = driver;
......@@ -552,12 +551,11 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, PUNICODE_STRING registry)
RtlInitUnicodeString(&nameW, device_name);
RtlInitUnicodeString(&linkW, driver_link);
if (!(status = IoCreateDevice(driver, 0, &nameW, FILE_DEVICE_UNKNOWN,
FILE_DEVICE_SECURE_OPEN, FALSE, &device_obj)))
{
status = IoCreateSymbolicLink(&linkW, &nameW);
device_obj->Flags &= ~DO_DEVICE_INITIALIZING;
}
status = IoCreateDevice(driver, 0, &nameW, FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &device_obj);
ok(!status, "failed to create device, status %#x\n", status);
status = IoCreateSymbolicLink(&linkW, &nameW);
ok(!status, "failed to create link, status %#x\n", status);
device_obj->Flags &= ~DO_DEVICE_INITIALIZING;
return status;
return STATUS_SUCCESS;
}
......@@ -405,8 +405,6 @@ static void main_test(void)
ok(res, "DeviceIoControl failed: %u\n", GetLastError());
ok(!size, "got size %u\n", size);
cat_okfile();
heap_free(test_input);
}
......@@ -931,6 +929,8 @@ static void test_driver_netio(struct testsign_context *ctx)
unload_driver(service);
ret = DeleteFileW(filename);
ok(ret, "DeleteFile failed: %u\n", GetLastError());
cat_okfile();
}
static void add_file_to_catalog(HANDLE catalog, const WCHAR *file)
......@@ -1272,6 +1272,8 @@ START_TEST(ntoskrnl)
ret = DeleteFileW(filename2);
ok(ret, "DeleteFile failed: %u\n", GetLastError());
cat_okfile();
test_driver3(&ctx);
subtest("driver_netio");
test_driver_netio(&ctx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment