Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/driver_hid.c | 27 ++++++++---- dlls/dinput/tests/driver_hid.h | 75 ++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+), 7 deletions(-)
diff --git a/dlls/dinput/tests/driver_hid.c b/dlls/dinput/tests/driver_hid.c index 99aa9bd688c..e4101853833 100644 --- a/dlls/dinput/tests/driver_hid.c +++ b/dlls/dinput/tests/driver_hid.c @@ -411,11 +411,12 @@ static NTSTATUS WINAPI driver_pnp( DEVICE_OBJECT *device, IRP *irp ) IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp ); HID_DEVICE_EXTENSION *ext = device->DeviceExtension; struct hid_device *impl = ext->MiniDeviceExtension; + ULONG code = stack->MinorFunction; KIRQL irql;
- if (winetest_debug > 1) trace( "pnp %#x\n", stack->MinorFunction ); + if (winetest_debug > 1) trace( "%s: device %p, code %#lx %s\n", __func__, device, code, debugstr_pnp(code) );
- switch (stack->MinorFunction) + switch (code) { case IRP_MN_START_DEVICE: ++got_start_device; @@ -502,7 +503,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) KIRQL irql; LONG index;
- if (winetest_debug > 1) trace( "ioctl %#lx\n", code ); + if (winetest_debug > 1) trace( "%s: device %p, code %#lx %s\n", __func__, device, code, debugstr_ioctl(code) );
ok( got_start_device, "expected IRP_MN_START_DEVICE before any ioctls\n" );
@@ -725,6 +726,8 @@ static NTSTATUS WINAPI driver_ioctl( DEVICE_OBJECT *device, IRP *irp ) ULONG code = stack->Parameters.DeviceIoControl.IoControlCode; KIRQL irql;
+ if (winetest_debug > 1) trace( "%s: device %p, code %#lx %s\n", __func__, device, code, debugstr_ioctl(code) ); + switch (code) { case IOCTL_WINETEST_HID_SET_EXPECT: @@ -752,27 +755,32 @@ static NTSTATUS WINAPI driver_ioctl( DEVICE_OBJECT *device, IRP *irp ) return hidclass_driver_ioctl( device, irp ); }
-static NTSTATUS WINAPI driver_add_device( DRIVER_OBJECT *driver, DEVICE_OBJECT *fdo ) +static NTSTATUS WINAPI driver_add_device( DRIVER_OBJECT *driver, DEVICE_OBJECT *device ) { - HID_DEVICE_EXTENSION *ext = fdo->DeviceExtension; + HID_DEVICE_EXTENSION *ext = device->DeviceExtension; NTSTATUS ret;
+ if (winetest_debug > 1) trace( "%s: driver %p, device %p\n", __func__, driver, device ); + /* We should be given the FDO, not the PDO. */ ok( !!ext->PhysicalDeviceObject, "expected non-NULL pdo\n" ); ok( ext->NextDeviceObject == ext->PhysicalDeviceObject, "got pdo %p, next %p\n", ext->PhysicalDeviceObject, ext->NextDeviceObject ); todo_wine - ok( ext->NextDeviceObject->AttachedDevice == fdo, "wrong attached device\n" ); + ok( ext->NextDeviceObject->AttachedDevice == device, "wrong attached device\n" );
ret = IoRegisterDeviceInterface( ext->PhysicalDeviceObject, &control_class, NULL, &control_symlink ); ok( !ret, "got %#lx\n", ret );
- fdo->Flags &= ~DO_DEVICE_INITIALIZING; + if (winetest_debug > 1) trace( "Created HID FDO %p for Bus PDO %p\n", device, ext->PhysicalDeviceObject ); + + device->Flags &= ~DO_DEVICE_INITIALIZING; return STATUS_SUCCESS; }
static NTSTATUS WINAPI driver_create( DEVICE_OBJECT *device, IRP *irp ) { + if (winetest_debug > 1) trace( "%s: device %p\n", __func__, device ); ok( 0, "unexpected call\n" ); irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest( irp, IO_NO_INCREMENT ); @@ -781,6 +789,7 @@ static NTSTATUS WINAPI driver_create( DEVICE_OBJECT *device, IRP *irp )
static NTSTATUS WINAPI driver_close( DEVICE_OBJECT *device, IRP *irp ) { + if (winetest_debug > 1) trace( "%s: device %p\n", __func__, device ); ok( 0, "unexpected call\n" ); irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest( irp, IO_NO_INCREMENT ); @@ -789,6 +798,7 @@ static NTSTATUS WINAPI driver_close( DEVICE_OBJECT *device, IRP *irp )
static void WINAPI driver_unload( DRIVER_OBJECT *driver ) { + if (winetest_debug > 1) trace( "%s: driver %p\n", __func__, driver ); input_queue_cleanup( &input_queue ); expect_queue_cleanup( &expect_queue ); winetest_cleanup(); @@ -812,6 +822,7 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *registry ) DWORD size;
if ((ret = winetest_init())) return ret; + if (winetest_debug > 1) trace( "%s: driver %p\n", __func__, driver );
InitializeObjectAttributes( &attr, registry, 0, NULL, NULL ); ret = ZwOpenKey( &hkey, KEY_ALL_ACCESS, &attr ); @@ -833,6 +844,8 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *registry ) ok( !ret, "ZwQueryValueKey returned %#lx\n", ret ); memcpy( &polled, buffer + info_size, size - info_size ); params.DevicesArePolled = polled; + /* polled mode calls this in a state where printing anything locks the system up */ + if (polled) winetest_debug = 0;
RtlInitUnicodeString( &name_str, L"Descriptor" ); size = info_size + sizeof(report_descriptor_buf); diff --git a/dlls/dinput/tests/driver_hid.h b/dlls/dinput/tests/driver_hid.h index 089d12b70fc..80073a6ae3f 100644 --- a/dlls/dinput/tests/driver_hid.h +++ b/dlls/dinput/tests/driver_hid.h @@ -31,9 +31,11 @@ #define WIN32_NO_STATUS #include "windef.h" #include "winbase.h" +#include "winioctl.h" #include "winternl.h"
#include "ddk/wdm.h" +#include "ddk/hidclass.h"
DEFINE_GUID(control_class,0xdeadbeef,0x29ef,0x4538,0xa5,0xfd,0xb6,0x95,0x73,0xa3,0x62,0xc0);
@@ -65,6 +67,79 @@ struct winetest_shared_data LONG todo_failures; };
+static inline const char *debugstr_pnp( ULONG code ) +{ + switch (code) + { + case IRP_MN_START_DEVICE: return "IRP_MN_START_DEVICE"; + case IRP_MN_QUERY_REMOVE_DEVICE: return "IRP_MN_QUERY_REMOVE_DEVICE"; + case IRP_MN_REMOVE_DEVICE: return "IRP_MN_REMOVE_DEVICE"; + case IRP_MN_CANCEL_REMOVE_DEVICE: return "IRP_MN_CANCEL_REMOVE_DEVICE"; + case IRP_MN_STOP_DEVICE: return "IRP_MN_STOP_DEVICE"; + case IRP_MN_QUERY_STOP_DEVICE: return "IRP_MN_QUERY_STOP_DEVICE"; + case IRP_MN_CANCEL_STOP_DEVICE: return "IRP_MN_CANCEL_STOP_DEVICE"; + case IRP_MN_QUERY_DEVICE_RELATIONS: return "IRP_MN_QUERY_DEVICE_RELATIONS"; + case IRP_MN_QUERY_INTERFACE: return "IRP_MN_QUERY_INTERFACE"; + case IRP_MN_QUERY_CAPABILITIES: return "IRP_MN_QUERY_CAPABILITIES"; + case IRP_MN_QUERY_RESOURCES: return "IRP_MN_QUERY_RESOURCES"; + case IRP_MN_QUERY_RESOURCE_REQUIREMENTS: return "IRP_MN_QUERY_RESOURCE_REQUIREMENTS"; + case IRP_MN_QUERY_DEVICE_TEXT: return "IRP_MN_QUERY_DEVICE_TEXT"; + case IRP_MN_FILTER_RESOURCE_REQUIREMENTS: return "IRP_MN_FILTER_RESOURCE_REQUIREMENTS"; + case IRP_MN_READ_CONFIG: return "IRP_MN_READ_CONFIG"; + case IRP_MN_WRITE_CONFIG: return "IRP_MN_WRITE_CONFIG"; + case IRP_MN_EJECT: return "IRP_MN_EJECT"; + case IRP_MN_SET_LOCK: return "IRP_MN_SET_LOCK"; + case IRP_MN_QUERY_ID: return "IRP_MN_QUERY_ID"; + case IRP_MN_QUERY_PNP_DEVICE_STATE: return "IRP_MN_QUERY_PNP_DEVICE_STATE"; + case IRP_MN_QUERY_BUS_INFORMATION: return "IRP_MN_QUERY_BUS_INFORMATION"; + case IRP_MN_DEVICE_USAGE_NOTIFICATION: return "IRP_MN_DEVICE_USAGE_NOTIFICATION"; + case IRP_MN_SURPRISE_REMOVAL: return "IRP_MN_SURPRISE_REMOVAL"; + case IRP_MN_QUERY_LEGACY_BUS_INFORMATION: return "IRP_MN_QUERY_LEGACY_BUS_INFORMATION"; + default: return "unknown"; + } +} + +static inline const char *debugstr_ioctl( ULONG code ) +{ + switch (code) + { + case HID_CTL_CODE(0): return "IOCTL_HID_GET_DEVICE_DESCRIPTOR"; + case HID_CTL_CODE(1): return "IOCTL_HID_GET_REPORT_DESCRIPTOR"; + case HID_CTL_CODE(2): return "IOCTL_HID_READ_REPORT"; + case HID_CTL_CODE(3): return "IOCTL_HID_WRITE_REPORT"; + case HID_CTL_CODE(4): return "IOCTL_HID_GET_STRING"; + case HID_CTL_CODE(7): return "IOCTL_HID_ACTIVATE_DEVICE"; + case HID_CTL_CODE(8): return "IOCTL_HID_DEACTIVATE_DEVICE"; + case HID_CTL_CODE(9): return "IOCTL_HID_GET_DEVICE_ATTRIBUTES"; + case HID_CTL_CODE(10): return "IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST"; + case HID_OUT_CTL_CODE(102): return "IOCTL_GET_PHYSICAL_DESCRIPTOR"; + case HID_CTL_CODE(101): return "IOCTL_HID_FLUSH_QUEUE"; + case HID_CTL_CODE(100): return "IOCTL_HID_GET_COLLECTION_DESCRIPTOR"; + case HID_BUFFER_CTL_CODE(106): return "IOCTL_HID_GET_COLLECTION_INFORMATION"; + case HID_OUT_CTL_CODE(100): return "IOCTL_HID_GET_FEATURE"; + case HID_OUT_CTL_CODE(103): return "IOCTL_HID_GET_HARDWARE_ID"; + case HID_OUT_CTL_CODE(120): return "IOCTL_HID_GET_INDEXED_STRING"; + case HID_OUT_CTL_CODE(104): return "IOCTL_HID_GET_INPUT_REPORT"; + case HID_OUT_CTL_CODE(110): return "IOCTL_HID_GET_MANUFACTURER_STRING"; + case HID_BUFFER_CTL_CODE(104): return "IOCTL_GET_NUM_DEVICE_INPUT_BUFFERS"; + case HID_BUFFER_CTL_CODE(102): return "IOCTL_HID_GET_POLL_FREQUENCY_MSEC"; + case HID_OUT_CTL_CODE(111): return "IOCTL_HID_GET_PRODUCT_STRING"; + case HID_OUT_CTL_CODE(112): return "IOCTL_HID_GET_SERIALNUMBER_STRING"; + case HID_IN_CTL_CODE(100): return "IOCTL_HID_SET_FEATURE"; + case HID_BUFFER_CTL_CODE(105): return "IOCTL_SET_NUM_DEVICE_INPUT_BUFFERS"; + case HID_IN_CTL_CODE(101): return "IOCTL_HID_SET_OUTPUT_REPORT"; + case HID_BUFFER_CTL_CODE(103): return "IOCTL_HID_SET_POLL_FREQUENCY_MSEC"; + case HID_BUFFER_CTL_CODE(100): return "IOCTL_HID_GET_DRIVER_CONFIG"; + case HID_BUFFER_CTL_CODE(101): return "IOCTL_HID_SET_DRIVER_CONFIG"; + case HID_OUT_CTL_CODE(121): return "IOCTL_HID_GET_MS_GENRE_DESCRIPTOR"; + case IOCTL_WINETEST_HID_SET_EXPECT: return "IOCTL_WINETEST_HID_SET_EXPECT"; + case IOCTL_WINETEST_HID_WAIT_EXPECT: return "IOCTL_WINETEST_HID_WAIT_EXPECT"; + case IOCTL_WINETEST_HID_SEND_INPUT: return "IOCTL_WINETEST_HID_SEND_INPUT"; + case IOCTL_WINETEST_HID_SET_CONTEXT: return "IOCTL_WINETEST_HID_SET_CONTEXT"; + default: return "unknown"; + } +} + #ifndef __WINE_WINE_TEST_H
#if !defined( __WINE_USE_MSVCRT ) || defined( __MINGW32__ )
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/Makefile.in | 8 ++-- dlls/dinput/tests/dinput_test.h | 4 +- dlls/dinput/tests/{driver_hid.c => driver.c} | 0 .../tests/{driver_hid.spec => driver.spec} | 0 dlls/dinput/tests/force_feedback.c | 4 +- dlls/dinput/tests/hid.c | 38 ++++++++++++------- dlls/dinput/tests/hotplug.c | 4 +- dlls/dinput/tests/joystick8.c | 10 ++--- 8 files changed, 40 insertions(+), 28 deletions(-) rename dlls/dinput/tests/{driver_hid.c => driver.c} (100%) rename dlls/dinput/tests/{driver_hid.spec => driver.spec} (100%)
diff --git a/dlls/dinput/tests/Makefile.in b/dlls/dinput/tests/Makefile.in index 5ba0e5be4d7..c1b887f8dcb 100644 --- a/dlls/dinput/tests/Makefile.in +++ b/dlls/dinput/tests/Makefile.in @@ -1,15 +1,15 @@ TESTDLL = dinput.dll IMPORTS = dinput dinput8 ole32 version user32 advapi32 hid uuid crypt32 newdev setupapi wintrust winmm
-driver_hid_IMPORTS = winecrt0 ntoskrnl hal hidclass -driver_hid_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native +driver_IMPORTS = winecrt0 ntoskrnl hal hidclass +driver_EXTRADLLFLAGS = -nodefaultlibs -nostartfiles -Wl,--subsystem,native
SOURCES = \ device.c \ device8.c \ dinput.c \ - driver_hid.c \ - driver_hid.spec \ + driver.c \ + driver.spec \ force_feedback.c \ hid.c \ hotplug.c \ diff --git a/dlls/dinput/tests/dinput_test.h b/dlls/dinput/tests/dinput_test.h index 97eed949a36..c0027c07094 100644 --- a/dlls/dinput/tests/dinput_test.h +++ b/dlls/dinput/tests/dinput_test.h @@ -52,8 +52,8 @@ extern const WCHAR expect_path_end[]; extern HINSTANCE instance; extern BOOL localized; /* object names get translated */
-BOOL pnp_driver_start( const WCHAR *resource ); -void pnp_driver_stop(void); +BOOL hid_device_start(void); +void hid_device_stop(void);
void cleanup_registry_keys(void);
diff --git a/dlls/dinput/tests/driver_hid.c b/dlls/dinput/tests/driver.c similarity index 100% rename from dlls/dinput/tests/driver_hid.c rename to dlls/dinput/tests/driver.c diff --git a/dlls/dinput/tests/driver_hid.spec b/dlls/dinput/tests/driver.spec similarity index 100% rename from dlls/dinput/tests/driver_hid.spec rename to dlls/dinput/tests/driver.spec diff --git a/dlls/dinput/tests/force_feedback.c b/dlls/dinput/tests/force_feedback.c index ce460147f9d..ca3f6293304 100644 --- a/dlls/dinput/tests/force_feedback.c +++ b/dlls/dinput/tests/force_feedback.c @@ -2999,7 +2999,7 @@ static BOOL test_force_feedback_joystick( DWORD version ) CloseHandle( file );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd ); winetest_pop_context(); @@ -4317,7 +4317,7 @@ static void test_device_managed_effect(void) CloseHandle( file );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd ); winetest_pop_context(); diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index 83635146324..b5683b18850 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -415,8 +415,9 @@ static void unload_driver( SC_HANDLE service ) CloseServiceHandle( service ); }
-void pnp_driver_stop(void) +static void pnp_driver_stop(void) { + const WCHAR *service_name = L"winetest"; SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; WCHAR path[MAX_PATH], dest[MAX_PATH], *filepart; SC_HANDLE manager, service; @@ -453,7 +454,7 @@ void pnp_driver_stop(void) manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_CONNECT ); ok( !!manager, "failed to open service manager, error %lu\n", GetLastError() );
- service = OpenServiceW( manager, L"winetest", SERVICE_STOP | DELETE ); + service = OpenServiceW( manager, service_name, SERVICE_STOP | DELETE ); if (service) unload_driver( service ); else ok( GetLastError() == ERROR_SERVICE_DOES_NOT_EXIST, "got error %lu\n", GetLastError() );
@@ -488,11 +489,12 @@ void pnp_driver_stop(void) ok( ret || GetLastError() == ERROR_FILE_NOT_FOUND, "Failed to delete file, error %lu\n", GetLastError() ); }
-BOOL pnp_driver_start( const WCHAR *resource ) +static BOOL pnp_driver_start(void) { static const WCHAR hardware_id[] = L"test_hardware_id\0"; SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; WCHAR path[MAX_PATH], filename[MAX_PATH]; + const WCHAR *service_name = L"winetest"; SC_HANDLE manager, service; const CERT_CONTEXT *cert; int old_mute_threshold; @@ -504,7 +506,7 @@ BOOL pnp_driver_start( const WCHAR *resource ) old_mute_threshold = winetest_mute_threshold; winetest_mute_threshold = 1;
- load_resource( resource, filename ); + load_resource( L"driver.dll", filename ); ret = MoveFileExW( filename, L"winetest.sys", MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING ); ok( ret, "failed to move file, error %lu\n", GetLastError() );
@@ -570,7 +572,7 @@ BOOL pnp_driver_start( const WCHAR *resource ) manager = OpenSCManagerW( NULL, NULL, SC_MANAGER_CONNECT ); ok( !!manager, "failed to open service manager, error %lu\n", GetLastError() );
- service = OpenServiceW( manager, L"winetest", SERVICE_START ); + service = OpenServiceW( manager, service_name, SERVICE_START ); ok( !!service, "failed to open service, error %lu\n", GetLastError() );
ret = StartServiceW( service, 0, NULL ); @@ -590,6 +592,16 @@ BOOL pnp_driver_start( const WCHAR *resource ) return ret || GetLastError() == ERROR_SERVICE_ALREADY_RUNNING; }
+void hid_device_stop(void) +{ + pnp_driver_stop(); +} + +BOOL hid_device_start(void) +{ + return pnp_driver_start(); +} + #define check_hidp_caps( a, b ) check_hidp_caps_( __LINE__, a, b ) static inline void check_hidp_caps_( int line, HIDP_CAPS *caps, const HIDP_CAPS *exp ) { @@ -2809,9 +2821,9 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) status = RegSetValueExW( hkey, L"Context", 0, REG_BINARY, (void *)context, sizeof(context) ); ok( !status, "RegSetValueExW returned %#lx\n", status );
- if (pnp_driver_start( L"driver_hid.dll" )) test_hid_device( report_id, polled, &caps ); + if (hid_device_start()) test_hid_device( report_id, polled, &caps ); + hid_device_stop();
- pnp_driver_stop(); SetCurrentDirectoryW( cwd ); }
@@ -3169,7 +3181,7 @@ static void test_hidp_kdr(void) status = RegSetValueExW( hkey, L"Context", 0, REG_BINARY, (void *)context, sizeof(context) ); ok( !status, "RegSetValueExW returned %#lx\n", status );
- if (!pnp_driver_start( L"driver_hid.dll" )) goto done; + if (!hid_device_start()) goto done;
set = SetupDiGetClassDevsW( &GUID_DEVINTERFACE_HID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT ); ok( set != INVALID_HANDLE_VALUE, "failed to get device list, error %#lx\n", GetLastError() ); @@ -3286,7 +3298,7 @@ static void test_hidp_kdr(void) CloseHandle( file );
done: - pnp_driver_stop(); + hid_device_stop(); SetCurrentDirectoryW( cwd ); }
@@ -3360,7 +3372,7 @@ BOOL dinput_driver_start_( const char *file, int line, const BYTE *desc_buf, ULO status = RegSetValueExW( hkey, L"Context", 0, REG_BINARY, (void *)context, sizeof(context) ); ok_(file, line)( !status, "RegSetValueExW returned %#lx\n", status );
- return pnp_driver_start( L"driver_hid.dll" ); + return hid_device_start(); }
BOOL dinput_test_init_( const char *file, int line ) @@ -3395,7 +3407,7 @@ BOOL dinput_test_init_( const char *file, int line ) FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, 0, NULL ); ok( okfile != INVALID_HANDLE_VALUE, "failed to create file, error %lu\n", GetLastError() );
- subtest( "driver_hid" ); + subtest( "driver" ); return TRUE; }
@@ -3555,9 +3567,9 @@ DWORD WINAPI dinput_test_device_thread( void *stop_event ) status = RegSetValueExW( hkey, L"Context", 0, REG_BINARY, (void *)context, sizeof(context) ); ok( !status, "RegSetValueExW returned %#lx\n", status );
- pnp_driver_start( L"driver_hid.dll" ); + hid_device_start(); WaitForSingleObject( stop_event, INFINITE ); - pnp_driver_stop(); + hid_device_stop();
SetCurrentDirectoryW( cwd );
diff --git a/dlls/dinput/tests/hotplug.c b/dlls/dinput/tests/hotplug.c index 3580964e187..e212f874be3 100644 --- a/dlls/dinput/tests/hotplug.c +++ b/dlls/dinput/tests/hotplug.c @@ -185,7 +185,7 @@ static BOOL test_input_lost( DWORD version ) ok( hr == DI_OK, "GetDeviceData returned %#lx\n", hr ); ok( count == 0, "got %lu expected 0\n", count );
- pnp_driver_stop(); + hid_device_stop();
hr = IDirectInputDevice8_GetDeviceState( device, sizeof(state), &state ); ok( hr == DIERR_INPUTLOST, "GetDeviceState returned %#lx\n", hr ); @@ -218,7 +218,7 @@ static BOOL test_input_lost( DWORD version ) ok( ref == 0, "Release returned %ld\n", ref );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd );
diff --git a/dlls/dinput/tests/joystick8.c b/dlls/dinput/tests/joystick8.c index c4cfceeee3e..ca7cc9a1a32 100644 --- a/dlls/dinput/tests/joystick8.c +++ b/dlls/dinput/tests/joystick8.c @@ -2084,7 +2084,7 @@ static void test_simple_joystick( DWORD version ) CloseHandle( file );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd ); winetest_pop_context(); @@ -2616,7 +2616,7 @@ static BOOL test_device_types( DWORD version ) ok( ref == 0, "Release returned %ld\n", ref );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd ); winetest_pop_context(); @@ -2842,7 +2842,7 @@ static void test_driving_wheel_axes(void) ok( ref == 0, "Release returned %ld\n", ref );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd ); winetest_pop_context(); @@ -3200,7 +3200,7 @@ static BOOL test_winmm_joystick(void) CloseHandle( file );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd );
@@ -3395,7 +3395,7 @@ static void test_windows_gaming_input(void) IRawGameControllerStatics_Release( controller_statics );
done: - pnp_driver_stop(); + hid_device_stop(); cleanup_registry_keys(); SetCurrentDirectoryW( cwd ); }
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=110832
Your paranoid android.
=== w1064_tsign (64 bit report) ===
dinput: joystick8.c:1844: Test failed: 0x800: state[0]: WaitForSingleObject succeeded
=== debian11 (32 bit Hindi:India report) ===
dinput: mouse.c:159: Test failed: Acquire() failed: 0x80070005 mouse.c:164: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:168: Test failed: Failed: 0x1 mouse.c:171: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:174: Test failed: Failed: 0x80070005 mouse.c:177: Test failed: Failed: 0x1 mouse.c:180: Test failed: Failed: 0x80070005 mouse.c:183: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:194: Test failed: GetDeviceData() failed: 0 cnt:0
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/driver.c | 13 ------------- 1 file changed, 13 deletions(-)
diff --git a/dlls/dinput/tests/driver.c b/dlls/dinput/tests/driver.c index e4101853833..579d82cfeed 100644 --- a/dlls/dinput/tests/driver.c +++ b/dlls/dinput/tests/driver.c @@ -457,18 +457,6 @@ static NTSTATUS WINAPI driver_pnp( DEVICE_OBJECT *device, IRP *irp ) return IoCallDriver( ext->NextDeviceObject, irp ); }
-static NTSTATUS WINAPI driver_power( DEVICE_OBJECT *device, IRP *irp ) -{ - HID_DEVICE_EXTENSION *ext = device->DeviceExtension; - - /* We do not expect power IRPs as part of normal operation. */ - ok( 0, "unexpected call\n" ); - - PoStartNextPowerIrp( irp ); - IoSkipCurrentIrpStackLocation( irp ); - return PoCallDriver( ext->NextDeviceObject, irp ); -} - #define check_buffer( a, b ) check_buffer_( __LINE__, a, b ) static void check_buffer_( int line, HID_XFER_PACKET *packet, struct hid_expect *expect ) { @@ -889,7 +877,6 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *registry ) driver->DriverExtension->AddDevice = driver_add_device; driver->DriverUnload = driver_unload; driver->MajorFunction[IRP_MJ_PNP] = driver_pnp; - driver->MajorFunction[IRP_MJ_POWER] = driver_power; driver->MajorFunction[IRP_MJ_DEVICE_CONTROL] = driver_ioctl; driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = driver_internal_ioctl; driver->MajorFunction[IRP_MJ_CREATE] = driver_create;
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=110833
Your paranoid android.
=== w7u_2qxl (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w7u_adm (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w7u_el (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w8 (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w8adm (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w864 (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064v1507 (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064v1809 (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064 (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064_tsign (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w10pro64 (32 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w864 (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064v1507 (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064v1809 (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064 (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064_2qxl (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w1064_tsign (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w10pro64 (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w10pro64_ar (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w10pro64_he (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w10pro64_ja (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
=== w10pro64_zh_CN (64 bit report) ===
dinput: Fatal: test 'driver' does not exist.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/hid.c | 106 ++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 58 deletions(-)
diff --git a/dlls/dinput/tests/hid.c b/dlls/dinput/tests/hid.c index b5683b18850..6203f67bb25 100644 --- a/dlls/dinput/tests/hid.c +++ b/dlls/dinput/tests/hid.c @@ -489,6 +489,42 @@ static void pnp_driver_stop(void) ok( ret || GetLastError() == ERROR_FILE_NOT_FOUND, "Failed to delete file, error %lu\n", GetLastError() ); }
+static BOOL find_hid_device_path( WCHAR *device_path ) +{ + char buffer[FIELD_OFFSET( SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath[MAX_PATH] )] = {0}; + SP_DEVICE_INTERFACE_DATA iface = {sizeof(SP_DEVICE_INTERFACE_DATA)}; + SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail = (void *)buffer; + SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; + ULONG i, len = wcslen( device_path ); + HDEVINFO set; + BOOL ret; + + set = SetupDiGetClassDevsW( &GUID_DEVINTERFACE_HID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT ); + ok( set != INVALID_HANDLE_VALUE, "Failed to get device list, error %#lx\n", GetLastError() ); + + for (i = 0; SetupDiEnumDeviceInfo( set, i, &device ); ++i) + { + ret = SetupDiEnumDeviceInterfaces( set, &device, &GUID_DEVINTERFACE_HID, 0, &iface ); + ok( ret, "Failed to get interface, error %#lx\n", GetLastError() ); + ok( IsEqualGUID( &iface.InterfaceClassGuid, &GUID_DEVINTERFACE_HID ), "wrong class %s\n", + debugstr_guid( &iface.InterfaceClassGuid ) ); + ok( iface.Flags == SPINT_ACTIVE, "got flags %#lx\n", iface.Flags ); + + iface_detail->cbSize = sizeof(*iface_detail); + ret = SetupDiGetDeviceInterfaceDetailW( set, &iface, iface_detail, sizeof(buffer), NULL, NULL ); + ok( ret, "Failed to get interface path, error %#lx\n", GetLastError() ); + + if (!wcsncmp( iface_detail->DevicePath, device_path, len )) break; + } + + ret = SetupDiDestroyDeviceInfoList( set ); + ok( ret, "Failed to destroy set, error %lu\n", GetLastError() ); + + ret = !wcsncmp( iface_detail->DevicePath, device_path, len ); + if (ret) wcscpy( device_path, iface_detail->DevicePath ); + return ret; +} + static BOOL pnp_driver_start(void) { static const WCHAR hardware_id[] = L"test_hardware_id\0"; @@ -2337,50 +2373,22 @@ static void test_hidp( HANDLE file, HANDLE async_file, int report_id, BOOL polle
static void test_hid_device( DWORD report_id, DWORD polled, const HIDP_CAPS *expect_caps ) { - char buffer[FIELD_OFFSET( SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath[MAX_PATH] )]; - SP_DEVICE_INTERFACE_DATA iface = {sizeof(SP_DEVICE_INTERFACE_DATA)}; - SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail = (void *)buffer; - SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; ULONG count, poll_freq, out_len; + WCHAR device_path[MAX_PATH]; HANDLE file, async_file; - BOOL ret, found = FALSE; OBJECT_ATTRIBUTES attr; UNICODE_STRING string; IO_STATUS_BLOCK io; NTSTATUS status; - unsigned int i; - HDEVINFO set; + BOOL ret;
winetest_push_context( "id %ld%s", report_id, polled ? " poll" : "" );
- set = SetupDiGetClassDevsW( &GUID_DEVINTERFACE_HID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT ); - ok( set != INVALID_HANDLE_VALUE, "failed to get device list, error %#lx\n", GetLastError() ); + swprintf( device_path, MAX_PATH, L"\\?\hid#winetest#" ); + ret = find_hid_device_path( device_path ); + ok( ret, "Failed to find HID device matching %s\n", debugstr_w( device_path ) );
- for (i = 0; SetupDiEnumDeviceInfo( set, i, &device ); ++i) - { - ret = SetupDiEnumDeviceInterfaces( set, &device, &GUID_DEVINTERFACE_HID, 0, &iface ); - ok( ret, "failed to get interface, error %#lx\n", GetLastError() ); - ok( IsEqualGUID( &iface.InterfaceClassGuid, &GUID_DEVINTERFACE_HID ), "wrong class %s\n", - debugstr_guid( &iface.InterfaceClassGuid ) ); - ok( iface.Flags == SPINT_ACTIVE, "got flags %#lx\n", iface.Flags ); - - iface_detail->cbSize = sizeof(*iface_detail); - ret = SetupDiGetDeviceInterfaceDetailW( set, &iface, iface_detail, sizeof(buffer), NULL, NULL ); - ok( ret, "failed to get interface path, error %#lx\n", GetLastError() ); - - if (wcsstr( iface_detail->DevicePath, L"\\?\hid#winetest#1" )) - { - found = TRUE; - break; - } - } - - SetupDiDestroyDeviceInfoList( set ); - - todo_wine - ok( found, "didn't find device\n" ); - - file = CreateFileW( iface_detail->DevicePath, FILE_READ_ACCESS | FILE_WRITE_ACCESS, + file = CreateFileW( device_path, FILE_READ_ACCESS | FILE_WRITE_ACCESS, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); ok( file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError() );
@@ -2411,7 +2419,7 @@ static void test_hid_device( DWORD report_id, DWORD polled, const HIDP_CAPS *exp ok( ret, "HidD_GetNumInputBuffers failed last error %lu\n", GetLastError() ); ok( count == 16, "HidD_GetNumInputBuffers returned %lu\n", count );
- async_file = CreateFileW( iface_detail->DevicePath, FILE_READ_ACCESS | FILE_WRITE_ACCESS, + async_file = CreateFileW( device_path, FILE_READ_ACCESS | FILE_WRITE_ACCESS, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL ); ok( async_file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError() ); @@ -3133,17 +3141,13 @@ static void test_hidp_kdr(void) }, };
- char buffer[FIELD_OFFSET( SP_DEVICE_INTERFACE_DETAIL_DATA_W, DevicePath[MAX_PATH] )]; - SP_DEVICE_INTERFACE_DATA iface = {sizeof(SP_DEVICE_INTERFACE_DATA)}; - SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail = (void *)buffer; - SP_DEVINFO_DATA device = {sizeof(SP_DEVINFO_DATA)}; WCHAR cwd[MAX_PATH], tempdir[MAX_PATH]; PHIDP_PREPARSED_DATA preparsed_data; DWORD i, report_id = 0, polled = 0; + WCHAR device_path[MAX_PATH]; struct hidp_kdr *kdr; char context[64]; LSTATUS status; - HDEVINFO set; HANDLE file; HKEY hkey; BOOL ret; @@ -3183,25 +3187,11 @@ static void test_hidp_kdr(void)
if (!hid_device_start()) goto done;
- set = SetupDiGetClassDevsW( &GUID_DEVINTERFACE_HID, NULL, NULL, DIGCF_DEVICEINTERFACE | DIGCF_PRESENT ); - ok( set != INVALID_HANDLE_VALUE, "failed to get device list, error %#lx\n", GetLastError() ); - for (i = 0; SetupDiEnumDeviceInfo( set, i, &device ); ++i) - { - ret = SetupDiEnumDeviceInterfaces( set, &device, &GUID_DEVINTERFACE_HID, 0, &iface ); - ok( ret, "failed to get interface, error %#lx\n", GetLastError() ); - ok( IsEqualGUID( &iface.InterfaceClassGuid, &GUID_DEVINTERFACE_HID ), "wrong class %s\n", - debugstr_guid( &iface.InterfaceClassGuid ) ); - ok( iface.Flags == SPINT_ACTIVE, "got flags %#lx\n", iface.Flags ); + swprintf( device_path, MAX_PATH, L"\\?\hid#winetest#" ); + ret = find_hid_device_path( device_path ); + ok( ret, "Failed to find HID device matching %s\n", debugstr_w( device_path ) );
- iface_detail->cbSize = sizeof(*iface_detail); - ret = SetupDiGetDeviceInterfaceDetailW( set, &iface, iface_detail, sizeof(buffer), NULL, NULL ); - ok( ret, "failed to get interface path, error %#lx\n", GetLastError() ); - - if (wcsstr( iface_detail->DevicePath, L"\\?\hid#winetest#1" )) break; - } - SetupDiDestroyDeviceInfoList( set ); - - file = CreateFileW( iface_detail->DevicePath, FILE_READ_ACCESS | FILE_WRITE_ACCESS, + file = CreateFileW( device_path, FILE_READ_ACCESS | FILE_WRITE_ACCESS, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); ok( file != INVALID_HANDLE_VALUE, "got error %lu\n", GetLastError() );
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/dinput/tests/driver.c | 50 +++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 6 deletions(-)
diff --git a/dlls/dinput/tests/driver.c b/dlls/dinput/tests/driver.c index 579d82cfeed..54a281072f9 100644 --- a/dlls/dinput/tests/driver.c +++ b/dlls/dinput/tests/driver.c @@ -406,6 +406,33 @@ struct hid_device KSPIN_LOCK lock; };
+static DRIVER_OBJECT *expect_driver; +static DEVICE_OBJECT *expect_bus_pdo; +static DEVICE_OBJECT *expect_hid_fdo; +static DEVICE_OBJECT *expect_hid_pdo; +static struct hid_device *expect_hid_ext; + +static void check_device( DEVICE_OBJECT *device ) +{ + static int checked_fdo, checked_pdo; + HID_DEVICE_EXTENSION *ext = device->DeviceExtension; + + ok( device == expect_hid_pdo || device == expect_hid_fdo, "got device %p\n", device ); + ok( device->DriverObject == expect_driver, "got DriverObject %p\n", device->DriverObject ); + if (!device->NextDevice) ok( device == expect_hid_fdo, "got device %p\n", device ); + else ok( device->NextDevice == expect_hid_fdo, "got NextDevice %p\n", device->NextDevice ); + ok( !device->AttachedDevice, "got AttachedDevice %p\n", device->AttachedDevice ); + + if (device == expect_hid_pdo && checked_pdo++) return; + if (device == expect_hid_fdo && checked_fdo++) return; + + todo_wine_if( device != expect_hid_fdo ) + ok( ext->MiniDeviceExtension == expect_hid_ext, "got MiniDeviceExtension %p\n", ext->MiniDeviceExtension ); + if (ext->MiniDeviceExtension != expect_hid_ext) return; + ok( ext->PhysicalDeviceObject == expect_bus_pdo, "got PhysicalDeviceObject %p\n", ext->PhysicalDeviceObject ); + ok( ext->NextDeviceObject == expect_bus_pdo, "got NextDeviceObject %p\n", ext->NextDeviceObject ); +} + static NTSTATUS WINAPI driver_pnp( DEVICE_OBJECT *device, IRP *irp ) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp ); @@ -493,6 +520,9 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp )
if (winetest_debug > 1) trace( "%s: device %p, code %#lx %s\n", __func__, device, code, debugstr_ioctl(code) );
+ ok( expect_hid_fdo == device, "got device %p\n", device ); + check_device( device ); + ok( got_start_device, "expected IRP_MN_START_DEVICE before any ioctls\n" );
irp->IoStatus.Information = 0; @@ -706,7 +736,7 @@ static NTSTATUS WINAPI driver_internal_ioctl( DEVICE_OBJECT *device, IRP *irp ) return ret; }
-static NTSTATUS( WINAPI *hidclass_driver_ioctl )(DEVICE_OBJECT *device, IRP *irp); +static NTSTATUS (WINAPI *hidclass_driver_ioctl)( DEVICE_OBJECT *device, IRP *irp ); static NTSTATUS WINAPI driver_ioctl( DEVICE_OBJECT *device, IRP *irp ) { IO_STACK_LOCATION *stack = IoGetCurrentIrpStackLocation( irp ); @@ -716,6 +746,10 @@ static NTSTATUS WINAPI driver_ioctl( DEVICE_OBJECT *device, IRP *irp )
if (winetest_debug > 1) trace( "%s: device %p, code %#lx %s\n", __func__, device, code, debugstr_ioctl(code) );
+ if (!expect_hid_pdo) expect_hid_pdo = device; + else ok( expect_hid_pdo == device, "got device %p\n", device ); + check_device( device ); + switch (code) { case IOCTL_WINETEST_HID_SET_EXPECT: @@ -750,12 +784,14 @@ static NTSTATUS WINAPI driver_add_device( DRIVER_OBJECT *driver, DEVICE_OBJECT *
if (winetest_debug > 1) trace( "%s: driver %p, device %p\n", __func__, driver, device );
- /* We should be given the FDO, not the PDO. */ - ok( !!ext->PhysicalDeviceObject, "expected non-NULL pdo\n" ); - ok( ext->NextDeviceObject == ext->PhysicalDeviceObject, "got pdo %p, next %p\n", - ext->PhysicalDeviceObject, ext->NextDeviceObject ); + expect_hid_fdo = device; + expect_bus_pdo = ext->PhysicalDeviceObject; + expect_hid_ext = ext->MiniDeviceExtension; + todo_wine - ok( ext->NextDeviceObject->AttachedDevice == device, "wrong attached device\n" ); + ok( expect_bus_pdo->AttachedDevice == device, "got AttachedDevice %p\n", expect_bus_pdo->AttachedDevice ); + ok( driver == expect_driver, "got driver %p\n", driver ); + check_device( device );
ret = IoRegisterDeviceInterface( ext->PhysicalDeviceObject, &control_class, NULL, &control_symlink ); ok( !ret, "got %#lx\n", ret ); @@ -809,6 +845,8 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *registry ) HANDLE hkey; DWORD size;
+ expect_driver = driver; + if ((ret = winetest_init())) return ret; if (winetest_debug > 1) trace( "%s: driver %p\n", __func__, driver );
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=110835
Your paranoid android.
=== build (build log) ===
error: patch failed: dlls/dinput/tests/driver.c:493 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/driver.c:493 Task: Patch failed to apply
=== debian11 (build log) ===
error: patch failed: dlls/dinput/tests/driver.c:493 Task: Patch failed to apply
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=110831
Your paranoid android.
=== debian11 (32 bit Hindi:India report) ===
dinput: mouse.c:159: Test failed: Acquire() failed: 0x80070005 mouse.c:164: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:168: Test failed: Failed: 0x1 mouse.c:171: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:174: Test failed: Failed: 0x80070005 mouse.c:177: Test failed: Failed: 0x1 mouse.c:180: Test failed: Failed: 0x80070005 mouse.c:183: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:194: Test failed: GetDeviceData() failed: 0 cnt:0
=== debian11 (32 bit WoW report) ===
dinput: mouse.c:159: Test failed: Acquire() failed: 0x80070005 mouse.c:164: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:168: Test failed: Failed: 0x1 mouse.c:171: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:174: Test failed: Failed: 0x80070005 mouse.c:177: Test failed: Failed: 0x1 mouse.c:180: Test failed: Failed: 0x80070005 mouse.c:183: Test failed: GetDeviceData() failed: 0 cnt:0 mouse.c:194: Test failed: GetDeviceData() failed: 0 cnt:0