Win7 has spurious device arrival / removal messages for the first polled HID device created, probably when installing the driver the first time, and it causes a timeout if we open it before it completed its sequence.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/hid.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index de77c02540f..8f984a006ac 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -74,7 +74,7 @@ const GUID expect_guid_product = {EXPECT_VIDPID, 0x0000, 0x0000, {0x00, 0x00, 'P const WCHAR expect_path[] = L"\\?\hid#vid_1209&pid_0001#2&"; const WCHAR expect_path_end[] = L"&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}"; HANDLE device_added, device_removed; -static BOOL hid_device_created; +static LONG device_added_count;
static struct winetest_shared_data *test_data; static HANDLE monitor_thread, monitor_stop; @@ -734,7 +734,6 @@ BOOL hid_device_start( struct hid_device_desc *desc ) CloseHandle( control );
WaitForSingleObject( device_added, INFINITE ); - hid_device_created = TRUE;
return TRUE; } @@ -2471,6 +2470,11 @@ static void test_hid_device( DWORD report_id, DWORD polled, const HIDP_CAPS *exp
winetest_push_context( "id %ld%s", report_id, polled ? " poll" : "" );
+ /* Win7 has a spurious device removal event with polled HID devices */ + if (!polled || !strcmp(winetest_platform, "wine")) ret = WAIT_TIMEOUT; + else ret = WaitForSingleObject( device_removed, 2000 ); + if (!ret && InterlockedOr( &device_added_count, 0 ) == 1) WaitForSingleObject( device_added, INFINITE ); + swprintf( device_path, MAX_PATH, L"\\?\hid#vid_%04x&pid_%04x", vid, pid ); ret = find_hid_device_path( device_path ); ok( ret, "Failed to find HID device matching %s\n", debugstr_w( device_path ) ); @@ -3339,7 +3343,10 @@ static LRESULT CALLBACK monitor_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPA if (wparam == DBT_DEVICEREMOVECOMPLETE && IsEqualGUID( &iface->dbcc_classguid, &control_class )) SetEvent( device_removed ); if (wparam == DBT_DEVICEARRIVAL && IsEqualGUID( &iface->dbcc_classguid, &GUID_DEVINTERFACE_HID )) + { + InterlockedIncrement( &device_added_count ); SetEvent( device_added ); + } }
return DefWindowProcW( hwnd, msg, wparam, lparam ); @@ -3648,7 +3655,6 @@ static void test_bus_driver(void) ok( ret, "IOCTL_WINETEST_CREATE_DEVICE failed, last error %lu\n", GetLastError() );
WaitForSingleObject( device_added, INFINITE ); - hid_device_created = TRUE;
swprintf( device_path, MAX_PATH, L"\\?\hid#vid_%04x&pid_%04x", LOWORD(EXPECT_VIDPID), HIWORD(EXPECT_VIDPID) ); ret = find_hid_device_path( device_path );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/driver_bus.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/dlls/dinput/tests/driver_bus.c b/dlls/dinput/tests/driver_bus.c index 9492f036c0f..be38de1999e 100644 --- a/dlls/dinput/tests/driver_bus.c +++ b/dlls/dinput/tests/driver_bus.c @@ -421,6 +421,7 @@ struct phys_device
WCHAR instance_id[MAX_PATH]; WCHAR device_id[MAX_PATH]; + IRP *pending_remove;
BOOL use_report_id; DWORD report_descriptor_len; @@ -677,8 +678,14 @@ static NTSTATUS pdo_pnp( DEVICE_OBJECT *device, IRP *irp ) { input_queue_cleanup( &impl->input_queue ); expect_queue_cleanup( &impl->expect_queue ); + irp = impl->pending_remove; IoDeleteDevice( device ); if (winetest_debug > 1) trace( "Deleted Bus PDO %p\n", device ); + if (irp) + { + irp->IoStatus.Status = STATUS_SUCCESS; + IoCompleteRequest( irp, IO_NO_INCREMENT ); + } } return STATUS_SUCCESS; } @@ -1220,7 +1227,9 @@ static NTSTATUS WINAPI pdo_ioctl( DEVICE_OBJECT *device, IRP *irp ) impl->base.state = PNP_DEVICE_REMOVED; irp_queue_clear( &impl->input_queue.pending ); KeReleaseSpinLock( &impl->base.lock, irql ); - status = STATUS_SUCCESS; + impl->pending_remove = irp; + IoMarkIrpPending( irp ); + status = STATUS_PENDING; break; case IOCTL_WINETEST_CREATE_DEVICE: ok( 0, "unexpected call\n" );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=111070
Your paranoid android.
=== w1064_tsign (64 bit report) ===
dinput: hid: Timeout