Commit 56113351 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput/tests: Fix source file in driver test context.

parent 01e8a9d0
...@@ -68,16 +68,8 @@ void dinput_test_exit(void); ...@@ -68,16 +68,8 @@ void dinput_test_exit(void);
HRESULT dinput_test_create_device( DWORD version, DIDEVICEINSTANCEW *devinst, IDirectInputDevice8W **device ); HRESULT dinput_test_create_device( DWORD version, DIDEVICEINSTANCEW *devinst, IDirectInputDevice8W **device );
DWORD WINAPI dinput_test_device_thread( void *stop_event ); DWORD WINAPI dinput_test_device_thread( void *stop_event );
#define fill_context( line, a, b ) \ #define fill_context( a, b ) fill_context_( __FILE__, __LINE__, a, b )
do \ void fill_context_( const char *file, int line, char *buffer, SIZE_T size );
{ \
const char *source_file; \
source_file = strrchr( __FILE__, '/' ); \
if (!source_file) source_file = strrchr( __FILE__, '\\' ); \
if (!source_file) source_file = __FILE__; \
else source_file++; \
snprintf( a, b, "%s:%d", source_file, line ); \
} while (0)
#define check_member_( file, line, val, exp, fmt, member ) \ #define check_member_( file, line, val, exp, fmt, member ) \
ok_(file, line)( (val).member == (exp).member, "got " #member " " fmt "\n", (val).member ) ok_(file, line)( (val).member == (exp).member, "got " #member " " fmt "\n", (val).member )
......
...@@ -2838,7 +2838,7 @@ static BOOL test_force_feedback_joystick( DWORD version ) ...@@ -2838,7 +2838,7 @@ static BOOL test_force_feedback_joystick( DWORD version )
desc.report_descriptor_len = sizeof(report_descriptor); desc.report_descriptor_len = sizeof(report_descriptor);
memcpy( desc.report_descriptor_buf, report_descriptor, sizeof(report_descriptor) ); memcpy( desc.report_descriptor_buf, report_descriptor, sizeof(report_descriptor) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
if (FAILED(hr = dinput_test_create_device( version, &devinst, &device ))) goto done; if (FAILED(hr = dinput_test_create_device( version, &devinst, &device ))) goto done;
...@@ -3959,7 +3959,7 @@ static void test_device_managed_effect(void) ...@@ -3959,7 +3959,7 @@ static void test_device_managed_effect(void)
memcpy( desc.report_descriptor_buf, report_descriptor, sizeof(report_descriptor) ); memcpy( desc.report_descriptor_buf, report_descriptor, sizeof(report_descriptor) );
desc.expect_size = sizeof(expect_pool); desc.expect_size = sizeof(expect_pool);
memcpy( desc.expect, expect_pool, sizeof(expect_pool) ); memcpy( desc.expect, expect_pool, sizeof(expect_pool) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
if (FAILED(hr = dinput_test_create_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done; if (FAILED(hr = dinput_test_create_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done;
...@@ -5706,7 +5706,7 @@ static void test_windows_gaming_input(void) ...@@ -5706,7 +5706,7 @@ static void test_windows_gaming_input(void)
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
desc.expect_size = sizeof(expect_init); desc.expect_size = sizeof(expect_init);
memcpy( desc.expect, expect_init, sizeof(expect_init) ); memcpy( desc.expect, expect_init, sizeof(expect_init) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
WaitForSingleObject( controller_added.event, INFINITE ); WaitForSingleObject( controller_added.event, INFINITE );
......
...@@ -899,12 +899,22 @@ BOOL sync_ioctl_( const char *file, int line, HANDLE device, DWORD code, void *i ...@@ -899,12 +899,22 @@ BOOL sync_ioctl_( const char *file, int line, HANDLE device, DWORD code, void *i
return ret; return ret;
} }
void fill_context_( const char *file, int line, char *buffer, SIZE_T size )
{
const char *source_file;
source_file = strrchr( file, '/' );
if (!source_file) source_file = strrchr( file, '\\' );
if (!source_file) source_file = file;
else source_file++;
snprintf( buffer, size, "%s:%d", source_file, line );
}
void set_hid_expect_( const char *file, int line, HANDLE device, struct hid_expect *expect, DWORD expect_size ) void set_hid_expect_( const char *file, int line, HANDLE device, struct hid_expect *expect, DWORD expect_size )
{ {
char context[64]; char context[64];
BOOL ret; BOOL ret;
fill_context( line, context, ARRAY_SIZE(context) ); fill_context_( file, line, context, ARRAY_SIZE(context) );
ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SET_CONTEXT, context, ARRAY_SIZE(context), NULL, 0, INFINITE ); ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SET_CONTEXT, context, ARRAY_SIZE(context), NULL, 0, INFINITE );
ok_(file, line)( ret, "IOCTL_WINETEST_HID_SET_CONTEXT failed, last error %lu\n", GetLastError() ); ok_(file, line)( ret, "IOCTL_WINETEST_HID_SET_CONTEXT failed, last error %lu\n", GetLastError() );
ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SET_EXPECT, expect, expect_size, NULL, 0, INFINITE ); ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SET_EXPECT, expect, expect_size, NULL, 0, INFINITE );
...@@ -928,7 +938,7 @@ void send_hid_input_( const char *file, int line, HANDLE device, struct hid_expe ...@@ -928,7 +938,7 @@ void send_hid_input_( const char *file, int line, HANDLE device, struct hid_expe
char context[64]; char context[64];
BOOL ret; BOOL ret;
fill_context( line, context, ARRAY_SIZE(context) ); fill_context_( file, line, context, ARRAY_SIZE(context) );
ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SET_CONTEXT, context, ARRAY_SIZE(context), NULL, 0, INFINITE ); ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SET_CONTEXT, context, ARRAY_SIZE(context), NULL, 0, INFINITE );
ok_(file, line)( ret, "IOCTL_WINETEST_HID_SET_CONTEXT failed, last error %lu\n", GetLastError() ); ok_(file, line)( ret, "IOCTL_WINETEST_HID_SET_CONTEXT failed, last error %lu\n", GetLastError() );
ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SEND_INPUT, expect, expect_size, NULL, 0, INFINITE ); ret = sync_ioctl_( file, line, device, IOCTL_WINETEST_HID_SEND_INPUT, expect, expect_size, NULL, 0, INFINITE );
...@@ -2894,7 +2904,7 @@ static void test_hid_driver( DWORD report_id, DWORD polled ) ...@@ -2894,7 +2904,7 @@ static void test_hid_driver( DWORD report_id, DWORD polled )
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
desc.input_size = polled ? sizeof(expect_in) : 0; desc.input_size = polled ? sizeof(expect_in) : 0;
memcpy( desc.input, &expect_in, sizeof(expect_in) ); memcpy( desc.input, &expect_in, sizeof(expect_in) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (hid_device_start( &desc )) test_hid_device( report_id, polled, &caps, desc.attributes.VendorID, desc.attributes.ProductID ); if (hid_device_start( &desc )) test_hid_device( report_id, polled, &caps, desc.attributes.VendorID, desc.attributes.ProductID );
hid_device_stop( &desc ); hid_device_stop( &desc );
...@@ -3208,7 +3218,7 @@ static void test_hidp_kdr(void) ...@@ -3208,7 +3218,7 @@ static void test_hidp_kdr(void)
desc.report_descriptor_len = sizeof(report_desc); desc.report_descriptor_len = sizeof(report_desc);
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
...@@ -3597,7 +3607,7 @@ DWORD WINAPI dinput_test_device_thread( void *stop_event ) ...@@ -3597,7 +3607,7 @@ DWORD WINAPI dinput_test_device_thread( void *stop_event )
desc.report_descriptor_len = sizeof(gamepad_desc); desc.report_descriptor_len = sizeof(gamepad_desc);
memcpy( desc.report_descriptor_buf, gamepad_desc, sizeof(gamepad_desc) ); memcpy( desc.report_descriptor_buf, gamepad_desc, sizeof(gamepad_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
hid_device_start( &desc ); hid_device_start( &desc );
WaitForSingleObject( stop_event, INFINITE ); WaitForSingleObject( stop_event, INFINITE );
......
...@@ -167,7 +167,7 @@ static BOOL test_input_lost( DWORD version ) ...@@ -167,7 +167,7 @@ static BOOL test_input_lost( DWORD version )
desc.report_descriptor_len = sizeof(report_desc); desc.report_descriptor_len = sizeof(report_desc);
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
if (FAILED(hr = dinput_test_create_device( version, &devinst, &device ))) goto done; if (FAILED(hr = dinput_test_create_device( version, &devinst, &device ))) goto done;
...@@ -209,7 +209,7 @@ static BOOL test_input_lost( DWORD version ) ...@@ -209,7 +209,7 @@ static BOOL test_input_lost( DWORD version )
hr = IDirectInputDevice8_Unacquire( device ); hr = IDirectInputDevice8_Unacquire( device );
ok( hr == DI_NOEFFECT, "Unacquire returned: %#lx\n", hr ); ok( hr == DI_NOEFFECT, "Unacquire returned: %#lx\n", hr );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
hid_device_start( &desc ); hid_device_start( &desc );
hr = IDirectInputDevice8_Acquire( device ); hr = IDirectInputDevice8_Acquire( device );
......
...@@ -802,7 +802,7 @@ static void test_simple_joystick( DWORD version ) ...@@ -802,7 +802,7 @@ static void test_simple_joystick( DWORD version )
desc.report_descriptor_len = sizeof(report_desc); desc.report_descriptor_len = sizeof(report_desc);
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
if (FAILED(hr = dinput_test_create_device( version, &devinst, &device ))) goto done; if (FAILED(hr = dinput_test_create_device( version, &devinst, &device ))) goto done;
...@@ -2575,7 +2575,7 @@ static BOOL test_device_types( DWORD version ) ...@@ -2575,7 +2575,7 @@ static BOOL test_device_types( DWORD version )
desc.caps = device_desc[i].hid_caps; desc.caps = device_desc[i].hid_caps;
desc.report_descriptor_len = device_desc[i].report_desc_len; desc.report_descriptor_len = device_desc[i].report_desc_len;
memcpy( desc.report_descriptor_buf, device_desc[i].report_desc_buf, device_desc[i].report_desc_len ); memcpy( desc.report_descriptor_buf, device_desc[i].report_desc_buf, device_desc[i].report_desc_len );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) if (!hid_device_start( &desc ))
{ {
...@@ -3022,7 +3022,7 @@ static void test_many_axes_joystick(void) ...@@ -3022,7 +3022,7 @@ static void test_many_axes_joystick(void)
desc.report_descriptor_len = sizeof(report_desc); desc.report_descriptor_len = sizeof(report_desc);
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
if (FAILED(hr = dinput_test_create_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done; if (FAILED(hr = dinput_test_create_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done;
...@@ -3364,7 +3364,7 @@ static void test_driving_wheel_axes(void) ...@@ -3364,7 +3364,7 @@ static void test_driving_wheel_axes(void)
desc.report_descriptor_len = sizeof(report_desc); desc.report_descriptor_len = sizeof(report_desc);
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
if (FAILED(hr = dinput_test_create_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done; if (FAILED(hr = dinput_test_create_device( DIRECTINPUT_VERSION, &devinst, &device ))) goto done;
...@@ -3600,7 +3600,7 @@ static BOOL test_winmm_joystick(void) ...@@ -3600,7 +3600,7 @@ static BOOL test_winmm_joystick(void)
desc.report_descriptor_len = sizeof(report_desc); desc.report_descriptor_len = sizeof(report_desc);
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
...@@ -4022,7 +4022,7 @@ static void test_windows_gaming_input(void) ...@@ -4022,7 +4022,7 @@ static void test_windows_gaming_input(void)
desc.report_descriptor_len = sizeof(report_desc); desc.report_descriptor_len = sizeof(report_desc);
memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) ); memcpy( desc.report_descriptor_buf, report_desc, sizeof(report_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
if (!hid_device_start( &desc )) goto done; if (!hid_device_start( &desc )) goto done;
WaitForSingleObject( controller_added.event, INFINITE ); WaitForSingleObject( controller_added.event, INFINITE );
...@@ -4097,7 +4097,7 @@ static void test_windows_gaming_input(void) ...@@ -4097,7 +4097,7 @@ static void test_windows_gaming_input(void)
desc.report_descriptor_len = sizeof(wheel_threepedals_desc); desc.report_descriptor_len = sizeof(wheel_threepedals_desc);
memcpy( desc.report_descriptor_buf, wheel_threepedals_desc, sizeof(wheel_threepedals_desc) ); memcpy( desc.report_descriptor_buf, wheel_threepedals_desc, sizeof(wheel_threepedals_desc) );
fill_context( __LINE__, desc.context, ARRAY_SIZE(desc.context) ); fill_context( desc.context, ARRAY_SIZE(desc.context) );
controller_added.event = CreateEventW( NULL, FALSE, FALSE, NULL ); controller_added.event = CreateEventW( NULL, FALSE, FALSE, NULL );
ok( !!controller_added.event, "CreateEventW failed, error %lu\n", GetLastError() ); ok( !!controller_added.event, "CreateEventW failed, error %lu\n", GetLastError() );
......
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