From: Andrei Emeltchenko <[email protected]>
test_dummy is a better name for dummy function test.
---
android/android-tester.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index a36c10a..7ecc80d 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -672,7 +672,7 @@ static void test_disable(const void *test_data)
data->if_bluetooth->disable();
}
-static void controller_setup(const void *test_data)
+static void test_dummy(const void *test_data)
{
tester_test_passed();
}
@@ -696,7 +696,7 @@ int main(int argc, char *argv[])
tester_init(&argc, &argv);
- test_bredrle("Test Init", NULL, setup_base, controller_setup, teardown);
+ test_bredrle("Test Init", NULL, setup_base, test_dummy, teardown);
test_bredrle("Test Enable - Success", &bluetooth_enable_success_test,
setup_base, test_enable, teardown);
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test invalid socket type during listen()
---
android/android-tester.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 15fd29e..e2554a3 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -690,6 +690,15 @@ static void test_dummy(const void *test_data)
/* Test Socket HAL */
+static const struct generic_data btsock_inv_param_socktype = {
+ .sock_type = 0,
+ .channel = 1,
+ .service_uuid = NULL,
+ .service_name = "Test service",
+ .flags = 0,
+ .expected_status = BT_STATUS_PARM_INVALID,
+};
+
static void setup_socket_interface(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -706,6 +715,28 @@ static void setup_socket_interface(const void *test_data)
tester_setup_complete();
}
+static void test_generic_listen(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ bt_status_t status;
+ int sock_fd = -1;
+
+ status = data->if_sock->listen(test->sock_type,
+ test->service_name, test->service_uuid,
+ test->channel, &sock_fd, test->flags);
+ if (status != test->expected_status) {
+ tester_test_failed();
+ goto clean;
+ }
+
+ tester_test_passed();
+
+clean:
+ if (sock_fd >= 0)
+ close(sock_fd);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -739,5 +770,9 @@ int main(int argc, char *argv[])
test_bredrle("Test Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
+ test_bredrle("Test Socket Listen - Invalid sock type",
+ &btsock_inv_param_socktype, setup_socket_interface,
+ test_generic_listen, teardown);
+
return tester_run();
}
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Socket data will be used in generic Socket HAL tests
---
android/android-tester.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 185f57b..15fd29e 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -61,6 +61,14 @@ enum hal_bluetooth_callbacks_id {
};
struct generic_data {
+ /* Socket data */
+ btsock_type_t sock_type;
+ const char *service_name;
+ const uint8_t *service_uuid;
+ int channel;
+ int flags;
+ bt_status_t expected_status;
+
uint8_t expected_adapter_status;
uint32_t expect_settings_set;
uint8_t expected_hal_callbacks[];
--
1.8.3.2
From: Andrei Emeltchenko <[email protected]>
Test get_socket_interface() and basic setup
---
android/android-tester.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 7ecc80d..185f57b 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -34,6 +34,7 @@
#include <hardware/hardware.h>
#include <hardware/bluetooth.h>
+#include <hardware/bt_sock.h>
#define adapter_props adapter_prop_bdaddr, adapter_prop_bdname, \
adapter_prop_uuids, adapter_prop_cod, \
@@ -76,7 +77,9 @@ struct test_data {
enum hciemu_type hciemu_type;
const struct generic_data *test_data;
pid_t bluetoothd_pid;
+
const bt_interface_t *if_bluetooth;
+ const btsock_interface_t *if_sock;
bool mgmt_settings_set;
bool hal_cb_called;
@@ -677,6 +680,24 @@ static void test_dummy(const void *test_data)
tester_test_passed();
}
+/* Test Socket HAL */
+
+static void setup_socket_interface(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const void *sock;
+
+ setup(data);
+
+ sock = data->if_bluetooth->get_profile_interface(BT_PROFILE_SOCKETS_ID);
+ if (!sock)
+ tester_setup_failed();
+
+ data->if_sock = sock;
+
+ tester_setup_complete();
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -707,5 +728,8 @@ int main(int argc, char *argv[])
test_bredrle("Test Disable - Success", &bluetooth_disable_success_test,
setup_enabled_adapter, test_disable, teardown);
+ test_bredrle("Test Socket Init", NULL, setup_socket_interface,
+ test_dummy, teardown);
+
return tester_run();
}
--
1.8.3.2