summaryrefslogtreecommitdiff
path: root/system/test
diff options
context:
space:
mode:
author Henri Chataing <henrichataing@google.com> 2025-03-05 19:12:42 +0000
committer Henri Chataing <henrichataing@google.com> 2025-03-13 15:07:42 -0700
commite1ce1f2459f9afb2f7c1ec4f269b28f7f17e3976 (patch)
tree51f0c00f404e2270c31df1860293570092137b50 /system/test
parente5cfe1918bde18899715b19eed07282494268066 (diff)
system/btcore: Remove unused sources and headers
NB: the module fuzzer is not parameterized, and as such has no value Bug: 331817295 Test: m com.android.bt Flag: EXEMPT, dead code removal Change-Id: I364c8d8b7c6e3a633b0193e14021fefd4bd6516f
Diffstat (limited to 'system/test')
-rw-r--r--system/test/suite/adapter/adapter_unittest.cc51
-rw-r--r--system/test/suite/adapter/bluetooth_test.cc28
2 files changed, 77 insertions, 2 deletions
diff --git a/system/test/suite/adapter/adapter_unittest.cc b/system/test/suite/adapter/adapter_unittest.cc
index 8e2769ea10..e295cb473d 100644
--- a/system/test/suite/adapter/adapter_unittest.cc
+++ b/system/test/suite/adapter/adapter_unittest.cc
@@ -16,8 +16,11 @@
*
******************************************************************************/
+#include <bluetooth/log.h>
+
#include "adapter/bluetooth_test.h"
-#include "btcore/include/property.h"
+#include "osi/include/allocator.h"
+#include "osi/include/compat.h"
#include "types/bt_transport.h"
#include "types/raw_address.h"
@@ -58,6 +61,52 @@ TEST_F(BluetoothTest, AdapterRepeatedEnableDisable) {
}
}
+static bt_property_t* property_new_name(const char* name) {
+ bluetooth::log::assert_that(name != NULL, "assert failed: name != NULL");
+ bt_property_t* property = static_cast<bt_property_t*>(osi_calloc(sizeof(bt_property_t)));
+
+ property->val = osi_calloc(sizeof(bt_bdname_t) + 1);
+ osi_strlcpy((char*)property->val, name, sizeof(bt_bdname_t));
+
+ property->type = BT_PROPERTY_BDNAME;
+ property->len = sizeof(bt_bdname_t);
+
+ return property;
+}
+
+static void property_free(bt_property_t* property) {
+ if (property == NULL) {
+ return;
+ }
+
+ osi_free(property->val);
+ osi_free(property);
+}
+
+static const bt_bdname_t* property_as_name(const bt_property_t* property) {
+ bluetooth::log::assert_that(property->type == BT_PROPERTY_BDNAME,
+ "assert failed: property_is_name(property)");
+ return (const bt_bdname_t*)property->val;
+}
+
+static bool property_equals(const bt_property_t* p1, const bt_property_t* p2) {
+ if (!p1 || !p2 || p1->type != p2->type) {
+ return false;
+ }
+
+ if (p1->type == BT_PROPERTY_BDNAME && p1->len != p2->len) {
+ const bt_property_t *shorter = p1, *longer = p2;
+ if (p1->len > p2->len) {
+ shorter = p2;
+ longer = p1;
+ }
+ return strlen((const char*)longer->val) == (size_t)shorter->len &&
+ !memcmp(longer->val, shorter->val, shorter->len);
+ }
+
+ return p1->len == p2->len && !memcmp(p1->val, p2->val, p1->len);
+}
+
TEST_F(BluetoothTest, AdapterSetGetName) {
bt_property_t* new_name = property_new_name("BluetoothTestName1");
diff --git a/system/test/suite/adapter/bluetooth_test.cc b/system/test/suite/adapter/bluetooth_test.cc
index 4855b7a72d..490675a9f6 100644
--- a/system/test/suite/adapter/bluetooth_test.cc
+++ b/system/test/suite/adapter/bluetooth_test.cc
@@ -19,10 +19,11 @@
#include "adapter/bluetooth_test.h"
#include <binder/ProcessState.h>
+#include <bluetooth/log.h>
#include <mutex>
-#include "btcore/include/property.h"
+#include "osi/include/allocator.h"
#include "types/raw_address.h"
extern bt_interface_t bluetoothInterface;
@@ -35,6 +36,31 @@ namespace bttest {
static BluetoothTest* instance = nullptr;
+static void property_free_array(bt_property_t* properties, size_t count) {
+ if (properties == NULL) {
+ return;
+ }
+
+ for (size_t i = 0; i < count; ++i) {
+ osi_free(properties[i].val);
+ }
+
+ osi_free(properties);
+}
+
+static bt_property_t* property_copy_array(const bt_property_t* properties, size_t count) {
+ bluetooth::log::assert_that(properties != NULL, "assert failed: properties != NULL");
+ bt_property_t* clone = static_cast<bt_property_t*>(osi_calloc(sizeof(bt_property_t) * count));
+
+ memcpy(&clone[0], &properties[0], sizeof(bt_property_t) * count);
+ for (size_t i = 0; i < count; ++i) {
+ clone[i].val = osi_calloc(clone[i].len);
+ memcpy(clone[i].val, properties[i].val, clone[i].len);
+ }
+
+ return clone;
+}
+
void AdapterStateChangedCallback(bt_state_t new_state) {
instance->state_ = new_state;
semaphore_post(instance->adapter_state_changed_callback_sem_);