ntoskrnl.exe/tests: Add HID driver test in polled mode.
Signed-off-by: Rémi Bernon <rbernon@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
005504969e
commit
e63bd6db23
|
@ -41,6 +41,7 @@ static UNICODE_STRING control_symlink;
|
|||
|
||||
static unsigned int got_start_device;
|
||||
static DWORD report_id;
|
||||
static DWORD polled;
|
||||
|
||||
struct irp_queue
|
||||
{
|
||||
|
@ -485,9 +486,19 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
|
|||
}
|
||||
if (out_size != expected_size) test_failed = TRUE;
|
||||
|
||||
IoMarkIrpPending(irp);
|
||||
irp_queue_push(&impl->irp_queue, irp);
|
||||
ret = STATUS_PENDING;
|
||||
if (polled)
|
||||
{
|
||||
memset(irp->UserBuffer, 0xa5, expected_size);
|
||||
if (report_id) ((char *)irp->UserBuffer)[0] = report_id;
|
||||
irp->IoStatus.Information = 3;
|
||||
ret = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
IoMarkIrpPending(irp);
|
||||
irp_queue_push(&impl->irp_queue, irp);
|
||||
ret = STATUS_PENDING;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -498,8 +509,9 @@ static NTSTATUS WINAPI driver_internal_ioctl(DEVICE_OBJECT *device, IRP *irp)
|
|||
ok(!in_size, "got input size %u\n", in_size);
|
||||
ok(out_size == sizeof(*packet), "got output size %u\n", out_size);
|
||||
|
||||
todo_wine_if(packet->reportId == 0x5a)
|
||||
ok(packet->reportId == report_id, "got packet report id %u\n", packet->reportId);
|
||||
todo_wine_if(packet->reportId == 0x5a || (polled && report_id && packet->reportId == 0))
|
||||
ok(packet->reportId == report_id, "report %d, polled %d got packet report id %u\n",
|
||||
report_id, polled, packet->reportId);
|
||||
todo_wine_if(packet->reportBufferLen == 21 || packet->reportBufferLen == 22)
|
||||
ok(packet->reportBufferLen >= expected_size, "got packet buffer len %u, expected %d or more\n",
|
||||
packet->reportBufferLen, expected_size);
|
||||
|
@ -669,6 +681,13 @@ NTSTATUS WINAPI DriverEntry(DRIVER_OBJECT *driver, UNICODE_STRING *registry)
|
|||
ok(!ret, "ZwQueryValueKey returned %#x\n", ret);
|
||||
memcpy(&report_id, buffer + info_size, size - info_size);
|
||||
|
||||
RtlInitUnicodeString(&name_str, L"PolledMode");
|
||||
size = info_size + sizeof(polled);
|
||||
ret = ZwQueryValueKey(hkey, &name_str, KeyValuePartialInformation, buffer, size, &size);
|
||||
ok(!ret, "ZwQueryValueKey returned %#x\n", ret);
|
||||
memcpy(&polled, buffer + info_size, size - info_size);
|
||||
params.DevicesArePolled = polled;
|
||||
|
||||
driver->DriverExtension->AddDevice = driver_add_device;
|
||||
driver->DriverUnload = driver_unload;
|
||||
driver->MajorFunction[IRP_MJ_PNP] = driver_pnp;
|
||||
|
|
|
@ -2637,7 +2637,7 @@ static void test_hidp(HANDLE file, int report_id)
|
|||
CloseHandle(file);
|
||||
}
|
||||
|
||||
static void test_hid_device(DWORD report_id)
|
||||
static void test_hid_device(DWORD report_id, DWORD polled)
|
||||
{
|
||||
char buffer[200];
|
||||
SP_DEVICE_INTERFACE_DETAIL_DATA_A *iface_detail = (void *)buffer;
|
||||
|
@ -2652,7 +2652,7 @@ static void test_hid_device(DWORD report_id)
|
|||
HDEVINFO set;
|
||||
HANDLE file;
|
||||
|
||||
winetest_push_context("report %d", report_id);
|
||||
winetest_push_context("report %d, polled %d", report_id, polled);
|
||||
|
||||
set = SetupDiGetClassDevsA(&GUID_DEVINTERFACE_HID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT);
|
||||
ok(set != INVALID_HANDLE_VALUE, "failed to get device list, error %#x\n", GetLastError());
|
||||
|
@ -2696,7 +2696,7 @@ static void test_hid_device(DWORD report_id)
|
|||
winetest_pop_context();
|
||||
}
|
||||
|
||||
static void test_hid_driver(struct testsign_context *ctx, DWORD report_id)
|
||||
static void test_hid_driver(struct testsign_context *ctx, DWORD report_id, DWORD polled)
|
||||
{
|
||||
static const char hardware_id[] = "test_hardware_id\0";
|
||||
char path[MAX_PATH], dest[MAX_PATH], *filepart;
|
||||
|
@ -2721,6 +2721,9 @@ static void test_hid_driver(struct testsign_context *ctx, DWORD report_id)
|
|||
status = RegSetValueExW(hkey, L"ReportID", 0, REG_DWORD, (void *)&report_id, sizeof(report_id));
|
||||
ok(!status, "RegSetValueExW returned %#x\n", status);
|
||||
|
||||
status = RegSetValueExW(hkey, L"PolledMode", 0, REG_DWORD, (void *)&polled, sizeof(polled));
|
||||
ok(!status, "RegSetValueExW returned %#x\n", status);
|
||||
|
||||
load_resource(L"driver_hid.dll", driver_filename);
|
||||
ret = MoveFileExW(driver_filename, L"winetest.sys", MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING);
|
||||
ok(ret, "failed to move file, error %u\n", GetLastError());
|
||||
|
@ -2768,7 +2771,7 @@ static void test_hid_driver(struct testsign_context *ctx, DWORD report_id)
|
|||
|
||||
/* Tests. */
|
||||
|
||||
test_hid_device(report_id);
|
||||
test_hid_device(report_id, polled);
|
||||
|
||||
/* Clean up. */
|
||||
|
||||
|
@ -2899,8 +2902,10 @@ START_TEST(ntoskrnl)
|
|||
test_pnp_driver(&ctx);
|
||||
|
||||
subtest("driver_hid");
|
||||
test_hid_driver(&ctx, 0);
|
||||
test_hid_driver(&ctx, 1);
|
||||
test_hid_driver(&ctx, 0, FALSE);
|
||||
test_hid_driver(&ctx, 1, FALSE);
|
||||
test_hid_driver(&ctx, 0, TRUE);
|
||||
test_hid_driver(&ctx, 1, TRUE);
|
||||
|
||||
out:
|
||||
testsign_cleanup(&ctx);
|
||||
|
|
Loading…
Reference in New Issue