Ravi kumar Veeramally (8):
android/tester: Fix memory leak
android/tester-ng: Add PAN init test case
android/tester-ng: Add PAN Connect test case
android/tester-ng: Add PAN Disconnect test case
anrdroid/tester-ng: Add PAN Get Local Role test case
android/tester-ng: Add PAN Enable PANU test case
android/tester-ng: Add PAN Enable NAP test case
android/tester-ng: Add PAN Enable None test case
android/Makefile.am | 1 +
android/tester-main.c | 83 +++++++++++++++++++
android/tester-main.h | 8 ++
android/tester-pan.c | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 311 insertions(+)
create mode 100644 android/tester-pan.c
--
1.9.1
Hi Ravi,
On Tuesday 29 of July 2014 15:01:24 Ravi kumar Veeramally wrote:
> Ravi kumar Veeramally (8):
> android/tester: Fix memory leak
> android/tester-ng: Add PAN init test case
> android/tester-ng: Add PAN Connect test case
> android/tester-ng: Add PAN Disconnect test case
> anrdroid/tester-ng: Add PAN Get Local Role test case
> android/tester-ng: Add PAN Enable PANU test case
> android/tester-ng: Add PAN Enable NAP test case
> android/tester-ng: Add PAN Enable None test case
>
> android/Makefile.am | 1 +
> android/tester-main.c | 83 +++++++++++++++++++
> android/tester-main.h | 8 ++
> android/tester-pan.c | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 311 insertions(+)
> create mode 100644 android/tester-pan.c
>
Patch 1/8 is now applied. Other patches need rebase. Also since now old tester
is removed, lets again prefix tester patches with 'android/tester'.
--
Best regards,
Szymon Janc
Hi Ravi,
On 07/29/2014 02:01 PM, Ravi kumar Veeramally wrote:
> ---
> android/tester-pan.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/android/tester-pan.c b/android/tester-pan.c
> index 7b013cc..1acc460 100644
> --- a/android/tester-pan.c
> +++ b/android/tester-pan.c
> @@ -121,6 +121,16 @@ static void pan_enable_panu_action(void)
> schedule_action_verification(step);
> }
>
> +static void pan_enable_nap_action(void)
> +{
> + struct test_data *data = tester_get_data();
> + struct step *step = g_new0(struct step, 1);
> +
> + step->action_status = data->if_pan->enable(BTPAN_ROLE_PANNAP);
> +
> + schedule_action_verification(step);
> +}
> +
> static struct test_case test_cases[] = {
> TEST_CASE_BREDRLE("PAN Init",
> ACTION_SUCCESS(dummy_action, NULL),
> @@ -172,6 +182,9 @@ static struct test_case test_cases[] = {
> TEST_CASE_BREDRLE("PAN Enable PANU - Success",
> ACTION(BT_STATUS_UNSUPPORTED, pan_enable_panu_action, NULL),
> ),
> + TEST_CASE_BREDRLE("PAN Enable NAP - Success",
> + ACTION_SUCCESS(pan_enable_nap_action, NULL),
> + ),
Shouldn't btpan_control_state_callback be verified after the enable?
Snipped from hardware/bt_pan.h:
"The result state of enabl will be returned by
btpan_control_state_callback."
Same applies to the previous case (enable PANU).
> };
>
> struct queue *get_pan_tests(void)
>
Regards,
Jakub
Hi Ravi,
Please correct commit message, there is a typo "anrdroid".
Best regards,
Grzegorz
On 29 July 2014 14:01, Ravi kumar Veeramally
<[email protected]> wrote:
> ---
> android/tester-pan.c | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/android/tester-pan.c b/android/tester-pan.c
> index 5048a43..1db4a85 100644
> --- a/android/tester-pan.c
> +++ b/android/tester-pan.c
> @@ -92,6 +92,25 @@ static void pan_disconnect_action(void)
> schedule_action_verification(step);
> }
>
> +static void pan_get_local_role_action(void)
> +{
> + struct test_data *data = tester_get_data();
> + const uint8_t *pan_addr = hciemu_get_client_bdaddr(data->hciemu);
> + struct step *step = g_new0(struct step, 1);
> + bt_bdaddr_t bdaddr;
> + int role;
> +
> + bdaddr2android((const bdaddr_t *) pan_addr, &bdaddr);
> +
> + role = data->if_pan->get_local_role();
> + if (role == BTPAN_ROLE_PANU)
> + step->action_status = BT_STATUS_SUCCESS;
> + else
> + step->action_status = BT_STATUS_FAIL;
> +
> + schedule_action_verification(step);
> +}
> +
> static struct test_case test_cases[] = {
> TEST_CASE_BREDRLE("PAN Init",
> ACTION_SUCCESS(dummy_action, NULL),
> @@ -125,6 +144,21 @@ static struct test_case test_cases[] = {
> ACTION_SUCCESS(bluetooth_disable_action, NULL),
> CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
> ),
> + TEST_CASE_BREDRLE("PAN GetLocalRole - Success",
> + ACTION_SUCCESS(bluetooth_enable_action, NULL),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
> + ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
> + ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
> + ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
> + ACTION_SUCCESS(pan_connect_action, NULL),
> + CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
> + BTPAN_STATE_CONNECTED),
> + ACTION_SUCCESS(pan_get_local_role_action, NULL),
> + ACTION_SUCCESS(bluetooth_disable_action, NULL),
> + CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
> + BTPAN_STATE_DISCONNECTED),
> + CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
> + ),
> };
>
> struct queue *get_pan_tests(void)
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Ravi,
On 07/29/2014 02:01 PM, Ravi kumar Veeramally wrote:
> ---
> android/Makefile.am | 1 +
> android/tester-main.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
> android/tester-main.h | 8 ++++++
> android/tester-pan.c | 48 +++++++++++++++++++++++++++++++
> 4 files changed, 137 insertions(+)
> create mode 100644 android/tester-pan.c
>
> diff --git a/android/Makefile.am b/android/Makefile.am
> index 84a05a8..66cb8c1 100644
> --- a/android/Makefile.am
> +++ b/android/Makefile.am
> @@ -181,6 +181,7 @@ android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
> android/tester-bluetooth.c \
> android/tester-socket.c \
> android/tester-hidhost.c \
> + android/tester-pan.c \
> android/tester-gatt.c \
> android/tester-main.h android/tester-main.c
>
> diff --git a/android/tester-main.c b/android/tester-main.c
> index 91a79ba..5e71809 100644
> --- a/android/tester-main.c
> +++ b/android/tester-main.c
> @@ -783,6 +783,37 @@ static bthh_callbacks_t bthh_callbacks = {
> .virtual_unplug_cb = NULL
> };
>
> +static void pan_control_state_cb(btpan_control_state_t state,
> + bt_status_t error, int local_role,
> + const char *ifname)
> +{
> + struct step *step = g_new0(struct step, 1);
> +
> + step->callback = CB_PAN_CONTROL_STATE;
> + step->callback_result.state = state;
> +
> + schedule_callback_call(step);
> +}
> +
> +static void pan_connection_state_cb(btpan_connection_state_t state,
> + bt_status_t error,
> + const bt_bdaddr_t *bd_addr,
> + int local_role, int remote_role)
> +{
> + struct step *step = g_new0(struct step, 1);
> +
> + step->callback = CB_PAN_CONNECTION_STATE;
> + step->callback_result.state = state;
> +
> + schedule_callback_call(step);
> +}
It would be nice to verify more than one callback parameter.
Fortunately PAN has only 2 callbacks.
Just saying. :) I know that this also applies to some HID cases (there
is 'TODO' somewhere).
Regards,
Jakub
---
android/tester-pan.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/android/tester-pan.c b/android/tester-pan.c
index 1acc460..c3a8cea 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -131,6 +131,16 @@ static void pan_enable_nap_action(void)
schedule_action_verification(step);
}
+static void pan_enable_none_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = data->if_pan->enable(BTPAN_ROLE_NONE);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -185,6 +195,9 @@ static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Enable NAP - Success",
ACTION_SUCCESS(pan_enable_nap_action, NULL),
),
+ TEST_CASE_BREDRLE("PAN Enable NONE - Success",
+ ACTION_SUCCESS(pan_enable_none_action, NULL),
+ ),
};
struct queue *get_pan_tests(void)
--
1.9.1
---
android/tester-pan.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/android/tester-pan.c b/android/tester-pan.c
index 1db4a85..7b013cc 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -111,6 +111,16 @@ static void pan_get_local_role_action(void)
schedule_action_verification(step);
}
+static void pan_enable_panu_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = data->if_pan->enable(BTPAN_ROLE_PANU);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -159,6 +169,9 @@ static struct test_case test_cases[] = {
BTPAN_STATE_DISCONNECTED),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
),
+ TEST_CASE_BREDRLE("PAN Enable PANU - Success",
+ ACTION(BT_STATUS_UNSUPPORTED, pan_enable_panu_action, NULL),
+ ),
};
struct queue *get_pan_tests(void)
--
1.9.1
---
android/tester-pan.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/android/tester-pan.c b/android/tester-pan.c
index 7b013cc..1acc460 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -121,6 +121,16 @@ static void pan_enable_panu_action(void)
schedule_action_verification(step);
}
+static void pan_enable_nap_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = data->if_pan->enable(BTPAN_ROLE_PANNAP);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -172,6 +182,9 @@ static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Enable PANU - Success",
ACTION(BT_STATUS_UNSUPPORTED, pan_enable_panu_action, NULL),
),
+ TEST_CASE_BREDRLE("PAN Enable NAP - Success",
+ ACTION_SUCCESS(pan_enable_nap_action, NULL),
+ ),
};
struct queue *get_pan_tests(void)
--
1.9.1
---
android/tester-pan.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/android/tester-pan.c b/android/tester-pan.c
index 5048a43..1db4a85 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -92,6 +92,25 @@ static void pan_disconnect_action(void)
schedule_action_verification(step);
}
+static void pan_get_local_role_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *pan_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+ int role;
+
+ bdaddr2android((const bdaddr_t *) pan_addr, &bdaddr);
+
+ role = data->if_pan->get_local_role();
+ if (role == BTPAN_ROLE_PANU)
+ step->action_status = BT_STATUS_SUCCESS;
+ else
+ step->action_status = BT_STATUS_FAIL;
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -125,6 +144,21 @@ static struct test_case test_cases[] = {
ACTION_SUCCESS(bluetooth_disable_action, NULL),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
),
+ TEST_CASE_BREDRLE("PAN GetLocalRole - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+ ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+ ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
+ ACTION_SUCCESS(pan_connect_action, NULL),
+ CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
+ BTPAN_STATE_CONNECTED),
+ ACTION_SUCCESS(pan_get_local_role_action, NULL),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
+ BTPAN_STATE_DISCONNECTED),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
};
struct queue *get_pan_tests(void)
--
1.9.1
---
android/tester-pan.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/android/tester-pan.c b/android/tester-pan.c
index caead9c..baf1d68 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -23,10 +23,79 @@
static struct queue *list; /* List of pan test cases */
+struct emu_cid_data {
+ uint16_t nap_handle;
+ uint16_t nap_cid;
+};
+
+struct emu_cid_data cid_data;
+static uint8_t pan_conn_req_pdu[] = {0x01, 0x01, 0x02, 0x11, 0x16, 0x11, 0x15};
+static uint8_t pan_conn_rsp_pdu[] = {0x01, 0x02, 0x00, 0x00};
+
+static void pan_nap_cid_hook_cb(const void *data, uint16_t len, void *user_data)
+{
+ struct test_data *t_data = tester_get_data();
+ struct emu_cid_data *cid_data = user_data;
+ struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+
+ if (!memcmp((uint8_t *) data, pan_conn_req_pdu,
+ sizeof(pan_conn_req_pdu)))
+ bthost_send_cid(bthost, cid_data->nap_handle, cid_data->nap_cid,
+ pan_conn_rsp_pdu, sizeof(pan_conn_rsp_pdu));
+}
+
+static void pan_connect_request_cb(uint16_t handle, uint16_t cid,
+ void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+ cid_data.nap_handle = handle;
+ cid_data.nap_cid = cid;
+
+ bthost_add_cid_hook(bthost, handle, cid, pan_nap_cid_hook_cb,
+ &cid_data);
+}
+
+static struct emu_set_l2cap_data l2cap_setup_data = {
+ .psm = 15,
+ .func = pan_connect_request_cb,
+ .user_data = NULL,
+};
+
+static void pan_connect_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *pan_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) pan_addr, &bdaddr);
+
+ step->action_status = data->if_pan->connect(&bdaddr,
+ BTPAN_ROLE_PANU, BTPAN_ROLE_PANNAP);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Init",
ACTION_SUCCESS(dummy_action, NULL),
),
+ TEST_CASE_BREDRLE("PAN Connect - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+ ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+ ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
+ ACTION_SUCCESS(pan_connect_action, NULL),
+ CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
+ BTPAN_STATE_CONNECTED),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
+ BTPAN_STATE_DISCONNECTED),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
};
struct queue *get_pan_tests(void)
--
1.9.1
---
android/tester-pan.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/android/tester-pan.c b/android/tester-pan.c
index baf1d68..5048a43 100644
--- a/android/tester-pan.c
+++ b/android/tester-pan.c
@@ -78,6 +78,20 @@ static void pan_connect_action(void)
schedule_action_verification(step);
}
+static void pan_disconnect_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *pan_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) pan_addr, &bdaddr);
+
+ step->action_status = data->if_pan->disconnect(&bdaddr);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("PAN Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -96,6 +110,21 @@ static struct test_case test_cases[] = {
BTPAN_STATE_DISCONNECTED),
CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
),
+ TEST_CASE_BREDRLE("PAN Disconnect - Success",
+ ACTION_SUCCESS(bluetooth_enable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+ ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+ ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+ ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
+ ACTION_SUCCESS(pan_connect_action, NULL),
+ CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
+ BTPAN_STATE_CONNECTED),
+ ACTION_SUCCESS(pan_disconnect_action, NULL),
+ CALLBACK_STATE(CB_PAN_CONNECTION_STATE,
+ BTPAN_STATE_DISCONNECTED),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
};
struct queue *get_pan_tests(void)
--
1.9.1
---
android/Makefile.am | 1 +
android/tester-main.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
android/tester-main.h | 8 ++++++
android/tester-pan.c | 48 +++++++++++++++++++++++++++++++
4 files changed, 137 insertions(+)
create mode 100644 android/tester-pan.c
diff --git a/android/Makefile.am b/android/Makefile.am
index 84a05a8..66cb8c1 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -181,6 +181,7 @@ android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
android/tester-bluetooth.c \
android/tester-socket.c \
android/tester-hidhost.c \
+ android/tester-pan.c \
android/tester-gatt.c \
android/tester-main.h android/tester-main.c
diff --git a/android/tester-main.c b/android/tester-main.c
index 91a79ba..5e71809 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -783,6 +783,37 @@ static bthh_callbacks_t bthh_callbacks = {
.virtual_unplug_cb = NULL
};
+static void pan_control_state_cb(btpan_control_state_t state,
+ bt_status_t error, int local_role,
+ const char *ifname)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_PAN_CONTROL_STATE;
+ step->callback_result.state = state;
+
+ schedule_callback_call(step);
+}
+
+static void pan_connection_state_cb(btpan_connection_state_t state,
+ bt_status_t error,
+ const bt_bdaddr_t *bd_addr,
+ int local_role, int remote_role)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_PAN_CONNECTION_STATE;
+ step->callback_result.state = state;
+
+ schedule_callback_call(step);
+}
+
+static btpan_callbacks_t btpan_callbacks = {
+ .size = sizeof(btpan_callbacks),
+ .control_state_cb = pan_control_state_cb,
+ .connection_state_cb = pan_connection_state_cb,
+};
+
static const btgatt_client_callbacks_t btgatt_client_callbacks = {
.register_client_cb = NULL,
.scan_result_cb = NULL,
@@ -974,6 +1005,42 @@ static void setup_hidhost(const void *test_data)
tester_setup_complete();
}
+static void setup_pan(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ bt_status_t status;
+ const void *pan;
+
+ if (!setup_base(data)) {
+ tester_setup_failed();
+ return;
+ }
+
+ status = data->if_bluetooth->init(&bt_callbacks);
+ if (status != BT_STATUS_SUCCESS) {
+ data->if_bluetooth = NULL;
+ tester_setup_failed();
+ return;
+ }
+
+ pan = data->if_bluetooth->get_profile_interface(BT_PROFILE_PAN_ID);
+ if (!pan) {
+ tester_setup_failed();
+ return;
+ }
+
+ data->if_pan = pan;
+
+ status = data->if_pan->init(&btpan_callbacks);
+ if (status != BT_STATUS_SUCCESS) {
+ data->if_pan = NULL;
+ tester_setup_failed();
+ return;
+ }
+
+ tester_setup_complete();
+}
+
static void setup_gatt(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -1028,6 +1095,11 @@ static void teardown(const void *test_data)
data->if_hid = NULL;
}
+ if (data->if_pan) {
+ data->if_pan->cleanup();
+ data->if_pan = NULL;
+ }
+
if (data->if_bluetooth) {
data->if_bluetooth->cleanup();
data->if_bluetooth = NULL;
@@ -1470,6 +1542,13 @@ static void add_hidhost_tests(void *data, void *user_data)
test(tc, setup_hidhost, generic_test_function, teardown);
}
+static void add_pan_tests(void *data, void *user_data)
+{
+ struct test_case *tc = data;
+
+ test(tc, setup_pan, generic_test_function, teardown);
+}
+
static void add_gatt_tests(void *data, void *user_data)
{
struct test_case *tc = data;
@@ -1486,6 +1565,7 @@ int main(int argc, char *argv[])
queue_foreach(get_bluetooth_tests(), add_bluetooth_tests, NULL);
queue_foreach(get_socket_tests(), add_socket_tests, NULL);
queue_foreach(get_hidhost_tests(), add_hidhost_tests, NULL);
+ queue_foreach(get_pan_tests(), add_pan_tests, NULL);
queue_foreach(get_gatt_tests(), add_gatt_tests, NULL);
if (tester_run())
diff --git a/android/tester-main.h b/android/tester-main.h
index e2ecaab..dabccff 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -46,6 +46,7 @@
#include <hardware/bluetooth.h>
#include <hardware/bt_sock.h>
#include <hardware/bt_hh.h>
+#include <hardware/bt_pan.h>
#include <hardware/bt_gatt.h>
#include <hardware/bt_gatt_client.h>
#include <hardware/bt_gatt_server.h>
@@ -154,6 +155,10 @@ typedef enum {
CB_HH_GET_REPORT,
CB_HH_VIRTUAL_UNPLUG,
+ /* PAN cb */
+ CB_PAN_CONTROL_STATE,
+ CB_PAN_CONNECTION_STATE,
+
/* Gatt client */
CB_GATTC_REGISTER_CLIENT,
CB_GATTC_SCAN_RESULT,
@@ -199,6 +204,7 @@ struct test_data {
const bt_interface_t *if_bluetooth;
const btsock_interface_t *if_sock;
const bthh_interface_t *if_hid;
+ const btpan_interface_t *if_pan;
const btgatt_interface_t *if_gatt;
const void *test_data;
@@ -284,6 +290,8 @@ struct queue *get_socket_tests(void);
void remove_socket_tests(void);
struct queue *get_hidhost_tests(void);
void remove_hidhost_tests(void);
+struct queue *get_pan_tests(void);
+void remove_pan_tests(void);
struct queue *get_gatt_tests(void);
void remove_gatt_tests(void);
diff --git a/android/tester-pan.c b/android/tester-pan.c
new file mode 100644
index 0000000..caead9c
--- /dev/null
+++ b/android/tester-pan.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+
+#include "emulator/bthost.h"
+#include "tester-main.h"
+#include "android/utils.h"
+
+static struct queue *list; /* List of pan test cases */
+
+static struct test_case test_cases[] = {
+ TEST_CASE_BREDRLE("PAN Init",
+ ACTION_SUCCESS(dummy_action, NULL),
+ ),
+};
+
+struct queue *get_pan_tests(void)
+{
+ uint16_t i = 0;
+
+ list = queue_new();
+
+ for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
+ if (!queue_push_tail(list, &test_cases[i]))
+ return NULL;
+
+ return list;
+}
+
+void remove_pan_tests(void)
+{
+ queue_destroy(list, NULL);
+}
--
1.9.1
Fixes valgrind report.
==26707== HEAP SUMMARY:
==26707== in use at exit: 4,943 bytes in 41 blocks
==26707== total heap usage: 25,702 allocs, 25,661 frees, 1,379,978 bytes allocated
==26707==
==26707== 8 bytes in 2 blocks are definitely lost in loss record 6 of 39
==26707== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26707== by 0x5089610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
==26707== by 0x50A0B57: g_memdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
==26707== by 0x40E57E: create_property (tester-main.c:623)
==26707== by 0x40F49C: pin_request_cb (tester-main.c:713)
==26707== by 0x5F70E7A: notification_handler (hal-ipc.c:125)
==26707== by 0x534B181: start_thread (pthread_create.c:312)
==26707== by 0x565C30C: clone (clone.S:111)
==26707==
==26707== 12 bytes in 2 blocks are definitely lost in loss record 7 of 39
==26707== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==26707== by 0x5089610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
==26707== by 0x50A0B57: g_memdup (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4000.0)
==26707== by 0x40E57E: create_property (tester-main.c:623)
==26707== by 0x40F467: pin_request_cb (tester-main.c:709)
==26707== by 0x5F70E7A: notification_handler (hal-ipc.c:125)
==26707== by 0x534B181: start_thread (pthread_create.c:312)
==26707== by 0x565C30C: clone (clone.S:111)
==26707==
==26707== LEAK SUMMARY:
==26707== definitely lost: 20 bytes in 4 blocks
==26707== indirectly lost: 0 bytes in 0 blocks
==26707== possibly lost: 0 bytes in 0 blocks
==26707== still reachable: 4,923 bytes in 37 blocks
==26707== suppressed: 0 bytes in 0 blocks
---
android/tester-main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/android/tester-main.c b/android/tester-main.c
index abef822..91a79ba 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -716,8 +716,11 @@ static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
step->callback_result.num_properties = 3;
step->callback_result.properties = repack_properties(3, props);
+ g_free(props[0]->val);
g_free(props[0]);
+ g_free(props[1]->val);
g_free(props[1]);
+ g_free(props[2]->val);
g_free(props[2]);
schedule_callback_call(step);
--
1.9.1