[PATCH 0/1] MR2261: dinput/tests: Skip the tests if acquiring the device fails.
From: Francois Gouget <fgouget(a)codeweavers.com> All the tests that follow would fail anyway, making it hard to filter them out to avoid false positives. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=54558 --- Acquiring the device seems to randomly fail with a permission denied error, maybe when some other test triggers an UAC prompt. --- dlls/dinput/tests/device8.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/dlls/dinput/tests/device8.c b/dlls/dinput/tests/device8.c index 1f29c9af519..9db7d1149fb 100644 --- a/dlls/dinput/tests/device8.c +++ b/dlls/dinput/tests/device8.c @@ -344,7 +344,11 @@ void test_overlapped_format( DWORD version ) hr = IDirectInputDevice_Acquire( keyboard ); - ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + if (hr != DI_OK) + { + ok(0, "Acquire failed %#lx, skipping the remainder of test_overlapped_format\n", hr ); + return; + } keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE, 0 ); res = WaitForSingleObject( event, 100 ); @@ -405,7 +409,11 @@ void test_overlapped_format( DWORD version ) hr = IDirectInputDevice_Acquire( keyboard ); - ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + if (hr != DI_OK) + { + ok(0, "Acquire failed %#lx, skipping the remainder of test_overlapped_format\n", hr ); + return; + } keybd_event( 0, DIK_F, KEYEVENTF_SCANCODE, 0 ); res = WaitForSingleObject( event, 100 ); @@ -1969,7 +1977,11 @@ static void test_sys_mouse( DWORD version ) hr = IDirectInputDevice8_Unacquire( device ); ok( hr == DI_NOEFFECT, "Unacquire returned %#lx\n", hr ); hr = IDirectInputDevice8_Acquire( device ); - ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + if (hr != DI_OK) + { + ok(0, "Acquire failed %#lx, skipping the remainder of test_sys_mouse\n", hr ); + return; + } hr = IDirectInputDevice8_Acquire( device ); ok( hr == DI_NOEFFECT, "Acquire returned %#lx\n", hr ); @@ -1999,7 +2011,11 @@ static void test_sys_mouse( DWORD version ) ok( count == 1, "got count %lu\n", count ); hr = IDirectInputDevice8_Acquire( device ); - ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + if (hr != DI_OK) + { + ok(0, "Acquire failed %#lx, skipping the remainder of test_sys_mouse\n", hr ); + return; + } mouse_event( MOUSEEVENTF_MOVE, 10, 10, 0, 0 ); res = WaitForSingleObject( event, 100 ); @@ -2014,7 +2030,11 @@ static void test_sys_mouse( DWORD version ) ok( hr == DI_OK, "Unacquire returned %#lx\n", hr ); hr = IDirectInputDevice8_Acquire( device ); - ok( hr == DI_OK, "Acquire returned %#lx\n", hr ); + if (hr != DI_OK) + { + ok(0, "Acquire failed %#lx, skipping the remainder of test_sys_mouse\n", hr ); + return; + } count = 1; hr = IDirectInputDevice8_GetDeviceData( device, sizeof(objdata), &objdata, &count, 0 ); ok( hr == (version < 0x800 ? DI_OK : DI_BUFFEROVERFLOW), "GetDeviceData returned %#lx\n", hr ); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2261
Rémi Bernon (@rbernon) commented about dlls/dinput/tests/device8.c:
ok( count == 1, "got count %lu\n", count );
IUnknown_Release( keyboard );
Adding a cleanup label around here and using goto instead of return would be a bit nicer. Same for the mouse. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2261#note_25202
This merge request was closed by Rémi Bernon. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2261
On Wed Feb 22 18:56:51 2023 +0000, Rémi Bernon wrote:
Adding a cleanup label around here and using goto instead of return would be a bit nicer. Same for the mouse. I've made the changes and it's been merged.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/2261#note_27089
participants (3)
-
Francois Gouget -
Francois Gouget (@fgouget) -
Rémi Bernon