This adds last set of test cases ported to newer tester framework.
Last patch removes the old 'android-tester' and renames 'android-tester-ng'
to 'android-tester'.
v2changes:
* improved/cleaned up some cases step flow
* renamed the 'android-tester-ng' to 'android-tester'
Jakub Tyszkowski (9):
android/tester-ng: Add HIDHost connect, disconnect cases
android/tester-ng: Add HIDHost virtual unplug test case
android/tester-ng: Add HIDHost get protocol mode case
android/tester-ng: Add HIDHost set protocol mode case
android/tester-ng: Add HIDHost get report case
android/tester-ng: Add HIDHost set report case
android/tester-ng: Add HIDHost send data case
android/tester: Remove old HIDHost test cases
android/tester: Remove old android-tester
.gitignore | 1 -
android/Makefile.am | 30 +-
android/android-tester.c | 2812 ----------------------------------------------
android/tester-hidhost.c | 533 ++++++++-
android/tester-main.c | 80 +-
android/tester-main.h | 27 +
6 files changed, 637 insertions(+), 2846 deletions(-)
delete mode 100644 android/android-tester.c
--
1.9.1
Hi Jakub,
On Tuesday 29 of July 2014 09:18:23 Jakub Tyszkowski wrote:
> This adds last set of test cases ported to newer tester framework.
> Last patch removes the old 'android-tester' and renames 'android-tester-ng'
> to 'android-tester'.
>
> v2changes:
> * improved/cleaned up some cases step flow
> * renamed the 'android-tester-ng' to 'android-tester'
>
> Jakub Tyszkowski (9):
> android/tester-ng: Add HIDHost connect, disconnect cases
> android/tester-ng: Add HIDHost virtual unplug test case
> android/tester-ng: Add HIDHost get protocol mode case
> android/tester-ng: Add HIDHost set protocol mode case
> android/tester-ng: Add HIDHost get report case
> android/tester-ng: Add HIDHost set report case
> android/tester-ng: Add HIDHost send data case
> android/tester: Remove old HIDHost test cases
> android/tester: Remove old android-tester
>
> .gitignore | 1 -
> android/Makefile.am | 30 +-
> android/android-tester.c | 2812 ----------------------------------------------
> android/tester-hidhost.c | 533 ++++++++-
> android/tester-main.c | 80 +-
> android/tester-main.h | 27 +
> 6 files changed, 637 insertions(+), 2846 deletions(-)
> delete mode 100644 android/android-tester.c
>
> --
> 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
All patches applied. Thanks a lot.
--
Best regards,
Szymon Janc
All test cases has already been ported to newer framework.
Old tester was removed and new one now uses its old name.
---
.gitignore | 1 -
android/Makefile.am | 30 +-
android/android-tester.c | 1931 ----------------------------------------------
3 files changed, 3 insertions(+), 1959 deletions(-)
delete mode 100644 android/android-tester.c
diff --git a/.gitignore b/.gitignore
index 13e0bcb..1a7b417 100644
--- a/.gitignore
+++ b/.gitignore
@@ -128,7 +128,6 @@ android/bluetoothd
android/mcaptest
android/haltest
android/android-tester
-android/android-tester-ng
android/ipc-tester
android/bluetoothd-snoop
android/test-ipc
diff --git a/android/Makefile.am b/android/Makefile.am
index 84a05a8..a3067bb 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -154,42 +154,18 @@ android_android_tester_SOURCES = emulator/btdev.h emulator/btdev.c \
src/shared/timeout.h src/shared/timeout-glib.c \
monitor/rfcomm.h \
android/hardware/hardware.c \
- android/android-tester.c
-
-android_android_tester_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
- -DPLUGINDIR=\""$(android_plugindir)"\"
-
-android_android_tester_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-
-android_android_tester_LDFLAGS = -pthread -ldl
-
-noinst_PROGRAMS += android/android-tester-ng
-
-android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
- emulator/bthost.h emulator/bthost.c \
- emulator/smp.c \
- src/shared/crypto.h src/shared/crypto.c \
- src/shared/io.h src/shared/io-glib.c \
- src/shared/queue.h src/shared/queue.c \
- src/shared/util.h src/shared/util.c \
- src/shared/mgmt.h src/shared/mgmt.c \
- src/shared/hciemu.h src/shared/hciemu.c \
- src/shared/tester.h src/shared/tester.c \
- src/shared/timeout.h src/shared/timeout-glib.c \
- monitor/rfcomm.h \
- android/hardware/hardware.c \
android/tester-bluetooth.c \
android/tester-socket.c \
android/tester-hidhost.c \
android/tester-gatt.c \
android/tester-main.h android/tester-main.c
-android_android_tester_ng_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
+android_android_tester_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
-DPLUGINDIR=\""$(android_plugindir)"\"
-android_android_tester_ng_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+android_android_tester_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
-android_android_tester_ng_LDFLAGS = -pthread -ldl
+android_android_tester_LDFLAGS = -pthread -ldl
noinst_PROGRAMS += android/ipc-tester
diff --git a/android/android-tester.c b/android/android-tester.c
deleted file mode 100644
index 1167e98..0000000
--- a/android/android-tester.c
+++ /dev/null
@@ -1,1931 +0,0 @@
-/*
- * Copyright (C) 2013 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 <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-
-#include <glib.h>
-#include <sys/socket.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <sys/un.h>
-#include <sys/signalfd.h>
-#include <libgen.h>
-
-#include "lib/bluetooth.h"
-#include "lib/mgmt.h"
-
-#include "src/shared/util.h"
-#include "src/shared/tester.h"
-#include "src/shared/mgmt.h"
-#include "src/shared/hciemu.h"
-
-#include "emulator/bthost.h"
-#include "monitor/bt.h"
-
-#include <hardware/hardware.h>
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sock.h>
-#include <hardware/bt_hh.h>
-
-#include "utils.h"
-
-struct priority_property {
- bt_property_t prop;
- int prio;
-};
-
-struct generic_data {
- int expected_adapter_status;
- uint32_t expect_settings_set;
- int expected_cb_count;
- bt_property_t set_property;
- bt_callbacks_t expected_hal_cb;
- struct priority_property *expected_properties;
- uint8_t expected_properties_num;
-};
-
-struct socket_data {
- btsock_type_t sock_type;
- const char *service_name;
- const uint8_t *service_uuid;
- const bt_bdaddr_t *bdaddr;
- int channel;
- int flags;
- bt_status_t expected_status;
- bool test_channel;
-};
-
-struct hidhost_generic_data {
- bthh_status_t expected_status;
- int expected_conn_state;
- int expected_cb_count;
- bthh_protocol_mode_t expected_protocol_mode;
- int expected_report;
- bthh_callbacks_t expected_hal_cb;
- int expected_report_size;
-};
-
-#define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
-#define EMULATOR_SIGNAL "emulator_started"
-
-#define BT_STATUS_NOT_EXPECTED -1
-
-struct test_data {
- struct mgmt *mgmt;
- uint16_t mgmt_index;
- unsigned int mgmt_settings_id;
- struct hciemu *hciemu;
- enum hciemu_type hciemu_type;
- const void *test_data;
- pid_t bluetoothd_pid;
- guint signalfd;
-
- struct hw_device_t *device;
- const bt_interface_t *if_bluetooth;
- const btsock_interface_t *if_sock;
- const bthh_interface_t *if_hid;
-
- int conditions_left;
-
- /* Set to true if test conditions should be verified */
- bool test_checks_valid;
-
- bool test_result_set;
-
- int cb_count;
- GSList *expected_properties_list;
-
- /* hidhost */
- uint16_t sdp_handle;
- uint16_t sdp_cid;
- uint16_t ctrl_handle;
- uint16_t ctrl_cid;
- uint16_t intr_handle;
- uint16_t intr_cid;
-};
-
-struct bt_cb_data {
- bt_state_t state;
- bt_status_t status;
-
- bt_bdaddr_t bdaddr;
- bt_bdname_t bdname;
- uint32_t cod;
-
- bt_ssp_variant_t ssp_variant;
- uint32_t passkey;
-
- int num;
- bt_property_t *props;
-};
-
-struct hh_cb_data {
- bt_bdaddr_t bdaddr;
-
- bthh_status_t status;
- bthh_hid_info_t hid_info;
- bthh_protocol_mode_t mode;
- bthh_connection_state_t state;
-
- uint8_t *report;
- int size;
-};
-
-static char exec_dir[PATH_MAX];
-
-static gint scheduled_cbacks_num = 0;
-
-static void test_update_state(void)
-{
- struct test_data *data = tester_get_data();
-
- if (data->conditions_left == 0 && !data->test_result_set) {
- data->test_result_set = true;
- tester_test_passed();
- }
-}
-
-static void check_cb_count(void)
-{
- struct test_data *data = tester_get_data();
-
- if (!data->test_checks_valid)
- return;
-
- if (data->cb_count == 0) {
- data->conditions_left--;
- test_update_state();
- }
-}
-
-static void check_expected_status(uint8_t status)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test_data = data->test_data;
-
- if (test_data->expected_adapter_status == status) {
- data->conditions_left--;
- test_update_state();
- } else
- tester_test_failed();
-}
-
-static int locate_property(gconstpointer expected_data,
- gconstpointer received_prop)
-{
- bt_property_t rec_prop = *((bt_property_t *)received_prop);
- bt_property_t exp_prop =
- ((struct priority_property *)expected_data)->prop;
-
- if (exp_prop.type && (exp_prop.type != rec_prop.type))
- return 1;
- if (exp_prop.len && (exp_prop.len != rec_prop.len))
- return 1;
- if (exp_prop.val && memcmp(exp_prop.val, rec_prop.val, exp_prop.len))
- return 1;
-
- return 0;
-}
-
-static int compare_priorities(gconstpointer prop_list, gconstpointer priority)
-{
- int prio = GPOINTER_TO_INT(priority);
- int comp_prio = ((struct priority_property *)prop_list)->prio;
-
- if (prio > comp_prio)
- return 0;
-
- return 1;
-}
-
-static bool check_prop_priority(int rec_prop_prio)
-{
- struct test_data *data = tester_get_data();
- GSList *l = data->expected_properties_list;
-
- if (!rec_prop_prio || !g_slist_length(l))
- return true;
-
- if (g_slist_find_custom(l, GINT_TO_POINTER(rec_prop_prio),
- &compare_priorities))
- return false;
-
- return true;
-}
-
-static void check_expected_property(bt_property_t received_prop)
-{
- struct test_data *data = tester_get_data();
- int rec_prio;
- GSList *l = data->expected_properties_list;
- GSList *found_exp_prop;
-
- if (!g_slist_length(l))
- return;
-
- found_exp_prop = g_slist_find_custom(l, &received_prop,
- &locate_property);
-
- if (found_exp_prop) {
- rec_prio = ((struct priority_property *)
- (found_exp_prop->data))->prio;
- if (check_prop_priority(rec_prio))
- l = g_slist_remove(l, found_exp_prop->data);
- }
-
- data->expected_properties_list = l;
-
- if (g_slist_length(l))
- return;
-
- data->conditions_left--;
- test_update_state();
-}
-
-static bool check_test_property(bt_property_t received_prop,
- bt_property_t expected_prop)
-{
- if (expected_prop.type && (expected_prop.type != received_prop.type))
- return false;
- if (expected_prop.len && (expected_prop.len != received_prop.len))
- return false;
- if (expected_prop.val && memcmp(expected_prop.val, received_prop.val,
- expected_prop.len))
- return false;
-
- return true;
-}
-
-static void emu_connectable_complete(uint16_t opcode, uint8_t status,
- const void *param, uint8_t len,
- void *user_data)
-{
- switch (opcode) {
- case BT_HCI_CMD_WRITE_SCAN_ENABLE:
- case BT_HCI_CMD_LE_SET_ADV_ENABLE:
- break;
- default:
- return;
- }
-
- tester_print("Emulated remote set connectable status 0x%02x", status);
-
- if (status)
- tester_setup_failed();
- else
- tester_setup_complete();
-}
-
-static void setup_powered_emulated_remote(void)
-{
- struct test_data *data = tester_get_data();
- struct bthost *bthost;
-
- tester_print("Controller powered on");
-
- bthost = hciemu_client_get_host(data->hciemu);
- bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
-
- if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01, 0x00);
- else
- bthost_write_scan_enable(bthost, 0x03);
-}
-
-static gboolean adapter_state_changed(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (data->test_checks_valid &&
- test->expected_hal_cb.adapter_state_changed_cb) {
- test->expected_hal_cb.adapter_state_changed_cb(cb_data->state);
- goto cleanup;
- }
-
- if (!data->test_checks_valid && cb_data->state == BT_STATE_ON)
- setup_powered_emulated_remote();
-
-cleanup:
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void adapter_state_changed_cb(bt_state_t state)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->state = state;
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(adapter_state_changed, cb_data);
-}
-
-static void discovery_start_success_cb(bt_discovery_state_t state)
-{
- struct test_data *data = tester_get_data();
-
- if (state == BT_DISCOVERY_STARTED) {
- data->cb_count--;
- check_cb_count();
- }
-}
-
-static void discovery_start_done_cb(bt_discovery_state_t state)
-{
- struct test_data *data = tester_get_data();
- bt_status_t status;
-
- status = data->if_bluetooth->start_discovery();
- data->cb_count--;
-
- check_cb_count();
- check_expected_status(status);
-}
-
-static void discovery_stop_success_cb(bt_discovery_state_t state)
-{
- struct test_data *data = tester_get_data();
- bt_status_t status;
-
- if (state == BT_DISCOVERY_STARTED && data->cb_count == 2) {
- status = data->if_bluetooth->cancel_discovery();
- check_expected_status(status);
- data->cb_count--;
- return;
- }
- if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1) {
- data->cb_count--;
- check_cb_count();
- }
-}
-
-static void discovery_device_found_state_changed_cb(bt_discovery_state_t state)
-{
- struct test_data *data = tester_get_data();
-
- if (state == BT_DISCOVERY_STARTED && data->cb_count == 3) {
- data->cb_count--;
- return;
- }
- if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1) {
- data->cb_count--;
- check_cb_count();
- }
-}
-
-static void remote_discovery_state_changed_cb(bt_discovery_state_t state)
-{
- struct test_data *data = tester_get_data();
-
- if (state == BT_DISCOVERY_STARTED && data->cb_count == 3) {
- data->cb_count--;
- return;
- }
- if (state == BT_DISCOVERY_STOPPED && data->cb_count == 1) {
- data->cb_count--;
- check_cb_count();
- }
-}
-
-static void remote_setprop_disc_state_changed_cb(bt_discovery_state_t state)
-{
- struct test_data *data = tester_get_data();
-
- if (state == BT_DISCOVERY_STARTED && data->cb_count == 3) {
- data->cb_count--;
- return;
- }
- if (state == BT_DISCOVERY_STOPPED) {
- data->cb_count--;
- check_cb_count();
- }
-}
-
-static gboolean discovery_state_changed(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (test && test->expected_hal_cb.discovery_state_changed_cb)
- test->expected_hal_cb.discovery_state_changed_cb(
- cb_data->state);
-
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void discovery_state_changed_cb(bt_discovery_state_t state)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->state = state;
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(discovery_state_changed, cb_data);
-}
-
-static bt_property_t *copy_properties(int num_properties,
- bt_property_t *properties)
-{
- int i;
- bt_property_t *props = g_new0(bt_property_t, num_properties);
-
- for (i = 0; i < num_properties; i++) {
- props[i].type = properties[i].type;
- props[i].len = properties[i].len;
- props[i].val = g_memdup(properties[i].val, properties[i].len);
- }
-
- return props;
-}
-
-static void free_properties(int num_properties, bt_property_t *properties)
-{
- int i;
-
- for (i = 0; i < num_properties; i++)
- g_free(properties[i].val);
-
- g_free(properties);
-}
-
-static void discovery_device_found_cb(int num_properties,
- bt_property_t *properties)
-{
- struct test_data *data = tester_get_data();
- uint8_t *remote_bdaddr =
- (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- uint32_t emu_remote_type = BT_DEVICE_DEVTYPE_BREDR;
- int32_t emu_remote_rssi = -60;
- bt_bdaddr_t emu_remote_bdaddr;
- int i;
- bt_property_t expected_prop;
- bt_property_t received_prop;
-
- data->cb_count--;
- check_cb_count();
-
- if (num_properties < 1) {
- tester_test_failed();
- return;
- }
-
- bdaddr2android((const bdaddr_t *) remote_bdaddr, &emu_remote_bdaddr);
-
- for (i = 0; i < num_properties; i++) {
- received_prop = properties[i];
-
- switch (properties[i].type) {
- case BT_PROPERTY_BDADDR:
- expected_prop.type = BT_PROPERTY_BDADDR;
- expected_prop.len = sizeof(emu_remote_bdaddr);
- expected_prop.val = &emu_remote_bdaddr;
- break;
-
- case BT_PROPERTY_TYPE_OF_DEVICE:
- expected_prop.type = BT_PROPERTY_TYPE_OF_DEVICE;
- expected_prop.len = sizeof(emu_remote_type);
- expected_prop.val = &emu_remote_type;
- break;
-
- case BT_PROPERTY_REMOTE_RSSI:
- expected_prop.type = BT_PROPERTY_REMOTE_RSSI;
- expected_prop.len = sizeof(emu_remote_rssi);
- expected_prop.val = &emu_remote_rssi;
- break;
-
- default:
- expected_prop.type = 0;
- expected_prop.len = 0;
- expected_prop.val = NULL;
- break;
- }
-
- if (!check_test_property(received_prop, expected_prop)) {
- data->if_bluetooth->cancel_discovery();
- tester_test_failed();
- return;
- }
- }
-
- data->if_bluetooth->cancel_discovery();
-}
-
-static void remote_getprops_device_found_cb(int num_properties,
- bt_property_t *properties)
-{
- struct test_data *data = tester_get_data();
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- if (data->cb_count == 2)
- data->cb_count--;
-
- data->if_bluetooth->cancel_discovery();
- data->if_bluetooth->get_remote_device_properties(&remote_addr);
-}
-
-static void remote_get_property_device_found_cb(int num_properties,
- bt_property_t *properties)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- bt_status_t status;
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
-
- const bt_property_t prop = test->expected_properties[0].prop;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- if (data->cb_count == 2)
- data->cb_count--;
-
- data->if_bluetooth->cancel_discovery();
- status = data->if_bluetooth->get_remote_device_property(&remote_addr,
- prop.type);
- check_expected_status(status);
-}
-
-static void remote_setprop_device_found_cb(int num_properties,
- bt_property_t *properties)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- bt_status_t status;
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
-
- const bt_property_t prop = test->expected_properties[0].prop;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- if (data->cb_count == 2)
- data->cb_count--;
-
- data->if_bluetooth->cancel_discovery();
- status = data->if_bluetooth->set_remote_device_property(&remote_addr,
- &prop);
- check_expected_status(status);
-
- data->if_bluetooth->get_remote_device_property(&remote_addr, prop.type);
-}
-
-static void remote_setprop_fail_device_found_cb(int num_properties,
- bt_property_t *properties)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- bt_status_t status;
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
-
- const bt_property_t prop = test->expected_properties[0].prop;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- if (data->cb_count == 2)
- data->cb_count--;
-
- data->if_bluetooth->cancel_discovery();
- status = data->if_bluetooth->set_remote_device_property(&remote_addr,
- &prop);
- check_expected_status(status);
-}
-
-static void bond_device_found_cb(int num_properties, bt_property_t *properties)
-{
- struct test_data *data = tester_get_data();
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
- bt_status_t status;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- if (data->cb_count == 4) {
- data->cb_count--;
- status = data->if_bluetooth->create_bond(&remote_addr);
- check_expected_status(status);
- }
-}
-
-static void bond_nostatus_device_found_cb(int num_properties,
- bt_property_t *properties)
-{
- struct test_data *data = tester_get_data();
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- if (data->cb_count == 4) {
- data->cb_count--;
- data->if_bluetooth->create_bond(&remote_addr);
- }
-}
-
-static gboolean device_found(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (data->test_checks_valid && test->expected_hal_cb.device_found_cb)
- test->expected_hal_cb.device_found_cb(cb_data->num,
- cb_data->props);
-
- free_properties(cb_data->num, cb_data->props);
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void device_found_cb(int num_properties, bt_property_t *properties)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->num = num_properties;
- cb_data->props = copy_properties(num_properties, properties);
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(device_found, cb_data);
-}
-
-static gboolean adapter_properties(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (data->test_checks_valid &&
- test->expected_hal_cb.adapter_properties_cb)
- test->expected_hal_cb.adapter_properties_cb(cb_data->status,
- cb_data->num, cb_data->props);
-
- free_properties(cb_data->num, cb_data->props);
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void adapter_properties_cb(bt_status_t status, int num_properties,
- bt_property_t *properties)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->status = status;
- cb_data->num = num_properties;
- cb_data->props = copy_properties(num_properties, properties);
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(adapter_properties, cb_data);
-}
-
-static void remote_test_device_properties_cb(bt_status_t status,
- bt_bdaddr_t *bd_addr, int num_properties,
- bt_property_t *properties)
-{
- int i;
-
- for (i = 0; i < num_properties; i++)
- check_expected_property(properties[i]);
-}
-
-static gboolean remote_device_properties(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (data->test_checks_valid &&
- test->expected_hal_cb.remote_device_properties_cb)
- test->expected_hal_cb.remote_device_properties_cb(
- cb_data->status, &cb_data->bdaddr,
- cb_data->num, cb_data->props);
-
- free_properties(cb_data->num, cb_data->props);
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void remote_device_properties_cb(bt_status_t status,
- bt_bdaddr_t *bd_addr, int num_properties,
- bt_property_t *properties)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->status = status;
- cb_data->bdaddr = *bd_addr;
- cb_data->num = num_properties;
- cb_data->props = copy_properties(num_properties, properties);
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(remote_device_properties, cb_data);
-}
-
-static void bond_test_bonded_state_changed_cb(bt_status_t status,
- bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
-{
- struct test_data *data = tester_get_data();
-
- switch (state) {
- case BT_BOND_STATE_BONDING:
- data->cb_count--;
- break;
- case BT_BOND_STATE_BONDED:
- data->cb_count--;
- check_cb_count();
- break;
- default:
- tester_test_failed();
- break;
- }
-}
-
-static void bond_test_none_state_changed_cb(bt_status_t status,
- bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
-{
- struct test_data *data = tester_get_data();
-
- switch (state) {
- case BT_BOND_STATE_BONDING:
- data->cb_count--;
- break;
- case BT_BOND_STATE_NONE:
- data->cb_count--;
- check_cb_count();
- break;
- default:
- tester_test_failed();
- break;
- }
-}
-
-static void bond_remove_success_state_changed_cb(bt_status_t status,
- bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
-{
- struct test_data *data = tester_get_data();
- bt_status_t remove_status;
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- if (state == BT_BOND_STATE_BONDED) {
- data->cb_count--;
- remove_status = data->if_bluetooth->remove_bond(&remote_addr);
- check_expected_status(remove_status);
- return;
- }
-
- if (state == BT_BOND_STATE_NONE) {
- data->cb_count--;
- check_cb_count();
- }
-}
-
-static gboolean bond_state_changed(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (data->test_checks_valid &&
- test->expected_hal_cb.bond_state_changed_cb)
- test->expected_hal_cb.bond_state_changed_cb(cb_data->status,
- &cb_data->bdaddr, cb_data->state);
-
- g_free(cb_data);
- return FALSE;
-}
-
-static void bond_state_changed_cb(bt_status_t status,
- bt_bdaddr_t *remote_bd_addr, bt_bond_state_t state)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->status = status;
- cb_data->bdaddr = *remote_bd_addr;
- cb_data->state = state;
-
- g_idle_add(bond_state_changed, cb_data);
-}
-
-static void bond_create_pin_success_request_cb(bt_bdaddr_t *remote_bd_addr,
- bt_bdname_t *bd_name, uint32_t cod)
-{
- struct test_data *data = tester_get_data();
- const bt_bdaddr_t *bdaddr = remote_bd_addr;
- bt_pin_code_t pin_code = {
- .pin = { 0x30, 0x30, 0x30, 0x30 },
- };
- uint8_t pin_len = 4;
-
- data->cb_count--;
-
- data->if_bluetooth->pin_reply(bdaddr, TRUE, pin_len, &pin_code);
-}
-
-static void bond_create_pin_fail_request_cb(bt_bdaddr_t *remote_bd_addr,
- bt_bdname_t *bd_name, uint32_t cod)
-{
- struct test_data *data = tester_get_data();
- const bt_bdaddr_t *bdaddr = remote_bd_addr;
- bt_pin_code_t pin_code = {
- .pin = { 0x31, 0x31, 0x31, 0x31 },
- };
- uint8_t pin_len = 4;
-
- data->cb_count--;
-
- data->if_bluetooth->pin_reply(bdaddr, TRUE, pin_len, &pin_code);
-}
-
-static gboolean pin_request(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (data->test_checks_valid && test->expected_hal_cb.pin_request_cb)
- test->expected_hal_cb.pin_request_cb(&cb_data->bdaddr,
- &cb_data->bdname, cb_data->cod);
-
- g_free(cb_data);
- return FALSE;
-}
-
-static void pin_request_cb(bt_bdaddr_t *remote_bd_addr,
- bt_bdname_t *bd_name, uint32_t cod)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->bdaddr = *remote_bd_addr;
- cb_data->bdname = *bd_name;
- cb_data->cod = cod;
-
- g_idle_add(pin_request, cb_data);
-}
-
-static void bond_create_ssp_request_cb(const bt_bdaddr_t *remote_bd_addr,
- bt_ssp_variant_t pairing_variant,
- bool accept, uint32_t pass_key)
-{
- struct test_data *data = tester_get_data();
-
- data->if_bluetooth->ssp_reply(remote_bd_addr,
- BT_SSP_VARIANT_PASSKEY_CONFIRMATION,
- accept, pass_key);
-
- data->cb_count--;
-}
-
-static void bond_create_ssp_success_request_cb(bt_bdaddr_t *remote_bd_addr,
- bt_bdname_t *bd_name, uint32_t cod,
- bt_ssp_variant_t pairing_variant,
- uint32_t pass_key)
-{
- bool accept = true;
-
- bond_create_ssp_request_cb(remote_bd_addr, pairing_variant, accept,
- pass_key);
-}
-
-static void bond_create_ssp_fail_request_cb(bt_bdaddr_t *remote_bd_addr,
- bt_bdname_t *bd_name, uint32_t cod,
- bt_ssp_variant_t pairing_variant,
- uint32_t pass_key)
-{
- bool accept = false;
-
- bond_create_ssp_request_cb(remote_bd_addr, pairing_variant, accept,
- pass_key);
-}
-
-static void bond_cancel_success_ssp_request_cb(bt_bdaddr_t *remote_bd_addr,
- bt_bdname_t *bd_name, uint32_t cod,
- bt_ssp_variant_t pairing_variant,
- uint32_t pass_key)
-{
- struct test_data *data = tester_get_data();
- uint8_t *bdaddr = (uint8_t *)hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t remote_addr;
- bt_status_t status;
-
- bdaddr2android((const bdaddr_t *)bdaddr, &remote_addr.address);
-
- data->cb_count--;
-
- status = data->if_bluetooth->cancel_bond(&remote_addr);
- check_expected_status(status);
-}
-
-static gboolean ssp_request(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct generic_data *test = data->test_data;
- struct bt_cb_data *cb_data = user_data;
-
- if (data->test_checks_valid && test->expected_hal_cb.ssp_request_cb)
- test->expected_hal_cb.ssp_request_cb(&cb_data->bdaddr,
- &cb_data->bdname, cb_data->cod,
- cb_data->ssp_variant, cb_data->passkey);
-
- g_free(cb_data);
- return FALSE;
-}
-
-static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
- uint32_t cod, bt_ssp_variant_t pairing_variant,
- uint32_t pass_key)
-{
- struct bt_cb_data *cb_data = g_new0(struct bt_cb_data, 1);
-
- cb_data->bdaddr = *remote_bd_addr;
- cb_data->bdname = *bd_name;
- cb_data->cod = cod;
- cb_data->ssp_variant = pairing_variant;
- cb_data->passkey = pass_key;
-
- g_idle_add(ssp_request, cb_data);
-}
-
-static const struct generic_data bluetooth_discovery_start_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- discovery_start_success_cb,
- .expected_cb_count = 1,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bluetooth_discovery_start_success2_test = {
- .expected_hal_cb.discovery_state_changed_cb = discovery_start_done_cb,
- .expected_cb_count = 1,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bluetooth_discovery_stop_success2_test = {
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bluetooth_discovery_stop_success_test = {
- .expected_hal_cb.discovery_state_changed_cb = discovery_stop_success_cb,
- .expected_cb_count = 2,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bluetooth_discovery_device_found_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- discovery_device_found_state_changed_cb,
- .expected_hal_cb.device_found_cb = discovery_device_found_cb,
- .expected_cb_count = 3,
- .expected_adapter_status = BT_STATUS_NOT_EXPECTED,
-};
-
-static const char remote_get_properties_bdname_val[] = "00:AA:01:01:00:00";
-static uint32_t remote_get_properties_cod_val = 0;
-static bt_device_type_t remote_get_properties_tod_val = BT_DEVICE_DEVTYPE_BREDR;
-static int32_t remote_get_properties_rssi_val = -60;
-
-static struct priority_property remote_getprops_props[] = {
- {
- .prop.type = BT_PROPERTY_BDNAME,
- .prop.val = &remote_get_properties_bdname_val,
- .prop.len = sizeof(remote_get_properties_bdname_val) - 1,
- },
- {
- .prop.type = BT_PROPERTY_UUIDS,
- .prop.val = NULL,
- .prop.len = 0,
- },
- {
- .prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
- .prop.val = &remote_get_properties_cod_val,
- .prop.len = sizeof(remote_get_properties_cod_val),
- },
- {
- .prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
- .prop.val = &remote_get_properties_tod_val,
- .prop.len = sizeof(remote_get_properties_tod_val),
- },
- {
- .prop.type = BT_PROPERTY_REMOTE_RSSI,
- .prop.val = &remote_get_properties_rssi_val,
- .prop.len = sizeof(remote_get_properties_rssi_val),
- },
- {
- .prop.type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
- .prop.val = NULL,
- .prop.len = 4,
- },
-};
-
-static const struct generic_data bt_dev_getprops_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_getprops_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 6,
- .expected_properties = remote_getprops_props,
- .expected_adapter_status = BT_STATUS_NOT_EXPECTED,
-};
-
-static const char remote_getprop_bdname_val[] = "00:AA:01:01:00:00";
-
-static struct priority_property remote_getprop_bdname_props[] = {
- {
- .prop.type = BT_PROPERTY_BDNAME,
- .prop.val = &remote_getprop_bdname_val,
- .prop.len = sizeof(remote_getprop_bdname_val) - 1,
- },
-};
-
-static const struct generic_data bt_dev_getprop_bdname_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 1,
- .expected_properties = remote_getprop_bdname_props,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static struct priority_property remote_getprop_uuids_props[] = {
- {
- .prop.type = BT_PROPERTY_UUIDS,
- .prop.val = NULL,
- .prop.len = 0,
- },
-};
-
-static const struct generic_data bt_dev_getprop_uuids_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 1,
- .expected_properties = remote_getprop_uuids_props,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static uint32_t remote_getprop_cod_val = 0;
-
-static struct priority_property remote_getprop_cod_props[] = {
- {
- .prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
- .prop.val = &remote_getprop_cod_val,
- .prop.len = sizeof(remote_getprop_cod_val),
- },
-};
-
-static const struct generic_data bt_dev_getprop_cod_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 1,
- .expected_properties = remote_getprop_cod_props,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static bt_device_type_t remote_getprop_tod_val = BT_DEVICE_DEVTYPE_BREDR;
-
-static struct priority_property remote_getprop_tod_props[] = {
- {
- .prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
- .prop.val = &remote_getprop_tod_val,
- .prop.len = sizeof(remote_getprop_tod_val),
- },
-};
-
-static const struct generic_data bt_dev_getprop_tod_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 1,
- .expected_properties = remote_getprop_tod_props,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static int32_t remote_getprop_rssi_val = -60;
-
-static struct priority_property remote_getprop_rssi_props[] = {
- {
- .prop.type = BT_PROPERTY_REMOTE_RSSI,
- .prop.val = &remote_getprop_rssi_val,
- .prop.len = sizeof(remote_getprop_rssi_val),
- },
-};
-
-static const struct generic_data bt_dev_getprop_rssi_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 1,
- .expected_properties = remote_getprop_rssi_props,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static struct priority_property remote_getprop_timestamp_props[] = {
- {
- .prop.type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
- .prop.val = NULL,
- .prop.len = 4,
- },
-};
-
-static const struct generic_data bt_dev_getprop_timpestamp_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 1,
- .expected_properties = remote_getprop_timestamp_props,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static bt_bdaddr_t remote_getprop_bdaddr_val = {
- .address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 }
-};
-
-static struct priority_property remote_getprop_bdaddr_props[] = {
- {
- .prop.type = BT_PROPERTY_BDADDR,
- .prop.val = &remote_getprop_bdaddr_val,
- .prop.len = sizeof(remote_getprop_bdaddr_val),
- },
-};
-
-static const struct generic_data bt_dev_getprop_bdaddr_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_getprop_bdaddr_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static bt_service_record_t remote_getprop_servrec_val = {
- .uuid = { {0x00} },
- .channel = 12,
- .name = "bt_name",
-};
-
-static struct priority_property remote_getprop_servrec_props[] = {
- {
- .prop.type = BT_PROPERTY_SERVICE_RECORD,
- .prop.val = &remote_getprop_servrec_val,
- .prop.len = sizeof(remote_getprop_servrec_val),
- },
-};
-
-static const struct generic_data bt_dev_getprop_servrec_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_getprop_servrec_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static bt_scan_mode_t remote_getprop_scanmode_val = BT_SCAN_MODE_CONNECTABLE;
-
-static struct priority_property remote_getprop_scanmode_props[] = {
- {
- .prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
- .prop.val = &remote_getprop_scanmode_val,
- .prop.len = sizeof(remote_getprop_scanmode_val),
- },
-};
-
-static const struct generic_data bt_dev_getprop_scanmode_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_getprop_scanmode_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static struct priority_property remote_getprop_bondeddev_props[] = {
- {
- .prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
- .prop.val = NULL,
- .prop.len = 0,
- },
-};
-
-static const struct generic_data bt_dev_getprop_bondeddev_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_getprop_bondeddev_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static uint32_t remote_getprop_disctimeout_val = 120;
-
-static struct priority_property remote_getprop_disctimeout_props[] = {
- {
- .prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
- .prop.val = &remote_getprop_disctimeout_val,
- .prop.len = sizeof(remote_getprop_disctimeout_val),
- },
-};
-
-static const struct generic_data bt_dev_getprop_disctimeout_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_getprop_disctimeout_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static struct priority_property remote_getprop_verinfo_props[] = {
- {
- .prop.type = BT_PROPERTY_REMOTE_VERSION_INFO,
- .prop.val = NULL,
- .prop.len = 0,
- },
-};
-
-static const struct generic_data bt_dev_getprop_verinfo_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_getprop_verinfo_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static struct priority_property remote_getprop_fname_props[] = {
- {
- .prop.type = BT_PROPERTY_REMOTE_VERSION_INFO,
- .prop.val = NULL,
- .prop.len = 0,
- },
-};
-
-static const struct generic_data bt_dev_getprop_fname_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_get_property_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_getprop_fname_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static const char remote_setprop_fname_val[] = "set_fname_test";
-
-static struct priority_property remote_setprop_fname_props[] = {
- {
- .prop.type = BT_PROPERTY_REMOTE_FRIENDLY_NAME,
- .prop.val = &remote_setprop_fname_val,
- .prop.len = sizeof(remote_setprop_fname_val) - 1,
- },
-};
-
-static const struct generic_data bt_dev_setprop_fname_success_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_setprop_disc_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_device_found_cb,
- .expected_hal_cb.remote_device_properties_cb =
- remote_test_device_properties_cb,
- .expected_cb_count = 3,
- .expected_properties_num = 1,
- .expected_properties = remote_setprop_fname_props,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const char remote_setprop_bdname_val[] = "setprop_bdname_fail";
-
-static struct priority_property remote_setprop_bdname_props[] = {
- {
- .prop.type = BT_PROPERTY_BDNAME,
- .prop.val = &remote_setprop_bdname_val,
- .prop.len = sizeof(remote_setprop_bdname_val) - 1,
- },
-};
-
-static const struct generic_data bt_dev_setprop_bdname_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_bdname_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static struct priority_property remote_setprop_uuids_props[] = {
- {
- .prop.type = BT_PROPERTY_UUIDS,
- .prop.val = NULL,
- .prop.len = 0,
- },
-};
-
-static const struct generic_data bt_dev_setprop_uuids_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_uuids_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static uint32_t remote_setprop_cod_val = 0;
-
-static struct priority_property remote_setprop_cod_props[] = {
- {
- .prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
- .prop.val = &remote_setprop_cod_val,
- .prop.len = sizeof(remote_setprop_cod_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_cod_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_cod_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static bt_device_type_t remote_setprop_tod_val = BT_DEVICE_DEVTYPE_BREDR;
-
-static struct priority_property remote_setprop_tod_props[] = {
- {
- .prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
- .prop.val = &remote_setprop_tod_val,
- .prop.len = sizeof(remote_setprop_tod_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_tod_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_tod_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static int32_t remote_setprop_rssi_val = -60;
-
-static struct priority_property remote_setprop_rssi_props[] = {
- {
- .prop.type = BT_PROPERTY_REMOTE_RSSI,
- .prop.val = &remote_setprop_rssi_val,
- .prop.len = sizeof(remote_setprop_rssi_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_rssi_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_rssi_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static int32_t remote_setprop_timestamp_val = 0xAB;
-
-static struct priority_property remote_setprop_timestamp_props[] = {
- {
- .prop.type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
- .prop.val = (&remote_setprop_timestamp_val),
- .prop.len = sizeof(remote_setprop_timestamp_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_timpestamp_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_timestamp_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static bt_bdaddr_t remote_setprop_bdaddr_val = {
- .address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 }
-};
-
-static struct priority_property remote_setprop_bdaddr_props[] = {
- {
- .prop.type = BT_PROPERTY_BDADDR,
- .prop.val = &remote_setprop_bdaddr_val,
- .prop.len = sizeof(remote_setprop_bdaddr_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_bdaddr_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_bdaddr_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static bt_service_record_t remote_setprop_servrec_val = {
- .uuid = { {0x00} },
- .channel = 12,
- .name = "bt_name",
-};
-
-static struct priority_property remote_setprop_servrec_props[] = {
- {
- .prop.type = BT_PROPERTY_SERVICE_RECORD,
- .prop.val = &remote_setprop_servrec_val,
- .prop.len = sizeof(remote_setprop_servrec_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_servrec_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_servrec_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static bt_scan_mode_t remote_setprop_scanmode_val = BT_SCAN_MODE_CONNECTABLE;
-
-static struct priority_property remote_setprop_scanmode_props[] = {
- {
- .prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
- .prop.val = &remote_setprop_scanmode_val,
- .prop.len = sizeof(remote_setprop_scanmode_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_scanmode_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_scanmode_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static bt_bdaddr_t remote_setprop_bondeddev_val = {
- .address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 }
-};
-
-static struct priority_property remote_setprop_bondeddev_props[] = {
- {
- .prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
- .prop.val = &remote_setprop_bondeddev_val,
- .prop.len = sizeof(remote_setprop_bondeddev_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_bondeddev_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_bondeddev_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static uint32_t remote_setprop_disctimeout_val = 120;
-
-static struct priority_property remote_setprop_disctimeout_props[] = {
- {
- .prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
- .prop.val = &remote_setprop_disctimeout_val,
- .prop.len = sizeof(remote_setprop_disctimeout_val),
- },
-};
-
-static const struct generic_data bt_dev_setprop_disctimeout_fail_test = {
- .expected_hal_cb.discovery_state_changed_cb =
- remote_discovery_state_changed_cb,
- .expected_hal_cb.device_found_cb = remote_setprop_fail_device_found_cb,
- .expected_cb_count = 3,
- .expected_properties = remote_setprop_disctimeout_props,
- .expected_adapter_status = BT_STATUS_FAIL,
-};
-
-static const struct generic_data bt_bond_create_pin_success_test = {
- .expected_hal_cb.device_found_cb = bond_device_found_cb,
- .expected_hal_cb.bond_state_changed_cb =
- bond_test_bonded_state_changed_cb,
- .expected_hal_cb.pin_request_cb = bond_create_pin_success_request_cb,
- .expected_cb_count = 4,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bt_bond_create_pin_fail_test = {
- .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
- .expected_hal_cb.bond_state_changed_cb =
- bond_test_none_state_changed_cb,
- .expected_hal_cb.pin_request_cb = bond_create_pin_fail_request_cb,
- .expected_cb_count = 4,
- .expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
-};
-
-static const struct generic_data bt_bond_create_ssp_success_test = {
- .expected_hal_cb.device_found_cb = bond_device_found_cb,
- .expected_hal_cb.bond_state_changed_cb =
- bond_test_bonded_state_changed_cb,
- .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
- .expected_cb_count = 4,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bt_bond_create_ssp_fail_test = {
- .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
- .expected_hal_cb.bond_state_changed_cb =
- bond_test_none_state_changed_cb,
- .expected_hal_cb.ssp_request_cb = bond_create_ssp_fail_request_cb,
- .expected_cb_count = 4,
- .expected_adapter_status = MGMT_STATUS_AUTH_FAILED,
-};
-
-static const struct generic_data bt_bond_create_no_disc_success_test = {
- .expected_hal_cb.bond_state_changed_cb =
- bond_test_bonded_state_changed_cb,
- .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
- .expected_cb_count = 3,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bt_bond_create_bad_addr_success_test = {
- .expected_adapter_status = MGMT_STATUS_CONNECT_FAILED,
-};
-
-static const struct generic_data bt_bond_cancel_success_test = {
- .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
- .expected_hal_cb.bond_state_changed_cb =
- bond_test_none_state_changed_cb,
- .expected_hal_cb.ssp_request_cb = bond_cancel_success_ssp_request_cb,
- .expected_cb_count = 4,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bt_bond_remove_success_test = {
- .expected_hal_cb.device_found_cb = bond_nostatus_device_found_cb,
- .expected_hal_cb.bond_state_changed_cb =
- bond_remove_success_state_changed_cb,
- .expected_hal_cb.ssp_request_cb = bond_create_ssp_success_request_cb,
- .expected_cb_count = 4,
- .expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static bt_callbacks_t bt_callbacks = {
- .size = sizeof(bt_callbacks),
- .adapter_state_changed_cb = adapter_state_changed_cb,
- .adapter_properties_cb = adapter_properties_cb,
- .remote_device_properties_cb = remote_device_properties_cb,
- .device_found_cb = device_found_cb,
- .discovery_state_changed_cb = discovery_state_changed_cb,
- .pin_request_cb = pin_request_cb,
- .ssp_request_cb = ssp_request_cb,
- .bond_state_changed_cb = bond_state_changed_cb,
- .acl_state_changed_cb = NULL,
- .thread_evt_cb = NULL,
- .dut_mode_recv_cb = NULL,
- .le_test_mode_cb = NULL
-};
-
-const bt_bdaddr_t bdaddr_dummy = {
- .address = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55}
-};
-
-static const struct socket_data btsock_inv_param_socktype = {
- .bdaddr = &bdaddr_dummy,
- .sock_type = 0,
- .channel = 1,
- .service_uuid = NULL,
- .service_name = "Test service",
- .flags = 0,
- .expected_status = BT_STATUS_PARM_INVALID,
-};
-
-static const struct socket_data btsock_inv_param_socktype_l2cap = {
- .bdaddr = &bdaddr_dummy,
- .sock_type = BTSOCK_L2CAP,
- .channel = 1,
- .service_uuid = NULL,
- .service_name = "Test service",
- .flags = 0,
- .expected_status = BT_STATUS_UNSUPPORTED,
-};
-
-/* Test invalid: channel & uuid are both zeroes */
-static const struct socket_data btsock_inv_params_chan_uuid = {
- .bdaddr = &bdaddr_dummy,
- .sock_type = BTSOCK_RFCOMM,
- .channel = 0,
- .service_uuid = NULL,
- .service_name = "Test service",
- .flags = 0,
- .expected_status = BT_STATUS_PARM_INVALID,
-};
-
-static const struct socket_data btsock_success = {
- .bdaddr = &bdaddr_dummy,
- .sock_type = BTSOCK_RFCOMM,
- .channel = 1,
- .service_uuid = NULL,
- .service_name = "Test service",
- .flags = 0,
- .expected_status = BT_STATUS_SUCCESS,
- .test_channel = false
-};
-
-static const struct socket_data btsock_success_check_chan = {
- .sock_type = BTSOCK_RFCOMM,
- .channel = 1,
- .service_uuid = NULL,
- .service_name = "Test service",
- .flags = 0,
- .expected_status = BT_STATUS_SUCCESS,
- .test_channel = true,
-};
-
-static const struct socket_data btsock_inv_param_bdaddr = {
- .bdaddr = NULL,
- .sock_type = BTSOCK_RFCOMM,
- .channel = 1,
- .service_uuid = NULL,
- .service_name = "Test service",
- .flags = 0,
- .expected_status = BT_STATUS_PARM_INVALID,
-};
-
-static const struct socket_data btsock_inv_listen_listen = {
- .sock_type = BTSOCK_RFCOMM,
- .channel = 1,
- .service_uuid = NULL,
- .service_name = "Test service",
- .flags = 0,
- .expected_status = BT_STATUS_BUSY,
- .test_channel = true,
-};
-
-static gboolean hidhost_connection_state(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct hidhost_generic_data *test = data->test_data;
- struct hh_cb_data *cb_data = user_data;
-
- data->cb_count++;
-
- if (cb_data->state == BTHH_CONN_STATE_CONNECTED)
- tester_setup_complete();
-
- if (test && test->expected_hal_cb.connection_state_cb)
- test->expected_hal_cb.connection_state_cb(&cb_data->bdaddr,
- cb_data->state);
-
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
- bthh_connection_state_t state)
-{
- struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
-
- cb_data->state = state;
- cb_data->bdaddr = *bd_addr;
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(hidhost_connection_state, cb_data);
-}
-
-static gboolean hidhost_virual_unplug(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct hidhost_generic_data *test = data->test_data;
- struct hh_cb_data *cb_data = user_data;
-
- data->cb_count++;
-
- if (test && test->expected_hal_cb.virtual_unplug_cb)
- test->expected_hal_cb.virtual_unplug_cb(&cb_data->bdaddr,
- cb_data->status);
-
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
-{
- struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
-
- cb_data->bdaddr = *bd_addr;
- cb_data->status = status;
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(hidhost_virual_unplug, cb_data);
-}
-
-static gboolean hidhost_hid_info(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct hidhost_generic_data *test = data->test_data;
- struct hh_cb_data *cb_data = user_data;
-
- data->cb_count++;
-
- if (test && test->expected_hal_cb.hid_info_cb)
- test->expected_hal_cb.hid_info_cb(&cb_data->bdaddr,
- cb_data->hid_info);
-
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
-{
- struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
-
- cb_data->bdaddr = *bd_addr;
- cb_data->hid_info = hid;
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(hidhost_hid_info, cb_data);
-}
-
-static gboolean hidhost_protocol_mode(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct hidhost_generic_data *test = data->test_data;
- struct hh_cb_data *cb_data = user_data;
-
- data->cb_count++;
-
- if (test && test->expected_hal_cb.protocol_mode_cb)
- test->expected_hal_cb.protocol_mode_cb(&cb_data->bdaddr,
- cb_data->status, cb_data->mode);
-
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
- bthh_status_t status,
- bthh_protocol_mode_t mode)
-{
- struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
-
- cb_data->bdaddr = *bd_addr;
- cb_data->status = status;
- cb_data->mode = mode;
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(hidhost_protocol_mode, cb_data);
-}
-
-static gboolean hidhost_get_report(gpointer user_data)
-{
- struct test_data *data = tester_get_data();
- const struct hidhost_generic_data *test = data->test_data;
- struct hh_cb_data *cb_data = user_data;
-
- data->cb_count++;
-
- if (test && test->expected_hal_cb.get_report_cb)
- test->expected_hal_cb.get_report_cb(&cb_data->bdaddr,
- cb_data->status, cb_data->report, cb_data->size);
-
- g_free(cb_data->report);
- g_free(cb_data);
-
- g_atomic_int_dec_and_test(&scheduled_cbacks_num);
- return FALSE;
-}
-
-static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
- uint8_t *report, int size)
-{
- struct hh_cb_data *cb_data = g_new0(struct hh_cb_data, 1);
-
- cb_data->bdaddr = *bd_addr;
- cb_data->status = status;
- cb_data->report = g_memdup(report, size);
- cb_data->size = size;
-
- g_atomic_int_inc(&scheduled_cbacks_num);
- g_idle_add(hidhost_get_report, cb_data);
-}
-
-static bthh_callbacks_t bthh_callbacks = {
- .size = sizeof(bthh_callbacks),
- .connection_state_cb = hidhost_connection_state_cb,
- .hid_info_cb = hidhost_hid_info_cb,
- .protocol_mode_cb = hidhost_protocol_mode_cb,
- .idle_time_cb = NULL,
- .get_report_cb = hidhost_get_report_cb,
- .virtual_unplug_cb = hidhost_virual_unplug_cb
-};
-
-#define test_bredr(name, data, test_setup, test, test_teardown) \
- do { \
- struct test_data *user; \
- user = g_malloc0(sizeof(struct test_data)); \
- if (!user) \
- break; \
- user->hciemu_type = HCIEMU_TYPE_BREDR; \
- user->test_data = data; \
- tester_add_full(name, data, test_pre_setup, test_setup, \
- test, test_teardown, test_post_teardown, \
- 1, user, g_free); \
- } while (0)
-
-#define test_bredrle(name, data, test_setup, test, test_teardown) \
- do { \
- struct test_data *user; \
- user = g_malloc0(sizeof(struct test_data)); \
- if (!user) \
- break; \
- user->hciemu_type = HCIEMU_TYPE_BREDRLE; \
- user->test_data = data; \
- tester_add_full(name, data, test_pre_setup, test_setup, \
- test, test_teardown, test_post_teardown, \
- 3, user, g_free); \
- } while (0)
-
-int main(int argc, char *argv[])
-{
- snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
-
- tester_init(&argc, &argv);
-
- return tester_run();
-}
--
1.9.1
---
android/android-tester.c | 881 -----------------------------------------------
1 file changed, 881 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 7f384ce..1167e98 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -151,108 +151,6 @@ static char exec_dir[PATH_MAX];
static gint scheduled_cbacks_num = 0;
-static gboolean check_callbacks_called(gpointer user_data)
-{
- /*
- * Wait for all callbacks scheduled in current test context to execute
- * in main loop. This will avoid late callback calls after test case has
- * already failed or timed out.
- */
-
- if (g_atomic_int_get(&scheduled_cbacks_num) == 0) {
- tester_teardown_complete();
- return FALSE;
- }
-
- return TRUE;
-}
-static void check_daemon_term(void)
-{
- int status;
- pid_t pid;
- struct test_data *data = tester_get_data();
-
- if (!data)
- return;
-
- pid = waitpid(data->bluetoothd_pid, &status, WNOHANG);
- if (pid != data->bluetoothd_pid)
- return;
-
- data->bluetoothd_pid = 0;
-
- if (WIFEXITED(status) && (WEXITSTATUS(status) == EXIT_SUCCESS)) {
- g_idle_add(check_callbacks_called, NULL);
- return;
- }
-
- tester_warn("Unexpected Daemon shutdown with status %d", status);
-}
-
-static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
- gpointer user_data)
-{
- struct signalfd_siginfo si;
- ssize_t result;
- int fd;
-
- if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
- return FALSE;
-
- fd = g_io_channel_unix_get_fd(channel);
-
- result = read(fd, &si, sizeof(si));
- if (result != sizeof(si))
- return FALSE;
-
- switch (si.ssi_signo) {
- case SIGCHLD:
- check_daemon_term();
- break;
- }
-
- return TRUE;
-}
-
-static guint setup_signalfd(void)
-{
- GIOChannel *channel;
- guint source;
- sigset_t mask;
- int fd;
-
- sigemptyset(&mask);
- sigaddset(&mask, SIGCHLD);
-
- if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
- return 0;
-
- fd = signalfd(-1, &mask, 0);
- if (fd < 0)
- return 0;
-
- channel = g_io_channel_unix_new(fd);
-
- g_io_channel_set_close_on_unref(channel, TRUE);
- g_io_channel_set_encoding(channel, NULL, NULL);
- g_io_channel_set_buffered(channel, FALSE);
-
- source = g_io_add_watch(channel,
- G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
- signal_handler, NULL);
-
- g_io_channel_unref(channel);
-
- return source;
-}
-
-static void mgmt_debug(const char *str, void *user_data)
-{
- const char *prefix = user_data;
-
- tester_print("%s%s", prefix, str);
-}
-
static void test_update_state(void)
{
struct test_data *data = tester_get_data();
@@ -374,214 +272,6 @@ static bool check_test_property(bt_property_t received_prop,
return true;
}
-static void read_info_callback(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- struct test_data *data = tester_get_data();
- const struct mgmt_rp_read_info *rp = param;
- char addr[18];
- uint16_t manufacturer;
- uint32_t supported_settings, current_settings;
-
- tester_print("Read Info callback");
- tester_print(" Status: 0x%02x", status);
-
- if (status || !param) {
- tester_pre_setup_failed();
- return;
- }
-
- ba2str(&rp->bdaddr, addr);
- manufacturer = btohs(rp->manufacturer);
- supported_settings = btohl(rp->supported_settings);
- current_settings = btohl(rp->current_settings);
-
- tester_print(" Address: %s", addr);
- tester_print(" Version: 0x%02x", rp->version);
- tester_print(" Manufacturer: 0x%04x", manufacturer);
- tester_print(" Supported settings: 0x%08x", supported_settings);
- tester_print(" Current settings: 0x%08x", current_settings);
- tester_print(" Class: 0x%02x%02x%02x",
- rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
- tester_print(" Name: %s", rp->name);
- tester_print(" Short name: %s", rp->short_name);
-
- if (strcmp(hciemu_get_address(data->hciemu), addr)) {
- tester_pre_setup_failed();
- return;
- }
-
- tester_pre_setup_complete();
-}
-
-static void index_added_callback(uint16_t index, uint16_t length,
- const void *param, void *user_data)
-{
- struct test_data *data = tester_get_data();
-
- tester_print("Index Added callback");
- tester_print(" Index: 0x%04x", index);
-
- data->mgmt_index = index;
-
- mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL,
- read_info_callback, NULL, NULL);
-}
-
-static void index_removed_callback(uint16_t index, uint16_t length,
- const void *param, void *user_data)
-{
- struct test_data *data = tester_get_data();
-
- tester_print("Index Removed callback");
- tester_print(" Index: 0x%04x", index);
-
- if (index != data->mgmt_index)
- return;
-
- mgmt_unregister_index(data->mgmt, data->mgmt_index);
-
- mgmt_unref(data->mgmt);
- data->mgmt = NULL;
-
- tester_post_teardown_complete();
-}
-
-static void read_index_list_callback(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- struct test_data *data = tester_get_data();
-
- tester_print("Read Index List callback");
- tester_print(" Status: 0x%02x", status);
-
- if (status || !param) {
- tester_pre_setup_failed();
- return;
- }
-
- mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
- index_added_callback, NULL, NULL);
-
- mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE,
- index_removed_callback, NULL, NULL);
-
- data->hciemu = hciemu_new(data->hciemu_type);
- if (!data->hciemu) {
- tester_warn("Failed to setup HCI emulation");
- tester_pre_setup_failed();
- return;
- }
-
- tester_print("New hciemu instance created");
-}
-
-static void test_pre_setup(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- data->signalfd = setup_signalfd();
- if (!data->signalfd) {
- tester_warn("Failed to setup signalfd");
- tester_pre_setup_failed();
- return;
- }
-
- data->mgmt = mgmt_new_default();
- if (!data->mgmt) {
- tester_warn("Failed to setup management interface");
- tester_pre_setup_failed();
- return;
- }
-
- if (!tester_use_debug())
- fclose(stderr);
- else
- mgmt_set_debug(data->mgmt, mgmt_debug, "mgmt: ", NULL);
-
- mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0,
- NULL, read_index_list_callback, NULL, NULL);
-}
-
-static void test_post_teardown(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- hciemu_unref(data->hciemu);
- data->hciemu = NULL;
-
- g_source_remove(data->signalfd);
- data->signalfd = 0;
-}
-
-static void bluetoothd_start(int hci_index)
-{
- char prg_name[PATH_MAX];
- char index[8];
- char *prg_argv[5];
-
- snprintf(prg_name, sizeof(prg_name), "%s/%s", exec_dir, "bluetoothd");
- snprintf(index, sizeof(index), "%d", hci_index);
-
- prg_argv[0] = prg_name;
- prg_argv[1] = "-i";
- prg_argv[2] = index;
- prg_argv[3] = "-d";
- prg_argv[4] = NULL;
-
- if (!tester_use_debug())
- fclose(stderr);
-
- execve(prg_argv[0], prg_argv, NULL);
-}
-
-static void emulator(int pipe, int hci_index)
-{
- static const char SYSTEM_SOCKET_PATH[] = "\0android_system";
- char buf[1024];
- struct sockaddr_un addr;
- struct timeval tv;
- int fd;
- ssize_t len;
-
- fd = socket(PF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
- if (fd < 0)
- goto failed;
-
- tv.tv_sec = WAIT_FOR_SIGNAL_TIME;
- tv.tv_usec = 0;
- setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
- memcpy(addr.sun_path, SYSTEM_SOCKET_PATH, sizeof(SYSTEM_SOCKET_PATH));
-
- if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- perror("Failed to bind system socket");
- goto failed;
- }
-
- len = write(pipe, EMULATOR_SIGNAL, sizeof(EMULATOR_SIGNAL));
- if (len != sizeof(EMULATOR_SIGNAL))
- goto failed;
-
- memset(buf, 0, sizeof(buf));
-
- len = read(fd, buf, sizeof(buf));
- if (len <= 0 || strcmp(buf, "bluetooth.start=daemon"))
- goto failed;
-
- close(pipe);
- close(fd);
- return bluetoothd_start(hci_index);
-
-failed:
- close(pipe);
-
- if (fd >= 0)
- close(fd);
-}
-
static void emu_connectable_complete(uint16_t opcode, uint8_t status,
const void *param, uint8_t len,
void *user_data)
@@ -1963,96 +1653,6 @@ static bt_callbacks_t bt_callbacks = {
.le_test_mode_cb = NULL
};
-static bool setup(struct test_data *data)
-{
- const hw_module_t *module;
- hw_device_t *device;
- int signal_fd[2];
- char buf[1024];
- pid_t pid;
- int len;
- int err;
-
- if (pipe(signal_fd))
- return false;
-
- pid = fork();
-
- if (pid < 0) {
- close(signal_fd[0]);
- close(signal_fd[1]);
- return false;
- }
-
- if (pid == 0) {
- if (!tester_use_debug())
- fclose(stderr);
-
- close(signal_fd[0]);
- emulator(signal_fd[1], data->mgmt_index);
- exit(0);
- }
-
- close(signal_fd[1]);
- data->bluetoothd_pid = pid;
-
- len = read(signal_fd[0], buf, sizeof(buf));
- if (len <= 0 || strcmp(buf, EMULATOR_SIGNAL)) {
- close(signal_fd[0]);
- return false;
- }
-
- close(signal_fd[0]);
-
- err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
- if (err)
- return false;
-
- err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
- if (err)
- return false;
-
- data->device = device;
-
- data->if_bluetooth = ((bluetooth_device_t *)
- device)->get_bluetooth_interface();
- if (!data->if_bluetooth)
- return false;
-
- return true;
-}
-
-static void teardown(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- if (data->if_hid) {
- data->if_hid->cleanup();
- data->if_hid = NULL;
- }
-
- if (data->if_bluetooth) {
- data->if_bluetooth->cleanup();
- data->if_bluetooth = NULL;
- }
-
- /* Test result already known, no need to check further */
- data->test_checks_valid = false;
-
- if (data->expected_properties_list)
- g_slist_free(data->expected_properties_list);
-
- data->device->close(data->device);
-
- if (!data->bluetoothd_pid)
- tester_teardown_complete();
-}
-
-static void test_dummy(const void *test_data)
-{
- tester_test_passed();
-}
-
const bt_bdaddr_t bdaddr_dummy = {
.address = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55}
};
@@ -2295,453 +1895,6 @@ static bthh_callbacks_t bthh_callbacks = {
.virtual_unplug_cb = hidhost_virual_unplug_cb
};
-static bool setup_hidhost(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- bt_status_t status;
- const void *hid;
-
- if (!setup(data))
- return false;
-
- status = data->if_bluetooth->init(&bt_callbacks);
- if (status != BT_STATUS_SUCCESS) {
- data->if_bluetooth = NULL;
- return false;
- }
-
- hid = data->if_bluetooth->get_profile_interface(BT_PROFILE_HIDHOST_ID);
- if (!hid)
- return false;
-
- data->if_hid = hid;
-
- status = data->if_hid->init(&bthh_callbacks);
- if (status != BT_STATUS_SUCCESS) {
- data->if_hid = NULL;
- return false;
- }
-
- return true;
-}
-
-static void setup_hidhost_interface(const void *test_data)
-{
- if (setup_hidhost(test_data))
- tester_setup_complete();
- else
- tester_setup_failed();
-}
-
-#define HID_GET_REPORT_PROTOCOL 0x60
-#define HID_GET_BOOT_PROTOCOL 0x61
-#define HID_SET_REPORT_PROTOCOL 0x70
-#define HID_SET_BOOT_PROTOCOL 0x71
-
-#define HID_SET_INPUT_REPORT 0x51
-#define HID_SET_OUTPUT_REPORT 0x52
-#define HID_SET_FEATURE_REPORT 0x53
-
-#define HID_SEND_DATA 0xa2
-
-#define HID_GET_INPUT_REPORT 0x49
-#define HID_GET_OUTPUT_REPORT 0x4a
-#define HID_GET_FEATURE_REPORT 0x4b
-
-static void hid_prepare_reply_protocol_mode(const void *data, uint16_t len)
-{
- struct test_data *t_data = tester_get_data();
- struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
- uint8_t pdu[2] = { 0, 0 };
- uint16_t pdu_len = 0;
-
- pdu_len = 2;
- pdu[0] = 0xa0;
- pdu[1] = 0x00;
-
- bthost_send_cid(bthost, t_data->ctrl_handle, t_data->ctrl_cid,
- (void *)pdu, pdu_len);
-}
-
-static void hid_prepare_reply_report(const void *data, uint16_t len)
-{
- struct test_data *t_data = tester_get_data();
- struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
- uint8_t pdu[3] = { 0, 0, 0 };
- uint16_t pdu_len = 0;
-
- pdu_len = 3;
- pdu[0] = 0xa2;
- pdu[1] = 0x01;
- pdu[2] = 0x00;
-
- bthost_send_cid(bthost, t_data->ctrl_handle, t_data->ctrl_cid,
- (void *)pdu, pdu_len);
-}
-
-static void hid_intr_cid_hook_cb(const void *data, uint16_t len,
- void *user_data)
-{
- uint8_t header = ((uint8_t *) data)[0];
-
- switch (header) {
- case HID_SEND_DATA:
- tester_test_passed();
- break;
- }
-}
-
-static void hid_intr_connect_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);
-
- data->intr_handle = handle;
- data->intr_cid = cid;
-
- bthost_add_cid_hook(bthost, handle, cid, hid_intr_cid_hook_cb, NULL);
-}
-
-static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
- void *user_data)
-{
- uint8_t header = ((uint8_t *) data)[0];
-
- switch (header) {
- case HID_GET_REPORT_PROTOCOL:
- case HID_GET_BOOT_PROTOCOL:
- case HID_SET_REPORT_PROTOCOL:
- case HID_SET_BOOT_PROTOCOL:
- hid_prepare_reply_protocol_mode(data, len);
- break;
- case HID_GET_INPUT_REPORT:
- case HID_GET_OUTPUT_REPORT:
- case HID_GET_FEATURE_REPORT:
- hid_prepare_reply_report(data, len);
- break;
- /*
- * HID device doesnot reply for this commads, so reaching pdu's
- * to hid device means assuming test passed
- */
- case HID_SET_INPUT_REPORT:
- case HID_SET_OUTPUT_REPORT:
- case HID_SET_FEATURE_REPORT:
- case HID_SEND_DATA:
- tester_test_passed();
- break;
- }
-}
-
-static void hid_ctrl_connect_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);
-
- data->ctrl_handle = handle;
- data->ctrl_cid = cid;
-
- bthost_add_cid_hook(bthost, handle, cid, hid_ctrl_cid_hook_cb, NULL);
-}
-
-static const uint8_t did_req_pdu[] = { 0x06, /* PDU id */
- 0x00, 0x00, /* Transaction id */
- 0x00, 0x0f, /* Req length */
- 0x35, 0x03, /* Attributes length */
- 0x19, 0x12, 0x00, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00,
- 0x00, 0xff, 0xff, 0x00 }; /* no continuation */
-
-static const uint8_t did_rsp_pdu[] = { 0x07, /* PDU id */
- 0x00, 0x00, /* Transaction id */
- 0x00, 0x4f, /* Response length */
- 0x00, 0x4c, /* Attributes length */
- 0x35, 0x4a, 0x35, 0x48, 0x09, 0x00, 0x00, 0x0a, 0x00,
- 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35, 0x03, 0x19,
- 0x12, 0x00, 0x09, 0x00, 0x05, 0x35, 0x03, 0x19, 0x10,
- 0x02, 0x09, 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19,
- 0x12, 0x00, 0x09, 0x01, 0x03, 0x09, 0x02, 0x00, 0x09,
- 0x01, 0x03, 0x09, 0x02, 0x01, 0x09, 0x1d, 0x6b, 0x09,
- 0x02, 0x02, 0x09, 0x02, 0x46, 0x09, 0x02, 0x03, 0x09,
- 0x05, 0x0e, 0x09, 0x02, 0x04, 0x28, 0x01, 0x09, 0x02,
- 0x05, 0x09, 0x00, 0x02,
- 0x00 }; /* no continuation */
-
-static const uint8_t hid_rsp_pdu[] = { 0x07, /* PDU id */
- 0x00, 0x01, /* Transaction id */
- 0x01, 0x71, /* Response length */
- 0x01, 0x6E, /* Attributes length */
- 0x36, 0x01, 0x6b, 0x36, 0x01, 0x68, 0x09, 0x00, 0x00,
- 0x0a, 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35,
- 0x03, 0x19, 0x11, 0x24, 0x09, 0x00, 0x04, 0x35, 0x0d,
- 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x11, 0x35,
- 0x03, 0x19, 0x00, 0x11, 0x09, 0x00, 0x05, 0x35, 0x03,
- 0x19, 0x10, 0x02, 0x09, 0x00, 0x06, 0x35, 0x09, 0x09,
- 0x65, 0x6e, 0x09, 0x00, 0x6a, 0x09, 0x01, 0x00, 0x09,
- 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x24,
- 0x09, 0x01, 0x00, 0x09, 0x00, 0x0d, 0x35, 0x0f, 0x35,
- 0x0d, 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x13,
- 0x35, 0x03, 0x19, 0x00, 0x11, 0x09, 0x01, 0x00, 0x25,
- 0x1e, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63, 0x68,
- 0x20, 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74,
- 0x68, 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x4d,
- 0x35, 0x35, 0x35, 0x62, 0x09, 0x01, 0x01, 0x25, 0x0f,
- 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, 0x68,
- 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x09, 0x01, 0x02,
- 0x25, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63,
- 0x68, 0x09, 0x02, 0x00, 0x09, 0x01, 0x00, 0x09, 0x02,
- 0x01, 0x09, 0x01, 0x11, 0x09, 0x02, 0x02, 0x08, 0x80,
- 0x09, 0x02, 0x03, 0x08, 0x21, 0x09, 0x02, 0x04, 0x28,
- 0x01, 0x09, 0x02, 0x05, 0x28, 0x01, 0x09, 0x02, 0x06,
- 0x35, 0x74, 0x35, 0x72, 0x08, 0x22, 0x25, 0x6e, 0x05,
- 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01,
- 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x08, 0x15,
- 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02,
- 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x16, 0x01, 0xf8,
- 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 0x81, 0x06,
- 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95,
- 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x81,
- 0x06, 0x05, 0x09, 0x19, 0x09, 0x29, 0x10, 0x15, 0x00,
- 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0xc0,
- 0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85,
- 0x10, 0x75, 0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff,
- 0x00, 0x09, 0x01, 0x81, 0x00, 0x09, 0x01, 0x91, 0x00,
- 0xc0, 0x09, 0x02, 0x07, 0x35, 0x08, 0x35, 0x06, 0x09,
- 0x04, 0x09, 0x09, 0x01, 0x00, 0x09, 0x02, 0x08, 0x28,
- 0x00, 0x09, 0x02, 0x09, 0x28, 0x01, 0x09, 0x02, 0x0a,
- 0x28, 0x01, 0x09, 0x02, 0x0b, 0x09, 0x01, 0x00, 0x09,
- 0x02, 0x0c, 0x09, 0x0c, 0x80, 0x09, 0x02, 0x0d, 0x28,
- 0x00, 0x09, 0x02, 0x0e, 0x28, 0x01,
- 0x00 }; /* no continuation */
-
-static void hid_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
-{
- struct test_data *t_data = tester_get_data();
- struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
-
- if (!memcmp(did_req_pdu, data, len)) {
- bthost_send_cid(bthost, t_data->sdp_handle, t_data->sdp_cid,
- did_rsp_pdu, sizeof(did_rsp_pdu));
- return;
- }
-
- bthost_send_cid(bthost, t_data->sdp_handle, t_data->sdp_cid,
- hid_rsp_pdu, sizeof(hid_rsp_pdu));
-}
-
-static void hid_sdp_search_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);
-
- data->sdp_handle = handle;
- data->sdp_cid = cid;
-
- bthost_add_cid_hook(bthost, handle, cid, hid_sdp_cid_hook_cb, NULL);
-}
-
-static void emu_powered_complete(uint16_t opcode, uint8_t status,
- const void *param, uint8_t len,
- void *user_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
-
- switch (opcode) {
- case BT_HCI_CMD_WRITE_SCAN_ENABLE:
- case BT_HCI_CMD_LE_SET_ADV_ENABLE:
- break;
- default:
- return;
- }
-
- if (status) {
- tester_setup_failed();
- return;
- }
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->connect(&bdaddr);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_setup_failed();
-}
-
-static void setup_hidhost_connect(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- struct bthost *bthost;
-
- if (!setup_hidhost(test_data)) {
- tester_setup_failed();
- return;
- }
-
- bthost = hciemu_client_get_host(data->hciemu);
-
- /* Emulate SDP (PSM = 1) */
- bthost_add_l2cap_server(bthost, 1, hid_sdp_search_cb, NULL);
- /* Emulate Control Channel (PSM = 17) */
- bthost_add_l2cap_server(bthost, 17, hid_ctrl_connect_cb, NULL);
- /* Emulate Interrupt Channel (PSM = 19) */
- bthost_add_l2cap_server(bthost, 19, hid_intr_connect_cb, NULL);
-
- bthost_set_cmd_complete_cb(bthost, emu_powered_complete, data);
- bthost_write_scan_enable(bthost, 0x03);
-}
-
-static void hid_discon_cb(bt_bdaddr_t *bd_addr, bthh_connection_state_t state)
-{
- if (state == BTHH_CONN_STATE_DISCONNECTED)
- tester_test_passed();
-}
-
-static const struct hidhost_generic_data hidhost_test_disconnect = {
- .expected_hal_cb.connection_state_cb = hid_discon_cb,
-};
-
-static void test_hidhost_disconnect(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->disconnect(&bdaddr);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_test_failed();
-}
-
-static void test_hidhost_virtual_unplug(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->virtual_unplug(&bdaddr);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_test_failed();
-}
-
-static void hid_protocol_mode_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
- bthh_protocol_mode_t mode)
-{
- struct test_data *data = tester_get_data();
- const struct hidhost_generic_data *test = data->test_data;
-
- if (data->cb_count == test->expected_cb_count &&
- status == test->expected_status &&
- mode == test->expected_protocol_mode)
- tester_test_passed();
- else
- tester_test_failed();
-}
-
-static const struct hidhost_generic_data hidhost_test_get_protocol = {
- .expected_hal_cb.protocol_mode_cb = hid_protocol_mode_cb,
- .expected_cb_count = 1,
- .expected_protocol_mode = BTHH_BOOT_MODE,
- .expected_status = BTHH_OK,
-};
-
-static void test_hidhost_get_protocol(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->get_protocol(&bdaddr, BTHH_REPORT_MODE);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_test_failed();
-}
-
-static void test_hidhost_set_protocol(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->set_protocol(&bdaddr, BTHH_REPORT_MODE);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_test_failed();
-}
-
-static void test_hidhost_set_report(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
- char *buf = "010101";
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->set_report(&bdaddr, BTHH_INPUT_REPORT, buf);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_test_failed();
-}
-
-static void test_hidhost_send_data(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
- char *buf = "fe0201";
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->send_data(&bdaddr, buf);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_test_failed();
-}
-
-static void hid_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
- uint8_t *report, int size)
-{
- struct test_data *data = tester_get_data();
- const struct hidhost_generic_data *test = data->test_data;
-
- if (data->cb_count == test->expected_cb_count &&
- status == test->expected_status &&
- size == test->expected_report_size)
- tester_test_passed();
- else
- tester_test_failed();
-}
-
-static const struct hidhost_generic_data hidhost_test_get_report = {
- .expected_hal_cb.get_report_cb = hid_get_report_cb,
- .expected_cb_count = 1,
- .expected_status = BTHH_OK,
- .expected_report_size = 2,
-};
-
-static void test_hidhost_get_report(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
- bt_bdaddr_t bdaddr;
- bt_status_t bt_status;
-
- data->cb_count = 0;
- bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
- bt_status = data->if_hid->get_report(&bdaddr, BTHH_INPUT_REPORT, 1, 20);
- if (bt_status != BT_STATUS_SUCCESS)
- tester_test_failed();
-}
-
#define test_bredr(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -2774,39 +1927,5 @@ int main(int argc, char *argv[])
tester_init(&argc, &argv);
- test_bredrle("HIDHost Init", NULL, setup_hidhost_interface,
- test_dummy, teardown);
-
- test_bredrle("HIDHost Connect Success",
- NULL, setup_hidhost_connect,
- test_dummy, teardown);
-
- test_bredrle("HIDHost Disconnect Success",
- &hidhost_test_disconnect, setup_hidhost_connect,
- test_hidhost_disconnect, teardown);
-
- test_bredrle("HIDHost VirtualUnplug Success",
- &hidhost_test_disconnect, setup_hidhost_connect,
- test_hidhost_virtual_unplug, teardown);
-
- test_bredrle("HIDHost GetProtocol Success",
- &hidhost_test_get_protocol, setup_hidhost_connect,
- test_hidhost_get_protocol, teardown);
-
- test_bredrle("HIDHost SetProtocol Success",
- &hidhost_test_get_protocol, setup_hidhost_connect,
- test_hidhost_set_protocol, teardown);
-
- test_bredrle("HIDHost GetReport Success",
- &hidhost_test_get_report, setup_hidhost_connect,
- test_hidhost_get_report, teardown);
-
- test_bredrle("HIDHost SetReport Success",
- NULL, setup_hidhost_connect,
- test_hidhost_set_report, teardown);
-
- test_bredrle("HIDHost SendData Success",
- NULL, setup_hidhost_connect,
- test_hidhost_send_data, teardown);
return tester_run();
}
--
1.9.1
---
android/tester-hidhost.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 84b9f62..c6296aa 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -238,10 +238,16 @@ static void hid_intr_cid_hook_cb(const void *data, uint16_t len,
void *user_data)
{
uint8_t header = ((uint8_t *) data)[0];
+ struct step *step;
switch (header) {
case HID_SEND_DATA:
- /* Todo verify step with success */
+ /* Successfully verify sending data step */
+ step = g_new0(struct step, 1);
+
+ step->action_status = BT_STATUS_SUCCESS;
+
+ schedule_action_verification(step);
break;
}
}
@@ -370,6 +376,26 @@ static void hidhost_set_report_action(void)
{
struct test_data *data = tester_get_data();
const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ char *buf = "fe0201";
+ bt_bdaddr_t bdaddr;
+ int status;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ /* Successfull result should be verified on the other end (hook) */
+ status = data->if_hid->send_data(&bdaddr, buf);
+ if (status) {
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = status;
+ schedule_action_verification(step);
+ }
+}
+
+static void hidhost_send_data_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
char *buf = "010101";
bt_bdaddr_t bdaddr;
int status;
@@ -515,6 +541,22 @@ static struct test_case test_cases[] = {
BTHH_CONN_STATE_CONNECTED),
ACTION_SUCCESS(hidhost_set_report_action, NULL),
),
+ TEST_CASE_BREDRLE("HidHost SendData 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(hidhost_send_data_action, NULL),
+ ),
};
struct queue *get_hidhost_tests(void)
--
1.9.1
---
android/tester-hidhost.c | 36 ++++++++++++++++++++++++++++++++++++
android/tester-main.c | 23 ++++++++++++++++++++++-
android/tester-main.h | 13 +++++++++++++
3 files changed, 71 insertions(+), 1 deletion(-)
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index f77d5c0..070646e 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -37,6 +37,10 @@
#define HID_GET_OUTPUT_REPORT 0x4a
#define HID_GET_FEATURE_REPORT 0x4b
+#define HID_MODE_DEFAULT 0x00
+#define HID_MODE_BREDR 0x01
+#define HID_MODE_LE 0x02
+
static struct queue *list; /* List of hidhost test cases */
struct emu_cid_data {
@@ -308,6 +312,21 @@ static void hidhost_virtual_unplug_action(void)
schedule_action_verification(step);
}
+static void hidhost_get_protocol_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ step->action_status = data->if_hid->get_protocol(&bdaddr,
+ BTHH_REPORT_MODE);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("HidHost Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -367,6 +386,23 @@ static struct test_case test_cases[] = {
CALLBACK_STATE(CB_HH_CONNECTION_STATE,
BTHH_CONN_STATE_DISCONNECTED),
),
+ TEST_CASE_BREDRLE("HidHost GetProtocol 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(hidhost_get_protocol_action, NULL),
+ CALLBACK_HH_MODE(CB_HH_PROTOCOL_MODE, BTHH_OK, HID_MODE_BREDR),
+ ),
};
struct queue *get_hidhost_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index f1e8a2c..efda577 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -431,6 +431,12 @@ static bool match_data(struct step *step)
return false;
}
+ if (exp->callback_result.mode !=
+ step->callback_result.mode) {
+ tester_debug("Callback mode don't match");
+ return false;
+ }
+
if (exp->callback_result.pairing_variant !=
step->callback_result.pairing_variant) {
tester_debug("Callback pairing result don't match");
@@ -791,6 +797,21 @@ static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
schedule_callback_call(step);
}
+static void hidhost_protocol_mode_cb(bt_bdaddr_t *bd_addr,
+ bthh_status_t status,
+ bthh_protocol_mode_t mode)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_HH_PROTOCOL_MODE;
+ step->callback_result.status = status;
+ step->callback_result.mode = mode;
+
+ /* TODO: add bdaddr to verify? */
+
+ schedule_callback_call(step);
+}
+
static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
{
struct step *step = g_new0(struct step, 1);
@@ -804,7 +825,7 @@ static bthh_callbacks_t bthh_callbacks = {
.size = sizeof(bthh_callbacks),
.connection_state_cb = hidhost_connection_state_cb,
.hid_info_cb = hidhost_hid_info_cb,
- .protocol_mode_cb = NULL,
+ .protocol_mode_cb = hidhost_protocol_mode_cb,
.idle_time_cb = NULL,
.get_report_cb = NULL,
.virtual_unplug_cb = hidhost_virual_unplug_cb
diff --git a/android/tester-main.h b/android/tester-main.h
index 7efc966..eebcc1e 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -91,6 +91,11 @@
.callback_result.state = cb_res, \
}
+#define CALLBACK_STATUS(cb, cb_res) { \
+ .callback = cb, \
+ .callback_result.status = cb_res, \
+ }
+
#define CALLBACK_ADAPTER_PROPS(props, prop_cnt) { \
.callback = CB_BT_ADAPTER_PROPERTIES, \
.callback_result.properties = props, \
@@ -103,6 +108,12 @@
.callback_result.num_properties = prop_cnt, \
}
+#define CALLBACK_HH_MODE(cb, cb_res, cb_mode) { \
+ .callback = cb, \
+ .callback_result.status = cb_res, \
+ .callback_result.mode = cb_mode, \
+ }
+
#define CALLBACK_DEVICE_PROPS(props, prop_cnt) \
CALLBACK_PROPS(CB_BT_REMOTE_DEVICE_PROPERTIES, props, prop_cnt)
@@ -257,6 +268,8 @@ struct bt_callback_data {
bt_property_t *properties;
bt_ssp_variant_t pairing_variant;
+
+ bthh_protocol_mode_t mode;
};
/*
--
1.9.1
---
android/tester-hidhost.c | 36 ++++++++++++++++++++++++++++++++++++
android/tester-main.c | 21 ++++++++++++++++++++-
android/tester-main.h | 10 ++++++++++
3 files changed, 66 insertions(+), 1 deletion(-)
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index d9dc04c..ad82a8e 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -41,6 +41,8 @@
#define HID_MODE_BREDR 0x01
#define HID_MODE_LE 0x02
+#define HID_EXPECTED_REPORT_SIZE 0x02
+
static struct queue *list; /* List of hidhost test cases */
struct emu_cid_data {
@@ -342,6 +344,22 @@ static void hidhost_set_protocol_action(void)
schedule_action_verification(step);
}
+static void hidhost_get_report_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ step->action_status = data->if_hid->get_report(&bdaddr,
+ BTHH_INPUT_REPORT, 1,
+ 20);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("HidHost Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -435,6 +453,24 @@ static struct test_case test_cases[] = {
ACTION_SUCCESS(hidhost_set_protocol_action, NULL),
CALLBACK_HH_MODE(CB_HH_PROTOCOL_MODE, BTHH_OK, HID_MODE_BREDR),
),
+ TEST_CASE_BREDRLE("HidHost GetReport 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(hidhost_get_report_action, NULL),
+ CALLBACK_HHREPORT(CB_HH_GET_REPORT, BTHH_OK,
+ HID_EXPECTED_REPORT_SIZE),
+ ),
};
struct queue *get_hidhost_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index efda577..a01a010 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -437,6 +437,12 @@ static bool match_data(struct step *step)
return false;
}
+ if (exp->callback_result.report_size !=
+ step->callback_result.report_size) {
+ tester_debug("Callback report size don't match");
+ return false;
+ }
+
if (exp->callback_result.pairing_variant !=
step->callback_result.pairing_variant) {
tester_debug("Callback pairing result don't match");
@@ -821,13 +827,26 @@ static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
schedule_callback_call(step);
}
+static void hidhost_get_report_cb(bt_bdaddr_t *bd_addr, bthh_status_t status,
+ uint8_t *report, int size)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_HH_GET_REPORT;
+
+ step->callback_result.status = status;
+ step->callback_result.report_size = size;
+
+ schedule_callback_call(step);
+}
+
static bthh_callbacks_t bthh_callbacks = {
.size = sizeof(bthh_callbacks),
.connection_state_cb = hidhost_connection_state_cb,
.hid_info_cb = hidhost_hid_info_cb,
.protocol_mode_cb = hidhost_protocol_mode_cb,
.idle_time_cb = NULL,
- .get_report_cb = NULL,
+ .get_report_cb = hidhost_get_report_cb,
.virtual_unplug_cb = hidhost_virual_unplug_cb
};
diff --git a/android/tester-main.h b/android/tester-main.h
index eebcc1e..b70d193 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -114,6 +114,12 @@
.callback_result.mode = cb_mode, \
}
+#define CALLBACK_HHREPORT(cb, cb_res, cb_rep_size) { \
+ .callback = cb, \
+ .callback_result.status = cb_res, \
+ .callback_result.report_size = cb_rep_size, \
+ }
+
#define CALLBACK_DEVICE_PROPS(props, prop_cnt) \
CALLBACK_PROPS(CB_BT_REMOTE_DEVICE_PROPERTIES, props, prop_cnt)
@@ -247,6 +253,9 @@ struct bt_action_data {
const char *service_name;
const int flags;
int *fd;
+
+ /* HidHost params */
+ const int report_size;
};
/* bthost's l2cap server setup parameters */
@@ -270,6 +279,7 @@ struct bt_callback_data {
bt_ssp_variant_t pairing_variant;
bthh_protocol_mode_t mode;
+ int report_size;
};
/*
--
1.9.1
---
android/tester-hidhost.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index ad82a8e..84b9f62 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -191,6 +191,7 @@ static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
{
struct emu_cid_data *cid_data = user_data;
uint8_t header = ((uint8_t *) data)[0];
+ struct step *step;
switch (header) {
case HID_GET_REPORT_PROTOCOL:
@@ -212,7 +213,12 @@ static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
case HID_SET_OUTPUT_REPORT:
case HID_SET_FEATURE_REPORT:
case HID_SEND_DATA:
- /* Todo verify step with success */
+ /* Successfully verify sending data step */
+ step = g_new0(struct step, 1);
+
+ step->action_status = BT_STATUS_SUCCESS;
+
+ schedule_action_verification(step);
break;
}
}
@@ -360,6 +366,26 @@ static void hidhost_get_report_action(void)
schedule_action_verification(step);
}
+static void hidhost_set_report_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ char *buf = "010101";
+ bt_bdaddr_t bdaddr;
+ int status;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ /* Successfull result should be verified on the other end (hook) */
+ status = data->if_hid->set_report(&bdaddr, BTHH_INPUT_REPORT, buf);
+ if (status) {
+ struct step *step = g_new0(struct step, 1);
+
+ step->action_status = status;
+ schedule_action_verification(step);
+ }
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("HidHost Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -471,6 +497,24 @@ static struct test_case test_cases[] = {
CALLBACK_HHREPORT(CB_HH_GET_REPORT, BTHH_OK,
HID_EXPECTED_REPORT_SIZE),
),
+ TEST_CASE_BREDRLE("HidHost SetReport 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTING),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(hidhost_set_report_action, NULL),
+ ),
};
struct queue *get_hidhost_tests(void)
--
1.9.1
---
android/tester-hidhost.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 070646e..d9dc04c 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -327,6 +327,21 @@ static void hidhost_get_protocol_action(void)
schedule_action_verification(step);
}
+static void hidhost_set_protocol_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ step->action_status = data->if_hid->set_protocol(&bdaddr,
+ BTHH_REPORT_MODE);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("HidHost Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -403,6 +418,23 @@ static struct test_case test_cases[] = {
ACTION_SUCCESS(hidhost_get_protocol_action, NULL),
CALLBACK_HH_MODE(CB_HH_PROTOCOL_MODE, BTHH_OK, HID_MODE_BREDR),
),
+ TEST_CASE_BREDRLE("HidHost SetProtocol 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(hidhost_set_protocol_action, NULL),
+ CALLBACK_HH_MODE(CB_HH_PROTOCOL_MODE, BTHH_OK, HID_MODE_BREDR),
+ ),
};
struct queue *get_hidhost_tests(void)
--
1.9.1
---
android/tester-hidhost.c | 32 ++++++++++++++++++++++++++++++++
android/tester-main.c | 23 +++++++++++++++++++++--
android/tester-main.h | 4 ++++
3 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 2a61984..f77d5c0 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -294,6 +294,20 @@ static void hidhost_disconnect_action(void)
schedule_action_verification(step);
}
+static void hidhost_virtual_unplug_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ step->action_status = data->if_hid->virtual_unplug(&bdaddr);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
TEST_CASE_BREDRLE("HidHost Init",
ACTION_SUCCESS(dummy_action, NULL),
@@ -335,6 +349,24 @@ static struct test_case test_cases[] = {
CALLBACK_STATE(CB_HH_CONNECTION_STATE,
BTHH_CONN_STATE_DISCONNECTED),
),
+ TEST_CASE_BREDRLE("HidHost VirtualUnplug 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(hidhost_virtual_unplug_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_DISCONNECTED),
+ ),
};
struct queue *get_hidhost_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index 9eb10c7..f1e8a2c 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -781,14 +781,33 @@ static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
schedule_callback_call(step);
}
+static void hidhost_virual_unplug_cb(bt_bdaddr_t *bd_addr, bthh_status_t status)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_HH_VIRTUAL_UNPLUG;
+ step->callback_result.status = status;
+
+ schedule_callback_call(step);
+}
+
+static void hidhost_hid_info_cb(bt_bdaddr_t *bd_addr, bthh_hid_info_t hid)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_HH_HID_INFO;
+
+ schedule_callback_call(step);
+}
+
static bthh_callbacks_t bthh_callbacks = {
.size = sizeof(bthh_callbacks),
.connection_state_cb = hidhost_connection_state_cb,
- .hid_info_cb = NULL,
+ .hid_info_cb = hidhost_hid_info_cb,
.protocol_mode_cb = NULL,
.idle_time_cb = NULL,
.get_report_cb = NULL,
- .virtual_unplug_cb = NULL
+ .virtual_unplug_cb = hidhost_virual_unplug_cb
};
static const btgatt_client_callbacks_t btgatt_client_callbacks = {
diff --git a/android/tester-main.h b/android/tester-main.h
index e2ecaab..7efc966 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -82,6 +82,10 @@
.set_data = data_set, \
}
+#define CALLBACK(cb) { \
+ .callback = cb, \
+ }
+
#define CALLBACK_STATE(cb, cb_res) { \
.callback = cb, \
.callback_result.state = cb_res, \
--
1.9.1
---
android/tester-hidhost.c | 311 ++++++++++++++++++++++++++++++++++++++++++++++-
android/tester-main.c | 13 +-
2 files changed, 322 insertions(+), 2 deletions(-)
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 59ff01c..2a61984 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -20,12 +20,321 @@
#include "emulator/bthost.h"
#include "tester-main.h"
+#include "android/utils.h"
+
+#define HID_GET_REPORT_PROTOCOL 0x60
+#define HID_GET_BOOT_PROTOCOL 0x61
+#define HID_SET_REPORT_PROTOCOL 0x70
+#define HID_SET_BOOT_PROTOCOL 0x71
+
+#define HID_SET_INPUT_REPORT 0x51
+#define HID_SET_OUTPUT_REPORT 0x52
+#define HID_SET_FEATURE_REPORT 0x53
+
+#define HID_SEND_DATA 0xa2
+
+#define HID_GET_INPUT_REPORT 0x49
+#define HID_GET_OUTPUT_REPORT 0x4a
+#define HID_GET_FEATURE_REPORT 0x4b
+
static struct queue *list; /* List of hidhost test cases */
+struct emu_cid_data {
+ const int pdu_len;
+ const void *pdu;
+
+ uint16_t sdp_handle;
+ uint16_t sdp_cid;
+ uint16_t ctrl_handle;
+ uint16_t ctrl_cid;
+ uint16_t intr_handle;
+ uint16_t intr_cid;
+};
+
+struct emu_cid_data cid_data;
+
+static const uint8_t did_req_pdu[] = { 0x06, /* PDU id */
+ 0x00, 0x00, /* Transaction id */
+ 0x00, 0x0f, /* Req length */
+ 0x35, 0x03, /* Attributes length */
+ 0x19, 0x12, 0x00, 0xff, 0xff, 0x35, 0x05, 0x0a, 0x00,
+ 0x00, 0xff, 0xff, 0x00 }; /* no continuation */
+
+static const uint8_t did_rsp_pdu[] = { 0x07, /* PDU id */
+ 0x00, 0x00, /* Transaction id */
+ 0x00, 0x4f, /* Response length */
+ 0x00, 0x4c, /* Attributes length */
+ 0x35, 0x4a, 0x35, 0x48, 0x09, 0x00, 0x00, 0x0a, 0x00,
+ 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35, 0x03, 0x19,
+ 0x12, 0x00, 0x09, 0x00, 0x05, 0x35, 0x03, 0x19, 0x10,
+ 0x02, 0x09, 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19,
+ 0x12, 0x00, 0x09, 0x01, 0x03, 0x09, 0x02, 0x00, 0x09,
+ 0x01, 0x03, 0x09, 0x02, 0x01, 0x09, 0x1d, 0x6b, 0x09,
+ 0x02, 0x02, 0x09, 0x02, 0x46, 0x09, 0x02, 0x03, 0x09,
+ 0x05, 0x0e, 0x09, 0x02, 0x04, 0x28, 0x01, 0x09, 0x02,
+ 0x05, 0x09, 0x00, 0x02,
+ 0x00 }; /* no continuation */
+
+static const uint8_t hid_rsp_pdu[] = { 0x07, /* PDU id */
+ 0x00, 0x01, /* Transaction id */
+ 0x01, 0x71, /* Response length */
+ 0x01, 0x6E, /* Attributes length */
+ 0x36, 0x01, 0x6b, 0x36, 0x01, 0x68, 0x09, 0x00, 0x00,
+ 0x0a, 0x00, 0x01, 0x00, 0x00, 0x09, 0x00, 0x01, 0x35,
+ 0x03, 0x19, 0x11, 0x24, 0x09, 0x00, 0x04, 0x35, 0x0d,
+ 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x11, 0x35,
+ 0x03, 0x19, 0x00, 0x11, 0x09, 0x00, 0x05, 0x35, 0x03,
+ 0x19, 0x10, 0x02, 0x09, 0x00, 0x06, 0x35, 0x09, 0x09,
+ 0x65, 0x6e, 0x09, 0x00, 0x6a, 0x09, 0x01, 0x00, 0x09,
+ 0x00, 0x09, 0x35, 0x08, 0x35, 0x06, 0x19, 0x11, 0x24,
+ 0x09, 0x01, 0x00, 0x09, 0x00, 0x0d, 0x35, 0x0f, 0x35,
+ 0x0d, 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x13,
+ 0x35, 0x03, 0x19, 0x00, 0x11, 0x09, 0x01, 0x00, 0x25,
+ 0x1e, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63, 0x68,
+ 0x20, 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74,
+ 0x68, 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x20, 0x4d,
+ 0x35, 0x35, 0x35, 0x62, 0x09, 0x01, 0x01, 0x25, 0x0f,
+ 0x42, 0x6c, 0x75, 0x65, 0x74, 0x6f, 0x6f, 0x74, 0x68,
+ 0x20, 0x4d, 0x6f, 0x75, 0x73, 0x65, 0x09, 0x01, 0x02,
+ 0x25, 0x08, 0x4c, 0x6f, 0x67, 0x69, 0x74, 0x65, 0x63,
+ 0x68, 0x09, 0x02, 0x00, 0x09, 0x01, 0x00, 0x09, 0x02,
+ 0x01, 0x09, 0x01, 0x11, 0x09, 0x02, 0x02, 0x08, 0x80,
+ 0x09, 0x02, 0x03, 0x08, 0x21, 0x09, 0x02, 0x04, 0x28,
+ 0x01, 0x09, 0x02, 0x05, 0x28, 0x01, 0x09, 0x02, 0x06,
+ 0x35, 0x74, 0x35, 0x72, 0x08, 0x22, 0x25, 0x6e, 0x05,
+ 0x01, 0x09, 0x02, 0xa1, 0x01, 0x85, 0x02, 0x09, 0x01,
+ 0xa1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x08, 0x15,
+ 0x00, 0x25, 0x01, 0x75, 0x01, 0x95, 0x08, 0x81, 0x02,
+ 0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x16, 0x01, 0xf8,
+ 0x26, 0xff, 0x07, 0x75, 0x0c, 0x95, 0x02, 0x81, 0x06,
+ 0x09, 0x38, 0x15, 0x81, 0x25, 0x7f, 0x75, 0x08, 0x95,
+ 0x01, 0x81, 0x06, 0x05, 0x0c, 0x0a, 0x38, 0x02, 0x81,
+ 0x06, 0x05, 0x09, 0x19, 0x09, 0x29, 0x10, 0x15, 0x00,
+ 0x25, 0x01, 0x95, 0x08, 0x75, 0x01, 0x81, 0x02, 0xc0,
+ 0xc0, 0x06, 0x00, 0xff, 0x09, 0x01, 0xa1, 0x01, 0x85,
+ 0x10, 0x75, 0x08, 0x95, 0x06, 0x15, 0x00, 0x26, 0xff,
+ 0x00, 0x09, 0x01, 0x81, 0x00, 0x09, 0x01, 0x91, 0x00,
+ 0xc0, 0x09, 0x02, 0x07, 0x35, 0x08, 0x35, 0x06, 0x09,
+ 0x04, 0x09, 0x09, 0x01, 0x00, 0x09, 0x02, 0x08, 0x28,
+ 0x00, 0x09, 0x02, 0x09, 0x28, 0x01, 0x09, 0x02, 0x0a,
+ 0x28, 0x01, 0x09, 0x02, 0x0b, 0x09, 0x01, 0x00, 0x09,
+ 0x02, 0x0c, 0x09, 0x0c, 0x80, 0x09, 0x02, 0x0d, 0x28,
+ 0x00, 0x09, 0x02, 0x0e, 0x28, 0x01,
+ 0x00 }; /* no continuation */
+
+static void hid_sdp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
+{
+ struct test_data *t_data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+ struct emu_cid_data *cid_data = user_data;
+
+ if (!memcmp(did_req_pdu, data, len)) {
+ bthost_send_cid(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
+ did_rsp_pdu, sizeof(did_rsp_pdu));
+ return;
+ }
+
+ bthost_send_cid(bthost, cid_data->sdp_handle, cid_data->sdp_cid,
+ hid_rsp_pdu, sizeof(hid_rsp_pdu));
+}
+static void hid_sdp_search_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.sdp_handle = handle;
+ cid_data.sdp_cid = cid;
+
+ bthost_add_cid_hook(bthost, handle, cid, hid_sdp_cid_hook_cb,
+ &cid_data);
+}
+
+static void hid_prepare_reply_protocol_mode(struct emu_cid_data *cid_data)
+{
+ struct test_data *t_data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+ uint8_t pdu[2] = { 0, 0 };
+ uint16_t pdu_len = 0;
+
+ pdu_len = 2;
+ pdu[0] = 0xa0;
+ pdu[1] = 0x00;
+
+ bthost_send_cid(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
+ (void *)pdu, pdu_len);
+}
+
+static void hid_prepare_reply_report(struct emu_cid_data *cid_data)
+{
+ struct test_data *t_data = tester_get_data();
+ struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+ uint8_t pdu[3] = { 0, 0, 0 };
+ uint16_t pdu_len = 0;
+
+ pdu_len = 3;
+ pdu[0] = 0xa2;
+ pdu[1] = 0x01;
+ pdu[2] = 0x00;
+
+ bthost_send_cid(bthost, cid_data->ctrl_handle, cid_data->ctrl_cid,
+ (void *)pdu, pdu_len);
+}
+
+static void hid_ctrl_cid_hook_cb(const void *data, uint16_t len,
+ void *user_data)
+{
+ struct emu_cid_data *cid_data = user_data;
+ uint8_t header = ((uint8_t *) data)[0];
+
+ switch (header) {
+ case HID_GET_REPORT_PROTOCOL:
+ case HID_GET_BOOT_PROTOCOL:
+ case HID_SET_REPORT_PROTOCOL:
+ case HID_SET_BOOT_PROTOCOL:
+ hid_prepare_reply_protocol_mode(cid_data);
+ break;
+ case HID_GET_INPUT_REPORT:
+ case HID_GET_OUTPUT_REPORT:
+ case HID_GET_FEATURE_REPORT:
+ hid_prepare_reply_report(cid_data);
+ break;
+ /*
+ * HID device doesnot reply for this commads, so reaching pdu's
+ * to hid device means assuming test passed
+ */
+ case HID_SET_INPUT_REPORT:
+ case HID_SET_OUTPUT_REPORT:
+ case HID_SET_FEATURE_REPORT:
+ case HID_SEND_DATA:
+ /* Todo verify step with success */
+ break;
+ }
+}
+static void hid_ctrl_connect_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.ctrl_handle = handle;
+ cid_data.ctrl_cid = cid;
+
+ bthost_add_cid_hook(bthost, handle, cid, hid_ctrl_cid_hook_cb,
+ &cid_data);
+}
+
+static void hid_intr_cid_hook_cb(const void *data, uint16_t len,
+ void *user_data)
+{
+ uint8_t header = ((uint8_t *) data)[0];
+
+ switch (header) {
+ case HID_SEND_DATA:
+ /* Todo verify step with success */
+ break;
+ }
+}
+static void hid_intr_connect_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.intr_handle = handle;
+ cid_data.intr_cid = cid;
+
+ bthost_add_cid_hook(bthost, handle, cid, hid_intr_cid_hook_cb,
+ &cid_data);
+}
+
+/* Emulate SDP (PSM = 1) */
+static struct emu_set_l2cap_data l2cap_setup_sdp_data = {
+ .psm = 1,
+ .func = hid_sdp_search_cb,
+ .user_data = NULL,
+};
+
+/* Emulate Control Channel (PSM = 17) */
+static struct emu_set_l2cap_data l2cap_setup_cc_data = {
+ .psm = 17,
+ .func = hid_ctrl_connect_cb,
+ .user_data = NULL,
+};
+
+/* Emulate Interrupt Channel (PSM = 19) */
+static struct emu_set_l2cap_data l2cap_setup_ic_data = {
+ .psm = 19,
+ .func = hid_intr_connect_cb,
+ .user_data = NULL,
+};
+
+static void hidhost_connect_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ step->action_status = data->if_hid->connect(&bdaddr);
+
+ schedule_action_verification(step);
+}
+
+static void hidhost_disconnect_action(void)
+{
+ struct test_data *data = tester_get_data();
+ const uint8_t *hid_addr = hciemu_get_client_bdaddr(data->hciemu);
+ struct step *step = g_new0(struct step, 1);
+ bt_bdaddr_t bdaddr;
+
+ bdaddr2android((const bdaddr_t *) hid_addr, &bdaddr);
+
+ step->action_status = data->if_hid->disconnect(&bdaddr);
+
+ schedule_action_verification(step);
+}
+
static struct test_case test_cases[] = {
- TEST_CASE_BREDRLE("Hidhost Init",
+ TEST_CASE_BREDRLE("HidHost Init",
ACTION_SUCCESS(dummy_action, NULL),
),
+ TEST_CASE_BREDRLE("HidHost 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(bluetooth_disable_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_DISCONNECTED),
+ CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+ ),
+ TEST_CASE_BREDRLE("HidHost 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_sdp_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_cc_data),
+ ACTION_SUCCESS(emu_add_l2cap_server_action,
+ &l2cap_setup_ic_data),
+ ACTION_SUCCESS(hidhost_connect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_CONNECTED),
+ ACTION_SUCCESS(hidhost_disconnect_action, NULL),
+ CALLBACK_STATE(CB_HH_CONNECTION_STATE,
+ BTHH_CONN_STATE_DISCONNECTED),
+ ),
};
struct queue *get_hidhost_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index abef822..9eb10c7 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -770,9 +770,20 @@ static bt_callbacks_t bt_callbacks = {
.le_test_mode_cb = NULL
};
+static void hidhost_connection_state_cb(bt_bdaddr_t *bd_addr,
+ bthh_connection_state_t state)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_HH_CONNECTION_STATE;
+ step->callback_result.state = state;
+
+ schedule_callback_call(step);
+}
+
static bthh_callbacks_t bthh_callbacks = {
.size = sizeof(bthh_callbacks),
- .connection_state_cb = NULL,
+ .connection_state_cb = hidhost_connection_state_cb,
.hid_info_cb = NULL,
.protocol_mode_cb = NULL,
.idle_time_cb = NULL,
--
1.9.1