Rémi Bernon : dinput8/tests: Make ret_length optional in struct hid_expect.

Alexandre Julliard julliard at winehq.org
Fri Sep 17 16:03:08 CDT 2021


Module: wine
Branch: master
Commit: e293db88a81bb364a773aaba5be4bc568f332f22
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=e293db88a81bb364a773aaba5be4bc568f332f22

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Fri Sep 17 09:06:23 2021 +0200

dinput8/tests: Make ret_length optional in struct hid_expect.

So that we don't have to specify it explicitely every time. Input
reports length is now enforced, and we don't mean to test the length
every time we inject input.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/dinput8/tests/driver_hid.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/dlls/dinput8/tests/driver_hid.c b/dlls/dinput8/tests/driver_hid.c
index 28694e5a4c6..f484710e498 100644
--- a/dlls/dinput8/tests/driver_hid.c
+++ b/dlls/dinput8/tests/driver_hid.c
@@ -225,11 +225,15 @@ static void input_queue_cleanup( struct input_queue *queue )
 
 static BOOL input_queue_read_locked( struct input_queue *queue, IRP *irp )
 {
+    IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp );
+    ULONG out_size = stack->Parameters.DeviceIoControl.OutputBufferLength;
     struct hid_expect *tmp = queue->pos;
+
     if (tmp >= queue->end) return FALSE;
+    if (tmp->ret_length) out_size = tmp->ret_length;
 
-    memcpy( irp->UserBuffer, tmp->report_buf, tmp->ret_length );
-    irp->IoStatus.Information = tmp->ret_length;
+    memcpy( irp->UserBuffer, tmp->report_buf, out_size );
+    irp->IoStatus.Information = out_size;
     irp->IoStatus.Status = tmp->ret_status;
     if (tmp < queue->end) queue->pos = tmp + 1;
 
@@ -464,7 +468,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
             "unexpected data\n" );
         winetest_pop_context();
 
-        irp->IoStatus.Information = expect.ret_length;
+        irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
         ret = expect.ret_status;
         break;
     }
@@ -487,8 +491,8 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
         ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
         winetest_pop_context();
 
-        memcpy( packet->reportBuffer, expect.report_buf, expect.ret_length );
-        irp->IoStatus.Information = expect.ret_length;
+        irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
+        memcpy( packet->reportBuffer, expect.report_buf, irp->IoStatus.Information );
         ret = expect.ret_status;
         break;
     }
@@ -513,7 +517,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
             "unexpected data\n" );
         winetest_pop_context();
 
-        irp->IoStatus.Information = expect.ret_length;
+        irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
         ret = expect.ret_status;
         break;
     }
@@ -536,8 +540,8 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
         ok( packet->reportBufferLen == expect.report_len, "got len %u\n", packet->reportBufferLen );
         winetest_pop_context();
 
-        memcpy( packet->reportBuffer, expect.report_buf, expect.ret_length );
-        irp->IoStatus.Information = expect.ret_length;
+        irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
+        memcpy( packet->reportBuffer, expect.report_buf, irp->IoStatus.Information );
         ret = expect.ret_status;
         break;
     }
@@ -562,7 +566,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
             "unexpected data\n" );
         winetest_pop_context();
 
-        irp->IoStatus.Information = expect.ret_length;
+        irp->IoStatus.Information = expect.ret_length ? expect.ret_length : expect.report_len;
         ret = expect.ret_status;
         break;
     }




More information about the wine-cvs mailing list