-- v2: dlls/bluetoothapis: Implement BluetoothFindRadioClose. dlls/bluetoothapis/tests: Add tests for BluetoothFindRadioClose. dlls/bluetoothapis: Implement BluetoothFindNextRadio. dlls/bluetoothapis/tests: Add tests for BluetoothFindNextRadio.
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/tests/sdp.c | 38 +++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/dlls/bluetoothapis/tests/sdp.c b/dlls/bluetoothapis/tests/sdp.c index 6f3bba8360f..9b6028c0a2f 100644 --- a/dlls/bluetoothapis/tests/sdp.c +++ b/dlls/bluetoothapis/tests/sdp.c @@ -33,6 +33,42 @@ static const char *debugstr_SDP_ELEMENT_DATA( const SDP_ELEMENT_DATA *data ) data->data.uint128.LowPart, data->data.uint128.HighPart ); }
+/* Returns the exact number of bytes we need to compare to test equality between the 'data' fields of two + * SDP_ELEMENT_DATA. */ +static SIZE_T sdp_type_size( SDP_TYPE type, SDP_SPECIFICTYPE st ) +{ + + switch (type) + { + case SDP_TYPE_NIL: + return 0; + case SDP_TYPE_BOOLEAN: + return sizeof( UCHAR ); + case SDP_TYPE_INT: + case SDP_TYPE_UINT: +#define XX(st) case SDP_ST_UINT ##st: case SDP_ST_INT ##st: return (st)/8 + switch (st) + { + XX( 16 ); + XX( 32 ); + XX( 64 ); + default: XX( 128 ); + } + case SDP_TYPE_UUID: +#undef XX +#define XX(st) case SDP_ST_UUID ##st: return (st)/8 + switch (st) + { + XX( 16 ); + XX( 32 ); + default: XX( 128 ); + } +#undef XX + default: + return sizeof( BYTE * ) + sizeof( ULONG ); + } +} + static void test_BluetoothSdpGetElementData( BYTE *stream, SIZE_T size, DWORD error, const SDP_ELEMENT_DATA *sdp_data ) { @@ -47,7 +83,7 @@ static void test_BluetoothSdpGetElementData( BYTE *stream, SIZE_T size, DWORD er ok( result.specificType == sdp_data->specificType, "%#x != %#x.\n", sdp_data->specificType, result.specificType ); - ok( !memcmp( &sdp_data->data, &result.data, sizeof( result.data ) ), + ok( !memcmp( &sdp_data->data, &result.data, sdp_type_size( result.type, result.specificType ) ), "%s != %s.\n", debugstr_SDP_ELEMENT_DATA( sdp_data ), debugstr_SDP_ELEMENT_DATA( &result ) ); }
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/tests/Makefile.in | 1 + dlls/bluetoothapis/tests/radio.c | 71 ++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 dlls/bluetoothapis/tests/radio.c
diff --git a/dlls/bluetoothapis/tests/Makefile.in b/dlls/bluetoothapis/tests/Makefile.in index c2e8bc0377a..c7d6567f578 100644 --- a/dlls/bluetoothapis/tests/Makefile.in +++ b/dlls/bluetoothapis/tests/Makefile.in @@ -2,4 +2,5 @@ TESTDLL = bluetoothapis.dll IMPORTS = bluetoothapis
SOURCES = \ + radio.c \ sdp.c diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c new file mode 100644 index 00000000000..5f83c9d54e4 --- /dev/null +++ b/dlls/bluetoothapis/tests/radio.c @@ -0,0 +1,71 @@ +/* + * Tests for Bluetooth radio methods + * + * Copyright 2024 Vibhav Pant + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include <stdarg.h> + +#include <windef.h> +#include <winbase.h> + +#include <bthsdpdef.h> +#include <bluetoothapis.h> + +#include <wine/test.h> + +void test_BluetoothFindFirstRadio( void ) +{ + HANDLE radio, dummy = (HANDLE)0xdeadbeef; + BLUETOOTH_FIND_RADIO_PARAMS find_params; + HBLUETOOTH_RADIO_FIND find; + DWORD err, exp; + + radio = dummy; + SetLastError( 0xdeadbeef ); + find = BluetoothFindFirstRadio( NULL, &radio ); + ok ( !find, "Expected %p to be NULL\n", find ); + err = GetLastError(); + todo_wine ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); + todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy ); + + radio = dummy; + find_params.dwSize = 0; + SetLastError( 0xdeadbeef ); + find = BluetoothFindFirstRadio( &find_params, &radio ); + ok ( !find, "Expected %p to be NULL\n", find ); + err = GetLastError(); + todo_wine ok( err == ERROR_REVISION_MISMATCH, "%lu != %d\n", err, ERROR_REVISION_MISMATCH ); + todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy ); + + find_params.dwSize = sizeof( find_params ); + SetLastError( 0xdeadbeef ); + find = BluetoothFindFirstRadio( &find_params, &radio ); + err = GetLastError(); + exp = find ? ERROR_SUCCESS : ERROR_NO_MORE_ITEMS; + todo_wine ok( err == exp, "%lu != %lu\n", err, exp ); + if (find) + { + CloseHandle( radio ); + todo_wine ok( BluetoothFindRadioClose( find ), "BluetoothFindRadioClose failed: %lu\n", GetLastError() ); + } +} + +START_TEST( radio ) +{ + test_BluetoothFindFirstRadio(); +}
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/Makefile.in | 1 + dlls/bluetoothapis/main.c | 85 ++++++++++++++++++++++++++++++-- dlls/bluetoothapis/tests/radio.c | 10 ++-- 3 files changed, 87 insertions(+), 9 deletions(-)
diff --git a/dlls/bluetoothapis/Makefile.in b/dlls/bluetoothapis/Makefile.in index 1fd74074703..3e2e230fe55 100644 --- a/dlls/bluetoothapis/Makefile.in +++ b/dlls/bluetoothapis/Makefile.in @@ -1,5 +1,6 @@ MODULE = bluetoothapis.dll IMPORTLIB = bluetoothapis +IMPORTS = setupapi
EXTRADLLFLAGS = -Wb,--prefer-native
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index 5d9087a9a47..c32a6fb5a0d 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -22,13 +22,25 @@ #include <stdarg.h> #include <windef.h> #include <winbase.h> +#include <winuser.h> +#include <winreg.h>
#include "wine/debug.h" #include "bthsdpdef.h" #include "bluetoothapis.h" +#include "setupapi.h" + +#include "initguid.h" +#include "bthdef.h"
WINE_DEFAULT_DEBUG_CHANNEL(bluetoothapis);
+struct bluetooth_find_radio_handle +{ + HDEVINFO devinfo; + DWORD idx; +}; + /********************************************************************* * BluetoothFindFirstDevice */ @@ -45,10 +57,75 @@ HBLUETOOTH_DEVICE_FIND WINAPI BluetoothFindFirstDevice(BLUETOOTH_DEVICE_SEARCH_P */ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS *params, HANDLE *radio) { - FIXME("(%p %p): stub!\n", params, radio); - *radio = NULL; - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return NULL; + char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)]; + SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail; + struct bluetooth_find_radio_handle *find; + SP_DEVICE_INTERFACE_DATA iface_data; + HANDLE device_ret; + BOOL found; + + TRACE("(%p, %p)\n", params, radio); + + if (!params) + { + SetLastError(ERROR_INVALID_PARAMETER); + return NULL; + } + if (params->dwSize != sizeof(*params)) + { + SetLastError(ERROR_REVISION_MISMATCH); + return NULL; + } + + find = calloc(1, sizeof(*find)); + if (!find) + { + SetLastError(ERROR_OUTOFMEMORY); + return NULL; + } + + find->devinfo = SetupDiGetClassDevsW(&GUID_BTHPORT_DEVICE_INTERFACE, NULL, NULL, + DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); + + if (find->devinfo == INVALID_HANDLE_VALUE) + { + free(find); + return NULL; + } + + iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer; + iface_detail->cbSize = sizeof(*iface_detail); + iface_data.cbSize = sizeof(iface_data); + found = FALSE; + while (SetupDiEnumDeviceInterfaces(find->devinfo, NULL, &GUID_BTHPORT_DEVICE_INTERFACE, find->idx++, + &iface_data)) + { + + if (!SetupDiGetDeviceInterfaceDetailW(find->devinfo, &iface_data, iface_detail, sizeof(buffer), NULL, + NULL)) + continue; + device_ret = CreateFileW(iface_detail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); + if (device_ret != INVALID_HANDLE_VALUE) + { + found = TRUE; + break; + } + } + + if (!found) + { + DWORD err; + err = GetLastError(); + SetupDiDestroyDeviceInfoList(find->devinfo); + free(find); + find = NULL; + SetLastError(err); + } + else + *radio = device_ret; + + return find; }
/********************************************************************* diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index 5f83c9d54e4..a39bf81b416 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -40,8 +40,8 @@ void test_BluetoothFindFirstRadio( void ) find = BluetoothFindFirstRadio( NULL, &radio ); ok ( !find, "Expected %p to be NULL\n", find ); err = GetLastError(); - todo_wine ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); - todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy ); + ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER ); + ok( radio == dummy, "%p != %p\n", radio, dummy );
radio = dummy; find_params.dwSize = 0; @@ -49,15 +49,15 @@ void test_BluetoothFindFirstRadio( void ) find = BluetoothFindFirstRadio( &find_params, &radio ); ok ( !find, "Expected %p to be NULL\n", find ); err = GetLastError(); - todo_wine ok( err == ERROR_REVISION_MISMATCH, "%lu != %d\n", err, ERROR_REVISION_MISMATCH ); - todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy ); + ok( err == ERROR_REVISION_MISMATCH, "%lu != %d\n", err, ERROR_REVISION_MISMATCH ); + ok( radio == dummy, "%p != %p\n", radio, dummy );
find_params.dwSize = sizeof( find_params ); SetLastError( 0xdeadbeef ); find = BluetoothFindFirstRadio( &find_params, &radio ); err = GetLastError(); exp = find ? ERROR_SUCCESS : ERROR_NO_MORE_ITEMS; - todo_wine ok( err == exp, "%lu != %lu\n", err, exp ); + ok( err == exp, "%lu != %lu\n", err, exp ); if (find) { CloseHandle( radio );
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/tests/radio.c | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index a39bf81b416..a394c0f7948 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -65,7 +65,48 @@ void test_BluetoothFindFirstRadio( void ) } }
+void test_BluetoothFindNextRadio( void ) +{ + HANDLE radio, dummy = (HANDLE)0xdeadbeef; + BLUETOOTH_FIND_RADIO_PARAMS find_params; + HBLUETOOTH_RADIO_FIND find; + DWORD err; + BOOL ret; + + find_params.dwSize = sizeof( find_params ); + find = BluetoothFindFirstRadio( &find_params, &radio ); + if (!find) + { + skip( "No Bluetooth radios found.\n" ); + return; + } + CloseHandle( radio ); + + radio = dummy; + SetLastError( 0xdeadbeef ); + ret = BluetoothFindNextRadio( NULL, &radio ); + todo_wine ok( !ret, "Expected BluetoothFindNextRadio to return FALSE\n" ); + err = GetLastError(); + todo_wine ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); + todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy ); + + for(;;) + { + SetLastError( 0xdeadbeef ); + ret = BluetoothFindNextRadio( find, &radio ); + if (!ret) + { + err = GetLastError(); + todo_wine ok( err == ERROR_NO_MORE_ITEMS, "%lu != %d\n", err, ERROR_NO_MORE_ITEMS ); + break; + } + CloseHandle( radio ); + } + todo_wine ok( BluetoothFindRadioClose( find ), "BluetoothFindRadioClose failed: %lu\n", GetLastError() ); +} + START_TEST( radio ) { test_BluetoothFindFirstRadio(); + test_BluetoothFindNextRadio(); }
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/main.c | 67 +++++++++++++++++++------------- dlls/bluetoothapis/tests/radio.c | 8 ++-- 2 files changed, 45 insertions(+), 30 deletions(-)
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index c32a6fb5a0d..c63d584e9a6 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -57,10 +57,7 @@ HBLUETOOTH_DEVICE_FIND WINAPI BluetoothFindFirstDevice(BLUETOOTH_DEVICE_SEARCH_P */ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS *params, HANDLE *radio) { - char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)]; - SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail; struct bluetooth_find_radio_handle *find; - SP_DEVICE_INTERFACE_DATA iface_data; HANDLE device_ret; BOOL found;
@@ -93,25 +90,7 @@ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS return NULL; }
- iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer; - iface_detail->cbSize = sizeof(*iface_detail); - iface_data.cbSize = sizeof(iface_data); - found = FALSE; - while (SetupDiEnumDeviceInterfaces(find->devinfo, NULL, &GUID_BTHPORT_DEVICE_INTERFACE, find->idx++, - &iface_data)) - { - - if (!SetupDiGetDeviceInterfaceDetailW(find->devinfo, &iface_data, iface_detail, sizeof(buffer), NULL, - NULL)) - continue; - device_ret = CreateFileW(iface_detail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, - NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); - if (device_ret != INVALID_HANDLE_VALUE) - { - found = TRUE; - break; - } - } + found = BluetoothFindNextRadio(find, &device_ret);
if (!found) { @@ -151,11 +130,47 @@ BOOL WINAPI BluetoothFindDeviceClose(HBLUETOOTH_DEVICE_FIND find) /********************************************************************* * BluetoothFindNextRadio */ -BOOL WINAPI BluetoothFindNextRadio(HBLUETOOTH_RADIO_FIND find, HANDLE *radio) +BOOL WINAPI BluetoothFindNextRadio(HBLUETOOTH_RADIO_FIND find_handle, HANDLE *radio) { - FIXME("(%p, %p): stub!\n", find, radio); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)]; + struct bluetooth_find_radio_handle *find = find_handle; + SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail; + SP_DEVICE_INTERFACE_DATA iface_data; + HANDLE device_ret; + BOOL found; + + TRACE("(%p, %p)\n", find_handle, radio); + + if (!find_handle) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer; + iface_detail->cbSize = sizeof(*iface_detail); + iface_data.cbSize = sizeof(iface_data); + found = FALSE; + while (SetupDiEnumDeviceInterfaces(find->devinfo, NULL, &GUID_BTHPORT_DEVICE_INTERFACE, find->idx++, + &iface_data)) + { + + if (!SetupDiGetDeviceInterfaceDetailW(find->devinfo, &iface_data, iface_detail, sizeof(buffer), NULL, + NULL)) + continue; + device_ret = CreateFileW(iface_detail->DevicePath, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED | FILE_FLAG_NO_BUFFERING, NULL); + if (device_ret != INVALID_HANDLE_VALUE) + { + found = TRUE; + break; + } + } + + if (found) + *radio = device_ret; + + return found; }
/********************************************************************* diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index a394c0f7948..0eefecb053e 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -85,10 +85,10 @@ void test_BluetoothFindNextRadio( void ) radio = dummy; SetLastError( 0xdeadbeef ); ret = BluetoothFindNextRadio( NULL, &radio ); - todo_wine ok( !ret, "Expected BluetoothFindNextRadio to return FALSE\n" ); + ok( !ret, "Expected BluetoothFindNextRadio to return FALSE\n" ); err = GetLastError(); - todo_wine ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); - todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy ); + ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); + ok( radio == dummy, "%p != %p\n", radio, dummy );
for(;;) { @@ -97,7 +97,7 @@ void test_BluetoothFindNextRadio( void ) if (!ret) { err = GetLastError(); - todo_wine ok( err == ERROR_NO_MORE_ITEMS, "%lu != %d\n", err, ERROR_NO_MORE_ITEMS ); + ok( err == ERROR_NO_MORE_ITEMS, "%lu != %d\n", err, ERROR_NO_MORE_ITEMS ); break; } CloseHandle( radio );
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/tests/radio.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index 0eefecb053e..9d4dc8c26d2 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -105,8 +105,19 @@ void test_BluetoothFindNextRadio( void ) todo_wine ok( BluetoothFindRadioClose( find ), "BluetoothFindRadioClose failed: %lu\n", GetLastError() ); }
+void test_BluetoothFindRadioClose( void ) +{ + DWORD err; + + SetLastError( 0xdeadbeef ); + ok( !BluetoothFindRadioClose( NULL ), "Expected BluetoothFindRadioClose to return FALSE\n" ); + err = GetLastError(); + todo_wine ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); +} + START_TEST( radio ) { test_BluetoothFindFirstRadio(); test_BluetoothFindNextRadio(); + test_BluetoothFindRadioClose(); }
From: Vibhav Pant vibhavp@gmail.com
--- dlls/bluetoothapis/main.c | 22 ++++++++++++++++------ dlls/bluetoothapis/tests/radio.c | 6 +++--- 2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/dlls/bluetoothapis/main.c b/dlls/bluetoothapis/main.c index c63d584e9a6..c9999ae92a8 100644 --- a/dlls/bluetoothapis/main.c +++ b/dlls/bluetoothapis/main.c @@ -96,8 +96,7 @@ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS { DWORD err; err = GetLastError(); - SetupDiDestroyDeviceInfoList(find->devinfo); - free(find); + BluetoothFindRadioClose(find); find = NULL; SetLastError(err); } @@ -110,11 +109,22 @@ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS /********************************************************************* * BluetoothFindRadioClose */ -BOOL WINAPI BluetoothFindRadioClose(HBLUETOOTH_RADIO_FIND find) +BOOL WINAPI BluetoothFindRadioClose(HBLUETOOTH_RADIO_FIND find_handle) { - FIXME("(%p): stub!\n", find); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; + struct bluetooth_find_radio_handle *find = find_handle; + + TRACE("(%p)\n", find_handle); + + if (!find_handle) + { + SetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + SetupDiDestroyDeviceInfoList(find->devinfo); + free(find); + SetLastError(ERROR_SUCCESS); + return TRUE; }
/********************************************************************* diff --git a/dlls/bluetoothapis/tests/radio.c b/dlls/bluetoothapis/tests/radio.c index 9d4dc8c26d2..ad8a0616fd9 100644 --- a/dlls/bluetoothapis/tests/radio.c +++ b/dlls/bluetoothapis/tests/radio.c @@ -61,7 +61,7 @@ void test_BluetoothFindFirstRadio( void ) if (find) { CloseHandle( radio ); - todo_wine ok( BluetoothFindRadioClose( find ), "BluetoothFindRadioClose failed: %lu\n", GetLastError() ); + ok( BluetoothFindRadioClose( find ), "BluetoothFindRadioClose failed: %lu\n", GetLastError() ); } }
@@ -102,7 +102,7 @@ void test_BluetoothFindNextRadio( void ) } CloseHandle( radio ); } - todo_wine ok( BluetoothFindRadioClose( find ), "BluetoothFindRadioClose failed: %lu\n", GetLastError() ); + ok( BluetoothFindRadioClose( find ), "BluetoothFindRadioClose failed: %lu\n", GetLastError() ); }
void test_BluetoothFindRadioClose( void ) @@ -112,7 +112,7 @@ void test_BluetoothFindRadioClose( void ) SetLastError( 0xdeadbeef ); ok( !BluetoothFindRadioClose( NULL ), "Expected BluetoothFindRadioClose to return FALSE\n" ); err = GetLastError(); - todo_wine ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); + ok( err == ERROR_INVALID_HANDLE, "%lu != %d\n", err, ERROR_INVALID_HANDLE ); }
START_TEST( radio )
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=150082
Your paranoid android.
=== debian11b (64 bit WoW report) ===
Report validation errors: mshtml:style has no test summary line (early exit of the main process?) mshtml:style has unaccounted for todo messages mshtml:style returned a non-zero exit code despite reporting no failures
Rémi Bernon (@rbernon) commented about dlls/bluetoothapis/tests/sdp.c:
}
- case SDP_TYPE_UUID:
+#undef XX +#define XX(st) case SDP_ST_UUID ##st: return (st)/8
switch (st)
{
XX( 16 );
XX( 32 );
default: XX( 128 );
}
+#undef XX
- default:
return sizeof( BYTE * ) + sizeof( ULONG );
- }
+}
We usually use X as a temporary macro, I don't see why XX is better if not necessary. Also in this case with only a couple of cases and the need to redefine it, it doesn't seem very helpful to have a macro in the first place. The default cases for UINT/INT/UUID also looks wrong. What about:
```suggestion:-33+0 static SIZE_T sdp_type_size( SDP_TYPE type, SDP_SPECIFICTYPE st ) { switch (type) { case SDP_TYPE_NIL: return 0; case SDP_TYPE_UINT: case SDP_TYPE_INT: case SDP_TYPE_UUID: switch (st) { case SDP_ST_UINT8: case SDP_ST_INT8: return 1; case SDP_ST_UINT16: case SDP_ST_INT16: case SDP_ST_UUID16: return 2; case SDP_ST_UINT32: case SDP_ST_INT32: /* case SDP_ST_UUID32: */ return 4; case SDP_ST_UINT64: case SDP_ST_INT64: return 8; case SDP_ST_UINT128: case SDP_ST_INT128: case SDP_ST_UUID128: return 16; default: FIXME( "Unexpected type %#x/%#x\n", type, st ); return 0; } case SDP_TYPE_BOOLEAN: return 1; case SDP_TYPE_STRING: case SDP_TYPE_SEQUENCE: case SDP_TYPE_ALTERNATIVE: case SDP_TYPE_URL: case SDP_TYPE_CONTAINER: return sizeof(BYTE *) + sizeof(ULONG); default: FIXME( "Unexpected type %#x\n", type ); return 0; } }
```
I would even be fine with `return 1 << ((st >> 8) & 0x7);` for the INT/UINT/UUID case as it seems to be how specific types are encoded.
Rémi Bernon (@rbernon) commented about dlls/bluetoothapis/tests/radio.c:
+#include <bthsdpdef.h> +#include <bluetoothapis.h>
+#include <wine/test.h>
+void test_BluetoothFindFirstRadio( void ) +{
- HANDLE radio, dummy = (HANDLE)0xdeadbeef;
- BLUETOOTH_FIND_RADIO_PARAMS find_params;
- HBLUETOOTH_RADIO_FIND find;
- DWORD err, exp;
- radio = dummy;
- SetLastError( 0xdeadbeef );
- find = BluetoothFindFirstRadio( NULL, &radio );
- ok ( !find, "Expected %p to be NULL\n", find );
```suggestion:-0+0 ok( !find, "Expected %p to be NULL\n", find ); ```
Rémi Bernon (@rbernon) commented about dlls/bluetoothapis/tests/radio.c:
- HBLUETOOTH_RADIO_FIND find;
- DWORD err, exp;
- radio = dummy;
- SetLastError( 0xdeadbeef );
- find = BluetoothFindFirstRadio( NULL, &radio );
- ok ( !find, "Expected %p to be NULL\n", find );
- err = GetLastError();
- todo_wine ok( err == ERROR_INVALID_PARAMETER, "%lu != %d\n", err, ERROR_INVALID_PARAMETER );
- todo_wine ok( radio == dummy, "%p != %p\n", radio, dummy );
- radio = dummy;
- find_params.dwSize = 0;
- SetLastError( 0xdeadbeef );
- find = BluetoothFindFirstRadio( &find_params, &radio );
- ok ( !find, "Expected %p to be NULL\n", find );
```suggestion:-0+0 ok( !find, "Expected %p to be NULL\n", find ); ```
Rémi Bernon (@rbernon) commented about dlls/bluetoothapis/main.c:
*/ HBLUETOOTH_RADIO_FIND WINAPI BluetoothFindFirstRadio(BLUETOOTH_FIND_RADIO_PARAMS *params, HANDLE *radio) {
- FIXME("(%p %p): stub!\n", params, radio);
- *radio = NULL;
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- char buffer[sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W) + MAX_PATH * sizeof(WCHAR)];
- SP_DEVICE_INTERFACE_DETAIL_DATA_W *iface_detail;
- struct bluetooth_find_radio_handle *find;
- SP_DEVICE_INTERFACE_DATA iface_data;
- HANDLE device_ret;
- BOOL found;
- TRACE("(%p, %p)\n", params, radio);
You used space-in-paren style in sdp.c and in tests now, let's keep the module style uniform (ignoring how these stubs have initially been written, and you can fix the function declaration style one after another while you implement them).
Rémi Bernon (@rbernon) commented about dlls/bluetoothapis/main.c:
- TRACE("(%p, %p)\n", params, radio);
- if (!params)
- {
SetLastError(ERROR_INVALID_PARAMETER);
return NULL;
- }
- if (params->dwSize != sizeof(*params))
- {
SetLastError(ERROR_REVISION_MISMATCH);
return NULL;
- }
- find = calloc(1, sizeof(*find));
- if (!find)
We more often combine these in a single line, please adopt this pattern, unless it creates really long lines:
```suggestion:-1+0 if (!(find = calloc( 1, sizeof(*find) ))) ```
Rémi Bernon (@rbernon) commented about dlls/bluetoothapis/main.c:
if (!find)
{
SetLastError(ERROR_OUTOFMEMORY);
return NULL;
}
find->devinfo = SetupDiGetClassDevsW(&GUID_BTHPORT_DEVICE_INTERFACE, NULL, NULL,
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (find->devinfo == INVALID_HANDLE_VALUE)
{
free(find); return NULL;
}
iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer;
```suggestion:-0+0 iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer; ```
Let's initialize the variable like that in its declaration above directly.
Rémi Bernon (@rbernon) commented about dlls/bluetoothapis/main.c:
DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (find->devinfo == INVALID_HANDLE_VALUE)
{
free(find); return NULL;
}
iface_detail = (SP_DEVICE_INTERFACE_DETAIL_DATA_W *)buffer;
iface_detail->cbSize = sizeof(*iface_detail);
iface_data.cbSize = sizeof(iface_data);
found = FALSE;
while (SetupDiEnumDeviceInterfaces(find->devinfo, NULL, &GUID_BTHPORT_DEVICE_INTERFACE, find->idx++,
&iface_data))
{
Spurious empty line.
What about implementing some semi-stubs for the three function first (that would just allocate and free the find object), and implement the iteration logic in a second commit.
The former so that there's no intermediate commit where FindFirst returns something that will be leaked as Close isn't implemented yet, and the latter to avoid having to move FindFirst loop to FindNext right after having introduced it.
You also need to remove the `dlls/` prefix in commit titles.
On Sat Nov 30 16:51:37 2024 +0000, Rémi Bernon wrote:
What about implementing some semi-stubs for the three function first (that would just allocate and free the find object), and implement the iteration logic in a second commit. The former so that there's no intermediate commit where FindFirst returns something that will be leaked as Close isn't implemented yet, and the latter to avoid having to move FindFirst loop to FindNext right after having introduced it.
Hm, a stub for `BluetoothFindFirstRadio` returning a `non-NULL` find object would mean that there is at least one radio present on the system. I'll set the `radio` handle to `INVALID_HANDLE_VALUE`, and add another test for `FindRadio` to test that isn't equal to `INVALID_HANDLE_VALUE`.
On Sat Nov 30 16:51:37 2024 +0000, Vibhav Pant wrote:
Hm, a stub for `BluetoothFindFirstRadio` returning a `non-NULL` find object would mean that there is at least one radio present on the system. I'll set the `radio` handle to `INVALID_HANDLE_VALUE`, and add another test for `FindRadio` to test that isn't equal to `INVALID_HANDLE_VALUE`.
Or just implement the three functions are once, we only *prefer* implementing things one by one, it's not a strict rule and in such cases it's maybe not ideal.
On Sat Nov 30 16:58:34 2024 +0000, Rémi Bernon wrote:
Or just implement the three functions are once, we only *prefer* implementing things one by one, it's not a strict rule and in such cases it's maybe not ideal.
Sure. I'll reorder this then to be the three test commits first, and then one commit for implementing the three methods.