This allows to pass additional parameter describing wheter to set
flags parameter in advertising data.
This is needed to make device discoverable.
---
android/android-tester.c | 2 +-
emulator/bthost.c | 21 ++++++++++++++++++++-
emulator/bthost.h | 3 ++-
tools/l2cap-tester.c | 2 +-
tools/mgmt-tester.c | 2 +-
tools/smp-tester.c | 2 +-
6 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index eb5c513..ff14fc8 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -701,7 +701,7 @@ static void setup_powered_emulated_remote(void)
bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/emulator/bthost.c b/emulator/bthost.c
index 298edcf..b30999b 100644
--- a/emulator/bthost.c
+++ b/emulator/bthost.c
@@ -747,6 +747,8 @@ static void evt_cmd_complete(struct bthost *bthost, const void *data,
break;
case BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY:
break;
+ case BT_HCI_CMD_LE_SET_ADV_DATA:
+ break;
default:
printf("Unhandled cmd_complete opcode 0x%04x\n", opcode);
break;
@@ -2072,7 +2074,7 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
}
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable, uint8_t flags)
{
struct bt_hci_cmd_le_set_adv_parameters cp;
@@ -2080,6 +2082,23 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
&cp, sizeof(cp));
+ if (flags) {
+ struct bt_hci_cmd_le_set_adv_data adv_cp;
+
+ memset(adv_cp.data, 0, 31);
+
+ adv_cp.data[0] = 0x02; /* Field length */
+ adv_cp.data[1] = 0x01; /* Flags */
+ adv_cp.data[2] = flags;
+
+ adv_cp.data[3] = 0x00; /* Field terminator */
+
+ adv_cp.len = 1 + adv_cp.data[0];
+
+ send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
+ sizeof(adv_cp));
+ }
+
send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
}
diff --git a/emulator/bthost.h b/emulator/bthost.h
index b00bcd6..4a7e2bd 100644
--- a/emulator/bthost.h
+++ b/emulator/bthost.h
@@ -70,7 +70,8 @@ bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
-void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
+void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
+ uint8_t flags);
void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
index 79362b2..6841341 100644
--- a/tools/l2cap-tester.c
+++ b/tools/l2cap-tester.c
@@ -535,7 +535,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_cmd_complete, user_data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 16c3656..c813314 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -2946,7 +2946,7 @@ static void setup_bthost(void)
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_cmd_complete, data);
if (data->hciemu_type == HCIEMU_TYPE_LE)
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
else
bthost_write_scan_enable(bthost, 0x03);
}
diff --git a/tools/smp-tester.c b/tools/smp-tester.c
index 12e0bed..c9639e6 100644
--- a/tools/smp-tester.c
+++ b/tools/smp-tester.c
@@ -411,7 +411,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
- bthost_set_adv_enable(bthost, 0x01);
+ bthost_set_adv_enable(bthost, 0x01, 0x00);
}
static void setup_powered_client(const void *test_data)
--
1.9.1
Hi Jakub,
On Friday 18 of July 2014 11:50:13 Jakub Tyszkowski wrote:
> This allows to pass additional parameter describing wheter to set
> flags parameter in advertising data.
>
> This is needed to make device discoverable.
> ---
> android/android-tester.c | 2 +-
> emulator/bthost.c | 21 ++++++++++++++++++++-
> emulator/bthost.h | 3 ++-
> tools/l2cap-tester.c | 2 +-
> tools/mgmt-tester.c | 2 +-
> tools/smp-tester.c | 2 +-
> 6 files changed, 26 insertions(+), 6 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index eb5c513..ff14fc8 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -701,7 +701,7 @@ static void setup_powered_emulated_remote(void)
> bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
>
> if (data->hciemu_type == HCIEMU_TYPE_LE)
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> else
> bthost_write_scan_enable(bthost, 0x03);
> }
> diff --git a/emulator/bthost.c b/emulator/bthost.c
> index 298edcf..b30999b 100644
> --- a/emulator/bthost.c
> +++ b/emulator/bthost.c
> @@ -747,6 +747,8 @@ static void evt_cmd_complete(struct bthost *bthost, const void *data,
> break;
> case BT_HCI_CMD_LE_LTK_REQ_NEG_REPLY:
> break;
> + case BT_HCI_CMD_LE_SET_ADV_DATA:
> + break;
> default:
> printf("Unhandled cmd_complete opcode 0x%04x\n", opcode);
> break;
> @@ -2072,7 +2074,7 @@ void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan)
> send_command(bthost, BT_HCI_CMD_WRITE_SCAN_ENABLE, &scan, 1);
> }
>
> -void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
> +void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable, uint8_t flags)
> {
> struct bt_hci_cmd_le_set_adv_parameters cp;
>
> @@ -2080,6 +2082,23 @@ void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable)
> send_command(bthost, BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
> &cp, sizeof(cp));
>
> + if (flags) {
> + struct bt_hci_cmd_le_set_adv_data adv_cp;
> +
> + memset(adv_cp.data, 0, 31);
> +
> + adv_cp.data[0] = 0x02; /* Field length */
> + adv_cp.data[1] = 0x01; /* Flags */
> + adv_cp.data[2] = flags;
> +
> + adv_cp.data[3] = 0x00; /* Field terminator */
> +
> + adv_cp.len = 1 + adv_cp.data[0];
> +
> + send_command(bthost, BT_HCI_CMD_LE_SET_ADV_DATA, &adv_cp,
> + sizeof(adv_cp));
> + }
> +
> send_command(bthost, BT_HCI_CMD_LE_SET_ADV_ENABLE, &enable, 1);
> }
>
> diff --git a/emulator/bthost.h b/emulator/bthost.h
> index b00bcd6..4a7e2bd 100644
> --- a/emulator/bthost.h
> +++ b/emulator/bthost.h
> @@ -70,7 +70,8 @@ bool bthost_l2cap_req(struct bthost *bthost, uint16_t handle, uint8_t req,
>
> void bthost_write_scan_enable(struct bthost *bthost, uint8_t scan);
>
> -void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable);
> +void bthost_set_adv_enable(struct bthost *bthost, uint8_t enable,
> + uint8_t flags);
>
> void bthost_write_ssp_mode(struct bthost *bthost, uint8_t mode);
>
> diff --git a/tools/l2cap-tester.c b/tools/l2cap-tester.c
> index 79362b2..6841341 100644
> --- a/tools/l2cap-tester.c
> +++ b/tools/l2cap-tester.c
> @@ -535,7 +535,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
> bthost = hciemu_client_get_host(data->hciemu);
> bthost_set_cmd_complete_cb(bthost, client_cmd_complete, user_data);
> if (data->hciemu_type == HCIEMU_TYPE_LE)
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> else
> bthost_write_scan_enable(bthost, 0x03);
> }
> diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
> index 16c3656..c813314 100644
> --- a/tools/mgmt-tester.c
> +++ b/tools/mgmt-tester.c
> @@ -2946,7 +2946,7 @@ static void setup_bthost(void)
> bthost = hciemu_client_get_host(data->hciemu);
> bthost_set_cmd_complete_cb(bthost, client_cmd_complete, data);
> if (data->hciemu_type == HCIEMU_TYPE_LE)
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> else
> bthost_write_scan_enable(bthost, 0x03);
> }
> diff --git a/tools/smp-tester.c b/tools/smp-tester.c
> index 12e0bed..c9639e6 100644
> --- a/tools/smp-tester.c
> +++ b/tools/smp-tester.c
> @@ -411,7 +411,7 @@ static void setup_powered_client_callback(uint8_t status, uint16_t length,
>
> bthost = hciemu_client_get_host(data->hciemu);
> bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
> - bthost_set_adv_enable(bthost, 0x01);
> + bthost_set_adv_enable(bthost, 0x01, 0x00);
> }
>
> static void setup_powered_client(const void *test_data)
>
All patches applied, thanks.
--
Best regards,
Szymon Janc
Those properties requests should fails as those are adapter specific
ones and does not apply to remote devices.
---
android/tester-bluetooth.c | 107 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 107 insertions(+)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 497691f..91c5a1a 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -86,6 +86,10 @@ static bt_property_t prop_emu_bonded_devs = {
static bt_bdaddr_t emu_remote_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
};
+static struct bt_action_data prop_emu_ble_remote_bdaddr_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_BDADDR,
+};
static uint32_t emu_remote_type_val = BT_DEVICE_DEVTYPE_BLE;
static bt_property_t prop_emu_ble_remote_tod_prop = {
@@ -151,6 +155,31 @@ static struct bt_action_data prop_emu_ble_remote_timestamp_req = {
.prop_type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
};
+static struct bt_action_data prop_emu_ble_remote_scan_mode_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+};
+
+static struct bt_action_data prop_emu_ble_remote_bondeddev_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+};
+
+static struct bt_action_data prop_emu_ble_remote_disctimeout_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+};
+
+static struct bt_action_data prop_emu_ble_remote_verinfo_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_REMOTE_VERSION_INFO,
+};
+
+static struct bt_action_data prop_emu_ble_remote_fname_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_REMOTE_FRIENDLY_NAME,
+};
+
static bt_property_t prop_emu_default_set[] = {
{ BT_PROPERTY_BDADDR, sizeof(emu_bdaddr_val), NULL },
{ BT_PROPERTY_BDNAME, sizeof(emu_bdname_val) - 1, &emu_bdname_val },
@@ -565,6 +594,84 @@ static struct test_case test_cases[] = {
&prop_emu_ble_remote_timestamp_req),
CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_timestamp_prop, 1),
),
+ TEST_CASE("Bluetooth Device Get BDADDR - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_get_device_prop_action,
+ &prop_emu_ble_remote_bdaddr_req),
+ ),
+ TEST_CASE("Bluetooth Device Get SCAN_MODE - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_get_device_prop_action,
+ &prop_emu_ble_remote_scan_mode_req),
+ ),
+ TEST_CASE("Bluetooth Device Get BONDED_DEVICES - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_get_device_prop_action,
+ &prop_emu_ble_remote_bondeddev_req),
+ ),
+ TEST_CASE("Bluetooth Device Get DISCOVERY_TIMEOUT - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_get_device_prop_action,
+ &prop_emu_ble_remote_disctimeout_req),
+ ),
+ TEST_CASE("Bluetooth Device Get VERSION_INFO - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_get_device_prop_action,
+ &prop_emu_ble_remote_verinfo_req),
+ ),
+ TEST_CASE("Bluetooth Device Get FRIENDLY_NAME - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_get_device_prop_action,
+ &prop_emu_ble_remote_fname_req),
+ ),
};
struct queue *get_bluetooth_tests(void)
--
1.9.1
---
android/tester-bluetooth.c | 23 +++++++++++++++++++++++
android/tester-main.c | 21 +++++++++++++++++++++
android/tester-main.h | 2 ++
3 files changed, 46 insertions(+)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 91c5a1a..480c92e 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -175,9 +175,16 @@ static struct bt_action_data prop_emu_ble_remote_verinfo_req = {
.prop_type = BT_PROPERTY_REMOTE_VERSION_INFO,
};
+static const char prop_test_fname_val[] = "FriendlyTestName";
+static bt_property_t prop_emu_ble_remote_fname_prop = {
+ .type = BT_PROPERTY_REMOTE_FRIENDLY_NAME,
+ .val = &prop_test_fname_val,
+ .len = sizeof(prop_test_fname_val) - 1,
+};
static struct bt_action_data prop_emu_ble_remote_fname_req = {
.addr = &emu_remote_bdaddr_val,
.prop_type = BT_PROPERTY_REMOTE_FRIENDLY_NAME,
+ .prop = &prop_emu_ble_remote_fname_prop,
};
static bt_property_t prop_emu_default_set[] = {
@@ -672,6 +679,22 @@ static struct test_case test_cases[] = {
ACTION_FAIL(bt_get_device_prop_action,
&prop_emu_ble_remote_fname_req),
),
+ TEST_CASE("Bluetooth Device Set FRIENDLY_NAME - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_set_device_prop_action,
+ &prop_emu_ble_remote_fname_req),
+ ACTION_SUCCESS(bt_get_device_prop_action,
+ &prop_emu_ble_remote_fname_req),
+ CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_fname_prop, 1),
+ ),
};
struct queue *get_bluetooth_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index 59762bb..4c7a5e7 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -1078,6 +1078,27 @@ void bt_get_device_prop_action(void)
verify_step(&step, NULL);
}
+void bt_set_device_prop_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *current_data_step = queue_peek_head(data->steps);
+ struct bt_action_data *action_data = current_data_step->set_data;
+ struct step step;
+
+ if (!action_data) {
+ tester_warn("No arguments for 'set remote device prop' req.");
+ tester_test_failed();
+ return;
+ }
+
+ memset(&step, 0, sizeof(step));
+ step.action_status = data->if_bluetooth->set_remote_device_property(
+ action_data->addr,
+ action_data->prop);
+
+ verify_step(&step, NULL);
+}
+
static void generic_test_function(const void *test_data)
{
struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index ef8c3d5..2f6252d 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -181,6 +181,7 @@ struct bt_action_data {
/* Remote props action arguments */
int prop_type;
+ bt_property_t *prop;
};
/*
@@ -239,3 +240,4 @@ void bt_start_discovery_action(void);
void bt_cancel_discovery_action(void);
void bt_get_device_props_action(void);
void bt_get_device_prop_action(void);
+void bt_set_device_prop_action(void);
--
1.9.1
Those tests are now in the newer tester.
---
android/android-tester.c | 438 -----------------------------------------------
1 file changed, 438 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index ff14fc8..2b72bd8 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -2163,289 +2163,6 @@ static void test_dummy(const void *test_data)
tester_test_passed();
}
-static void test_discovery_start_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- bt_status_t status;
-
- init_test_conditions(data);
-
- status = data->if_bluetooth->start_discovery();
- check_expected_status(status);
-}
-
-static void test_discovery_stop_done(const void *test_data)
-{
- struct test_data *data = tester_get_data();
- bt_status_t status;
-
- init_test_conditions(data);
-
- status = data->if_bluetooth->cancel_discovery();
- check_expected_status(status);
-}
-
-static void test_discovery_stop_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_discovery_start_done(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_discovery_device_found(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprops_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_bdname_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_uuids_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_cod_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_tod_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_rssi_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_timestamp_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_bdaddr_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_servrec_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_scanmode_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_bondeddev_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_disctimeout_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_verinfo_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_getprop_fname_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_fname_success(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_bdname_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_uuids_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_cod_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_tod_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_rssi_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_timestamp_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_bdaddr_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_servrec_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_scanmode_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_bondeddev_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
-static void test_dev_setprop_disctimeout_fail(const void *test_data)
-{
- struct test_data *data = tester_get_data();
-
- init_test_conditions(data);
-
- data->if_bluetooth->start_discovery();
-}
-
static void bond_device_auth_fail_callback(uint16_t index, uint16_t length,
const void *param,
void *user_data)
@@ -3659,161 +3376,6 @@ int main(int argc, char *argv[])
tester_init(&argc, &argv);
- test_bredrle("Bluetooth BR/EDR Discovery Start - Success",
- &bluetooth_discovery_start_success_test,
- setup_enabled_adapter,
- test_discovery_start_success, teardown);
-
- test_bredrle("Bluetooth BR/EDR Discovery Start - Success 2",
- &bluetooth_discovery_start_success2_test,
- setup_enabled_adapter,
- test_discovery_start_done, teardown);
-
- test_bredrle("Bluetooth BR/EDR Discovery Stop - Success",
- &bluetooth_discovery_stop_success_test,
- setup_enabled_adapter,
- test_discovery_stop_success, teardown);
-
- test_bredrle("Bluetooth BR/EDR Discovery Stop - Success 2",
- &bluetooth_discovery_stop_success2_test,
- setup_enabled_adapter,
- test_discovery_stop_done, teardown);
-
- test_bredr("Bluetooth BR/EDR Discovery Device Found",
- &bluetooth_discovery_device_found_test,
- setup_enabled_adapter,
- test_discovery_device_found, teardown);
-
- test_bredr("Bluetooth Device Get Props - Success",
- &bt_dev_getprops_success_test,
- setup_enabled_adapter,
- test_dev_getprops_success, teardown);
-
- test_bredr("Bluetooth Device Get BDNAME - Success",
- &bt_dev_getprop_bdname_success_test,
- setup_enabled_adapter,
- test_dev_getprop_bdname_success, teardown);
-
- test_bredr("Bluetooth Device Get UUIDS - Success",
- &bt_dev_getprop_uuids_success_test,
- setup_enabled_adapter,
- test_dev_getprop_uuids_success, teardown);
-
- test_bredr("Bluetooth Device Get COD - Success",
- &bt_dev_getprop_cod_success_test,
- setup_enabled_adapter,
- test_dev_getprop_cod_success, teardown);
-
- test_bredr("Bluetooth Device Get TOD - Success",
- &bt_dev_getprop_tod_success_test,
- setup_enabled_adapter,
- test_dev_getprop_tod_success, teardown);
-
- test_bredr("Bluetooth Device Get RSSI - Success",
- &bt_dev_getprop_rssi_success_test,
- setup_enabled_adapter,
- test_dev_getprop_rssi_success, teardown);
-
- test_bredr("Bluetooth Device Get TIMESTAMP - Success",
- &bt_dev_getprop_timpestamp_success_test,
- setup_enabled_adapter,
- test_dev_getprop_timestamp_success, teardown);
-
- test_bredr("Bluetooth Device Get BDADDR - Fail",
- &bt_dev_getprop_bdaddr_fail_test,
- setup_enabled_adapter,
- test_dev_getprop_bdaddr_fail, teardown);
-
- test_bredr("Bluetooth Device Get SERVICE_RECORD - Fail",
- &bt_dev_getprop_servrec_fail_test,
- setup_enabled_adapter,
- test_dev_getprop_servrec_fail, teardown);
-
- test_bredr("Bluetooth Device Get SCAN_MODE - Fail",
- &bt_dev_getprop_scanmode_fail_test,
- setup_enabled_adapter,
- test_dev_getprop_scanmode_fail, teardown);
-
- test_bredr("Bluetooth Device Get BONDED_DEVICES - Fail",
- &bt_dev_getprop_bondeddev_fail_test,
- setup_enabled_adapter,
- test_dev_getprop_bondeddev_fail, teardown);
-
- test_bredr("Bluetooth Device Get DISCOVERY_TIMEOUT - Fail",
- &bt_dev_getprop_disctimeout_fail_test,
- setup_enabled_adapter,
- test_dev_getprop_disctimeout_fail, teardown);
-
- test_bredr("Bluetooth Device Get VERSION_INFO - Fail",
- &bt_dev_getprop_verinfo_fail_test,
- setup_enabled_adapter,
- test_dev_getprop_verinfo_fail, teardown);
-
- test_bredr("Bluetooth Device Get FRIENDLY_NAME - Fail",
- &bt_dev_getprop_fname_fail_test,
- setup_enabled_adapter,
- test_dev_getprop_fname_fail, teardown);
-
- test_bredr("Bluetooth Device Set FRIENDLY_NAME - Success",
- &bt_dev_setprop_fname_success_test,
- setup_enabled_adapter,
- test_dev_setprop_fname_success, teardown);
-
- test_bredr("Bluetooth Device Set BDNAME - Fail",
- &bt_dev_setprop_bdname_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_bdname_fail, teardown);
-
- test_bredr("Bluetooth Device Set UUIDS - Fail",
- &bt_dev_setprop_uuids_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_uuids_fail, teardown);
-
- test_bredr("Bluetooth Device Set COD - Fail",
- &bt_dev_setprop_cod_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_cod_fail, teardown);
-
- test_bredr("Bluetooth Device Set TOD - Fail",
- &bt_dev_setprop_tod_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_tod_fail, teardown);
-
- test_bredr("Bluetooth Device Set RSSI - Fail",
- &bt_dev_setprop_rssi_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_rssi_fail, teardown);
-
- test_bredr("Bluetooth Device Set TIMESTAMP - Fail",
- &bt_dev_setprop_timpestamp_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_timestamp_fail, teardown);
-
- test_bredr("Bluetooth Device Set BDADDR - Fail",
- &bt_dev_setprop_bdaddr_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_bdaddr_fail, teardown);
-
- test_bredr("Bluetooth Device Set SERVICE_RECORD - Fail",
- &bt_dev_setprop_servrec_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_servrec_fail, teardown);
-
- test_bredr("Bluetooth Device Set SCAN_MODE - Fail",
- &bt_dev_setprop_scanmode_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_scanmode_fail, teardown);
-
- test_bredr("Bluetooth Device Set BONDED_DEVICES - Fail",
- &bt_dev_setprop_bondeddev_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_bondeddev_fail, teardown);
-
- test_bredr("Bluetooth Device Set DISCOVERY_TIMEOUT - Fail",
- &bt_dev_setprop_disctimeout_fail_test,
- setup_enabled_adapter,
- test_dev_setprop_disctimeout_fail, teardown);
-
test_bredr("Bluetooth Create Bond PIN - Success",
&bt_bond_create_pin_success_test,
setup_enabled_adapter,
--
1.9.1
Those set property requests should fail as they request to set remotes
adapter properties.
---
android/tester-bluetooth.c | 205 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 205 insertions(+)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 480c92e..c36b507 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -228,6 +228,11 @@ static bt_property_t prop_test_bdname = {
.val = test_bdname,
.len = sizeof(test_bdname) - 1,
};
+static struct bt_action_data prop_test_ble_remote_bdname_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_BDNAME,
+ .prop = &prop_test_bdname,
+};
static bt_scan_mode_t test_scan_mode_connectable_discoverable =
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
@@ -243,6 +248,11 @@ static bt_property_t prop_test_disctimeout = {
.val = &test_disctimeout_val,
.len = sizeof(test_disctimeout_val),
};
+static struct bt_action_data prop_test_ble_remote_disc_timeout_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+ .prop = &prop_test_disctimeout,
+};
static unsigned char test_uuids_val[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -252,6 +262,11 @@ static bt_property_t prop_test_uuid = {
.val = &test_uuids_val,
.len = sizeof(test_uuids_val),
};
+static struct bt_action_data prop_test_ble_remote_uuids_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_UUIDS,
+ .prop = &prop_test_uuid,
+};
static uint32_t test_cod_val = 0;
static bt_property_t prop_test_cod = {
@@ -259,6 +274,11 @@ static bt_property_t prop_test_cod = {
.val = &test_cod_val,
.len = sizeof(test_cod_val),
};
+static struct bt_action_data prop_test_ble_remote_cod_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_CLASS_OF_DEVICE,
+ .prop = &prop_test_cod,
+};
static uint32_t test_tod_val = BT_DEVICE_DEVTYPE_BLE;
static bt_property_t prop_test_tod = {
@@ -266,6 +286,11 @@ static bt_property_t prop_test_tod = {
.val = &test_tod_val,
.len = sizeof(test_tod_val),
};
+static struct bt_action_data prop_test_ble_remote_tod_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_TYPE_OF_DEVICE,
+ .prop = &prop_test_tod,
+};
static int32_t test_remote_rssi_val = -9;
static bt_property_t prop_test_remote_rssi = {
@@ -273,6 +298,11 @@ static bt_property_t prop_test_remote_rssi = {
.val = &test_remote_rssi_val,
.len = sizeof(test_remote_rssi_val),
};
+static struct bt_action_data prop_test_ble_remote_rssi_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_REMOTE_RSSI,
+ .prop = &prop_test_remote_rssi,
+};
static bt_service_record_t test_srvc_record_val = {
.uuid = { {0x00} },
@@ -284,6 +314,11 @@ static bt_property_t prop_test_srvc_record = {
.val = &test_srvc_record_val,
.len = sizeof(test_srvc_record_val),
};
+static struct bt_action_data prop_test_ble_remote_srvc_record_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_SERVICE_RECORD,
+ .prop = &prop_test_srvc_record,
+};
static bt_bdaddr_t test_bdaddr_val = {
.address = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
@@ -293,6 +328,11 @@ static bt_property_t prop_test_bdaddr = {
.val = &test_bdaddr_val,
.len = sizeof(test_bdaddr_val),
};
+static struct bt_action_data prop_test_ble_remote_bdaddr_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_BDADDR,
+ .prop = &prop_test_bdaddr,
+};
static bt_scan_mode_t setprop_scan_mode_conn_val = BT_SCAN_MODE_CONNECTABLE;
@@ -308,6 +348,11 @@ static bt_property_t prop_test_scan_mode_none = {
.val = &test_scan_mode_none_val,
.len = sizeof(test_scan_mode_none_val),
};
+static struct bt_action_data prop_test_ble_remote_scanmode_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+ .prop = &prop_test_scan_mode_none,
+};
static bt_bdaddr_t test_bonded_dev_addr_val = {
.address = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05 },
@@ -317,6 +362,23 @@ static bt_property_t prop_test_bonded_dev_addr = {
.val = &test_bonded_dev_addr_val,
.len = sizeof(test_bonded_dev_addr_val),
};
+static struct bt_action_data prop_test_ble_bonded_dev_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
+ .prop = &prop_test_bonded_dev_addr,
+};
+
+static long test_remote_timestamp_val = 0x7f3d79965adf;
+static bt_property_t prop_test_ble_remote_timestamp_prop = {
+ .type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
+ .val = &test_remote_timestamp_val,
+ .len = sizeof(test_remote_timestamp_val),
+};
+static struct bt_action_data prop_test_ble_remote_timestamp_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
+ .prop = &prop_test_ble_remote_timestamp_prop,
+};
static struct test_case test_cases[] = {
TEST_CASE("Bluetooth Init",
@@ -695,6 +757,149 @@ static struct test_case test_cases[] = {
&prop_emu_ble_remote_fname_req),
CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_fname_prop, 1),
),
+ TEST_CASE("Bluetooth Device Set BDNAME - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_bdname_req),
+ ),
+ TEST_CASE("Bluetooth Device Set UUIDS - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_uuids_req),
+ ),
+ TEST_CASE("Bluetooth Device Set COD - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_cod_req),
+ ),
+ TEST_CASE("Bluetooth Device Set TOD - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_tod_req),
+ ),
+ TEST_CASE("Bluetooth Device Set RSSI - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_rssi_req),
+ ),
+ TEST_CASE("Bluetooth Device Set TIMESTAMP - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_timestamp_req),
+ ),
+ TEST_CASE("Bluetooth Device Set BDADDR - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_bdaddr_req),
+ ),
+ TEST_CASE("Bluetooth Device Set SERVICE_RECORD - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_srvc_record_req),
+ ),
+ TEST_CASE("Bluetooth Device Set SCAN_MODE - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_scanmode_req),
+ ),
+ TEST_CASE("Bluetooth Device Set BONDED_DEVICES - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_bonded_dev_req),
+ ),
+ TEST_CASE("Bluetooth Device Set DISCOVERY_TIMEOUT - Fail",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_FAIL(bt_set_device_prop_action,
+ &prop_test_ble_remote_disc_timeout_req),
+ ),
};
struct queue *get_bluetooth_tests(void)
--
1.9.1
Action (HAL api call) result is always status or file descriptor.
Integer value is enough to hold both so it replaced the truct.
---
android/tester-main.c | 20 ++++++++++----------
android/tester-main.h | 13 +++----------
2 files changed, 13 insertions(+), 20 deletions(-)
diff --git a/android/tester-main.c b/android/tester-main.c
index f5ac281..dde04b9 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -407,7 +407,7 @@ static bool match_data(struct step *step)
return false;
}
- if (exp->action_result.status != step->action_result.status) {
+ if (exp->action_status != step->action_status) {
tester_debug("Action status don't match");
return false;
}
@@ -916,10 +916,10 @@ static void emu_connectable_complete(uint16_t opcode, uint8_t status,
if (status) {
tester_warn("Emulated remote setup failed.");
- step.action_result.status = BT_STATUS_FAIL;
+ step.action_status = BT_STATUS_FAIL;
} else {
tester_warn("Emulated remote setup done.");
- step.action_result.status = BT_STATUS_SUCCESS;
+ step.action_status = BT_STATUS_SUCCESS;
}
verify_step(&step, NULL);
@@ -956,7 +956,7 @@ void bluetooth_enable_action(void)
struct step step;
memset(&step, 0, sizeof(step));
- step.action_result.status = data->if_bluetooth->enable();
+ step.action_status = data->if_bluetooth->enable();
verify_step(&step, NULL);
}
@@ -967,7 +967,7 @@ void bluetooth_disable_action(void)
struct step step;
memset(&step, 0, sizeof(step));
- step.action_result.status = data->if_bluetooth->disable();
+ step.action_status = data->if_bluetooth->disable();
verify_step(&step, NULL);
}
@@ -988,7 +988,7 @@ void bt_set_property_action(void)
prop = (bt_property_t *)current_data_step->set_data;
memset(&step, 0, sizeof(step));
- step.action_result.status = data->if_bluetooth->set_adapter_property(
+ step.action_status = data->if_bluetooth->set_adapter_property(
prop);
verify_step(&step, NULL);
@@ -1010,7 +1010,7 @@ void bt_get_property_action(void)
prop = (bt_property_t *)current_data_step->set_data;
memset(&step, 0, sizeof(step));
- step.action_result.status = data->if_bluetooth->get_adapter_property(
+ step.action_status = data->if_bluetooth->get_adapter_property(
prop->type);
verify_step(&step, NULL);
@@ -1021,7 +1021,7 @@ void bt_start_discovery_action(void)
struct test_data *data = tester_get_data();
struct step step;
- step.action_result.status = data->if_bluetooth->start_discovery();
+ step.action_status = data->if_bluetooth->start_discovery();
verify_step(&step, NULL);
}
@@ -1032,7 +1032,7 @@ void bt_cancel_discovery_action(void)
struct step step;
memset(&step, 0, sizeof(step));
- step.action_result.status = data->if_bluetooth->cancel_discovery();
+ step.action_status = data->if_bluetooth->cancel_discovery();
verify_step(&step, NULL);
}
@@ -1050,7 +1050,7 @@ void bt_get_device_props_action(void)
}
memset(&step, 0, sizeof(step));
- step.action_result.status =
+ step.action_status =
data->if_bluetooth->get_remote_device_properties(
current_data_step->set_data);
diff --git a/android/tester-main.h b/android/tester-main.h
index b81487d..920f82c 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -57,13 +57,13 @@
}
#define ACTION_SUCCESS(act_fun, data_set) { \
- .action_result.status = BT_STATUS_SUCCESS, \
+ .action_status = BT_STATUS_SUCCESS, \
.action = act_fun, \
.set_data = data_set, \
}
#define ACTION_FAIL(act_fun, data_set) { \
- .action_result.status = BT_STATUS_FAIL, \
+ .action_status = BT_STATUS_FAIL, \
.action = act_fun, \
.set_data = data_set, \
}
@@ -174,13 +174,6 @@ struct test_data {
};
/*
- * Struct of data to check within step action.
- */
-struct bt_action_data {
- uint8_t status;
-};
-
-/*
* Callback data structure should be enhanced with data
* returned by callbacks. It's used for test case step
* matching with expected step data.
@@ -198,7 +191,7 @@ struct bt_callback_data {
*/
struct step {
void (*action)(void);
- struct bt_action_data action_result;
+ int action_status;
expected_bt_callback_t callback;
struct bt_callback_data callback_result;
--
1.9.1
This patch also introduces bt_action_data for passing arguments to HAL
api calls. So far one argument was enough but now there's need for more.
---
android/tester-bluetooth.c | 148 ++++++++++++++++++++++++++++++++++++++++++++-
android/tester-main.c | 21 +++++++
android/tester-main.h | 11 ++++
3 files changed, 178 insertions(+), 2 deletions(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 65fd93c..497691f 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -83,13 +83,73 @@ static bt_property_t prop_emu_bonded_devs = {
.len = 0,
};
-static uint32_t emu_remote_type_val = BT_DEVICE_DEVTYPE_BLE;
-static int32_t emu_remote_rssi_val = 127;
static bt_bdaddr_t emu_remote_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
};
+
+static uint32_t emu_remote_type_val = BT_DEVICE_DEVTYPE_BLE;
+static bt_property_t prop_emu_ble_remote_tod_prop = {
+ .type = BT_PROPERTY_TYPE_OF_DEVICE,
+ .val = &emu_remote_type_val,
+ .len = sizeof(emu_remote_type_val),
+};
+static struct bt_action_data prop_emu_ble_remote_tod_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_TYPE_OF_DEVICE,
+};
+
+static int32_t emu_remote_rssi_val = 127;
+static bt_property_t prop_emu_ble_remote_rssi_prop = {
+ .type = BT_PROPERTY_REMOTE_RSSI,
+ .val = &emu_remote_rssi_val,
+ .len = sizeof(emu_remote_rssi_val),
+};
+static struct bt_action_data prop_emu_ble_remote_rssi_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_REMOTE_RSSI,
+};
+
static const char emu_remote_bdname_val[] = "00:AA:01:01:00:00";
+static bt_property_t prop_emu_ble_remote_bdname_prop = {
+ .type = BT_PROPERTY_BDNAME,
+ .val = &emu_remote_bdname_val,
+ .len = sizeof(emu_remote_bdname_val) - 1,
+};
+static struct bt_action_data prop_emu_ble_remote_bdname_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_BDNAME,
+};
+
static uint32_t emu_remote_cod_val = 0;
+static bt_property_t prop_emu_ble_remote_cod_prop = {
+ .type = BT_PROPERTY_CLASS_OF_DEVICE,
+ .val = &emu_remote_cod_val,
+ .len = sizeof(emu_remote_cod_val),
+};
+static struct bt_action_data prop_emu_ble_remote_cod_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_CLASS_OF_DEVICE,
+};
+
+static bt_property_t prop_emu_ble_remote_uuids_prop = {
+ .type = BT_PROPERTY_UUIDS,
+ .val = NULL,
+ .len = 0,
+};
+static struct bt_action_data prop_emu_ble_remote_uuids_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_UUIDS,
+};
+
+static bt_property_t prop_emu_ble_remote_timestamp_prop = {
+ .type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
+ .val = NULL,
+ .len = 4,
+};
+static struct bt_action_data prop_emu_ble_remote_timestamp_req = {
+ .addr = &emu_remote_bdaddr_val,
+ .prop_type = BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP,
+};
static bt_property_t prop_emu_default_set[] = {
{ BT_PROPERTY_BDADDR, sizeof(emu_bdaddr_val), NULL },
@@ -421,6 +481,90 @@ static struct test_case test_cases[] = {
&emu_remote_bdaddr_val),
CALLBACK_DEVICE_PROPS(prop_emu_ble_remotes_query_set, 6),
),
+ TEST_CASE("Bluetooth Device Get BDNAME - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_get_device_prop_action,
+ &prop_emu_ble_remote_bdname_req),
+ CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_bdname_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Device Get UUIDS - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_get_device_prop_action,
+ &prop_emu_ble_remote_uuids_req),
+ CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_uuids_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Device Get COD - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_get_device_prop_action,
+ &prop_emu_ble_remote_cod_req),
+ CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_cod_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Device Get TOD - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_get_device_prop_action,
+ &prop_emu_ble_remote_tod_req),
+ CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_tod_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Device Get RSSI - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_get_device_prop_action,
+ &prop_emu_ble_remote_rssi_req),
+ CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_rssi_prop, 1),
+ ),
+ TEST_CASE("Bluetooth Device Get TIMESTAMP - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_get_device_prop_action,
+ &prop_emu_ble_remote_timestamp_req),
+ CALLBACK_DEVICE_PROPS(&prop_emu_ble_remote_timestamp_prop, 1),
+ ),
};
struct queue *get_bluetooth_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index dde04b9..59762bb 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -1057,6 +1057,27 @@ void bt_get_device_props_action(void)
verify_step(&step, NULL);
}
+void bt_get_device_prop_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *current_data_step = queue_peek_head(data->steps);
+ struct bt_action_data *action_data = current_data_step->set_data;
+ struct step step;
+
+ if (!action_data) {
+ tester_warn("No arguments for 'get remote device prop' req.");
+ tester_test_failed();
+ return;
+ }
+
+ memset(&step, 0, sizeof(step));
+ step.action_status = data->if_bluetooth->get_remote_device_property(
+ action_data->addr,
+ action_data->prop_type);
+
+ verify_step(&step, NULL);
+}
+
static void generic_test_function(const void *test_data)
{
struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index 920f82c..ef8c3d5 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -174,6 +174,16 @@ struct test_data {
};
/*
+ * Struct holding bluetooth HAL action parameters
+ */
+struct bt_action_data {
+ bt_bdaddr_t *addr;
+
+ /* Remote props action arguments */
+ int prop_type;
+};
+
+/*
* Callback data structure should be enhanced with data
* returned by callbacks. It's used for test case step
* matching with expected step data.
@@ -228,3 +238,4 @@ void bt_get_property_action(void);
void bt_start_discovery_action(void);
void bt_cancel_discovery_action(void);
void bt_get_device_props_action(void);
+void bt_get_device_prop_action(void);
--
1.9.1
---
android/tester-bluetooth.c | 29 +++++++++++++++++++++++++++++
android/tester-main.c | 37 ++++++++++++++++++++++++++++++++++++-
android/tester-main.h | 7 +++++++
3 files changed, 72 insertions(+), 1 deletion(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 6bc67da..65fd93c 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -88,6 +88,8 @@ static int32_t emu_remote_rssi_val = 127;
static bt_bdaddr_t emu_remote_bdaddr_val = {
.address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
};
+static const char emu_remote_bdname_val[] = "00:AA:01:01:00:00";
+static uint32_t emu_remote_cod_val = 0;
static bt_property_t prop_emu_default_set[] = {
{ BT_PROPERTY_BDADDR, sizeof(emu_bdaddr_val), NULL },
@@ -111,6 +113,19 @@ static bt_property_t prop_emu_ble_remotes_default_set[] = {
&emu_remote_rssi_val },
};
+static bt_property_t prop_emu_ble_remotes_query_set[] = {
+ { BT_PROPERTY_TYPE_OF_DEVICE, sizeof(emu_remote_type_val),
+ &emu_remote_type_val },
+ { BT_PROPERTY_CLASS_OF_DEVICE, sizeof(emu_remote_cod_val),
+ &emu_remote_cod_val },
+ { BT_PROPERTY_REMOTE_RSSI, sizeof(emu_remote_rssi_val),
+ &emu_remote_rssi_val },
+ { BT_PROPERTY_BDNAME, sizeof(emu_remote_bdname_val) - 1,
+ &emu_remote_bdname_val },
+ { BT_PROPERTY_UUIDS, 0, NULL },
+ { BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP, 4, NULL },
+};
+
static char test_bdname[] = "test_bdname";
static bt_property_t prop_test_bdname = {
.type = BT_PROPERTY_BDNAME,
@@ -392,6 +407,20 @@ static struct test_case test_cases[] = {
CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
BT_DISCOVERY_STOPPED),
),
+ TEST_CASE("Bluetooth Device Get Props - 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ACTION_SUCCESS(bt_get_device_props_action,
+ &emu_remote_bdaddr_val),
+ CALLBACK_DEVICE_PROPS(prop_emu_ble_remotes_query_set, 6),
+ ),
};
struct queue *get_bluetooth_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index 5849c0c..f5ac281 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -601,11 +601,26 @@ static void device_found_cb(int num_properties, bt_property_t *properties)
schedule_callback_call(step);
}
+static void remote_device_properties_cb(bt_status_t status,
+ bt_bdaddr_t *bd_addr, int num_properties,
+ bt_property_t *properties)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback_result.num_properties = num_properties;
+ step->callback_result.properties = copy_properties(num_properties,
+ properties);
+
+ step->callback = CB_BT_REMOTE_DEVICE_PROPERTIES;
+
+ schedule_callback_call(step);
+}
+
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 = NULL,
+ .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 = NULL,
@@ -1022,6 +1037,26 @@ void bt_cancel_discovery_action(void)
verify_step(&step, NULL);
}
+void bt_get_device_props_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct step *current_data_step = queue_peek_head(data->steps);
+ struct step step;
+
+ if (!current_data_step->set_data) {
+ tester_debug("bdaddr not defined");
+ tester_test_failed();
+ return;
+ }
+
+ memset(&step, 0, sizeof(step));
+ step.action_result.status =
+ data->if_bluetooth->get_remote_device_properties(
+ current_data_step->set_data);
+
+ verify_step(&step, NULL);
+}
+
static void generic_test_function(const void *test_data)
{
struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index 3919713..b81487d 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -79,6 +79,12 @@
.callback_result.num_properties = prop_cnt, \
}
+#define CALLBACK_DEVICE_PROPS(props, prop_cnt) { \
+ .callback = CB_BT_REMOTE_DEVICE_PROPERTIES, \
+ .callback_result.properties = props, \
+ .callback_result.num_properties = prop_cnt, \
+ }
+
#define CALLBACK_DEVICE_FOUND(props, prop_cnt) { \
.callback = CB_BT_DEVICE_FOUND, \
.callback_result.properties = props, \
@@ -228,3 +234,4 @@ void bt_set_property_action(void);
void bt_get_property_action(void);
void bt_start_discovery_action(void);
void bt_cancel_discovery_action(void);
+void bt_get_device_props_action(void);
--
1.9.1
This patch adds first test case that requires remote emulated device to be
discovered. New action step was added to activate this device on demand.
---
android/tester-bluetooth.c | 27 +++++++++++++++++++++
android/tester-main.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-
android/tester-main.h | 9 +++++++
3 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index fd5837d..6bc67da 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -83,6 +83,12 @@ static bt_property_t prop_emu_bonded_devs = {
.len = 0,
};
+static uint32_t emu_remote_type_val = BT_DEVICE_DEVTYPE_BLE;
+static int32_t emu_remote_rssi_val = 127;
+static bt_bdaddr_t emu_remote_bdaddr_val = {
+ .address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
+};
+
static bt_property_t prop_emu_default_set[] = {
{ BT_PROPERTY_BDADDR, sizeof(emu_bdaddr_val), NULL },
{ BT_PROPERTY_BDNAME, sizeof(emu_bdname_val) - 1, &emu_bdname_val },
@@ -96,6 +102,15 @@ static bt_property_t prop_emu_default_set[] = {
{ BT_PROPERTY_UUIDS, sizeof(emu_uuids_val), &emu_uuids_val },
};
+static bt_property_t prop_emu_ble_remotes_default_set[] = {
+ { BT_PROPERTY_BDADDR, sizeof(emu_remote_bdaddr_val),
+ &emu_remote_bdaddr_val },
+ { BT_PROPERTY_TYPE_OF_DEVICE, sizeof(emu_remote_type_val),
+ &emu_remote_type_val },
+ { BT_PROPERTY_REMOTE_RSSI, sizeof(emu_remote_rssi_val),
+ &emu_remote_rssi_val },
+};
+
static char test_bdname[] = "test_bdname";
static bt_property_t prop_test_bdname = {
.type = BT_PROPERTY_BDNAME,
@@ -365,6 +380,18 @@ static struct test_case test_cases[] = {
BT_DISCOVERY_STOPPED),
ACTION_SUCCESS(bt_start_discovery_action, NULL),
),
+ TEST_CASE("Bluetooth BR/EDR Discovery Device Found",
+ 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(bt_start_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STARTED),
+ CALLBACK_DEVICE_FOUND(prop_emu_ble_remotes_default_set, 3),
+ ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
+ CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
+ BT_DISCOVERY_STOPPED),
+ ),
};
struct queue *get_bluetooth_tests(void)
diff --git a/android/tester-main.c b/android/tester-main.c
index 7e2cc09..5849c0c 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -17,6 +17,9 @@
#include "tester-main.h"
+#include "emulator/bthost.h"
+#include "monitor/bt.h"
+
static char exec_dir[PATH_MAX + 1];
static gint scheduled_cbacks_num;
@@ -585,12 +588,25 @@ static void discovery_state_changed_cb(bt_discovery_state_t state)
schedule_callback_call(step);
}
+static void device_found_cb(int num_properties, bt_property_t *properties)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback_result.num_properties = num_properties;
+ step->callback_result.properties = copy_properties(num_properties,
+ properties);
+
+ step->callback = CB_BT_DEVICE_FOUND;
+
+ schedule_callback_call(step);
+}
+
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 = NULL,
- .device_found_cb = NULL,
+ .device_found_cb = device_found_cb,
.discovery_state_changed_cb = discovery_state_changed_cb,
.pin_request_cb = NULL,
.ssp_request_cb = NULL,
@@ -867,6 +883,48 @@ static void teardown(const void *test_data)
tester_teardown_complete();
}
+static void emu_connectable_complete(uint16_t opcode, uint8_t status,
+ const void *param, uint8_t len,
+ void *user_data)
+{
+ struct step step;
+
+ switch (opcode) {
+ case BT_HCI_CMD_WRITE_SCAN_ENABLE:
+ case BT_HCI_CMD_LE_SET_ADV_ENABLE:
+ break;
+ default:
+ return;
+ }
+
+ memset(&step, 0, sizeof(step));
+
+ if (status) {
+ tester_warn("Emulated remote setup failed.");
+ step.action_result.status = BT_STATUS_FAIL;
+ } else {
+ tester_warn("Emulated remote setup done.");
+ step.action_result.status = BT_STATUS_SUCCESS;
+ }
+
+ verify_step(&step, NULL);
+}
+
+void emu_setup_powered_remote_action(void)
+{
+ struct test_data *data = tester_get_data();
+ struct bthost *bthost;
+
+ bthost = hciemu_client_get_host(data->hciemu);
+ bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
+
+ if ((data->hciemu_type == HCIEMU_TYPE_LE) ||
+ (data->hciemu_type == HCIEMU_TYPE_BREDRLE))
+ bthost_set_adv_enable(bthost, 0x01, 0x02);
+ else
+ bthost_write_scan_enable(bthost, 0x03);
+}
+
void dummy_action(void)
{
struct step step;
diff --git a/android/tester-main.h b/android/tester-main.h
index 1e1dd51..3919713 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -79,6 +79,12 @@
.callback_result.num_properties = prop_cnt, \
}
+#define CALLBACK_DEVICE_FOUND(props, prop_cnt) { \
+ .callback = CB_BT_DEVICE_FOUND, \
+ .callback_result.properties = props, \
+ .callback_result.num_properties = prop_cnt, \
+ }
+
/*
* NOTICE:
* Callback enum sections should be
@@ -211,6 +217,9 @@ void remove_hidhost_tests(void);
struct queue *get_gatt_tests(void);
void remove_gatt_tests(void);
+/* Emulator actions */
+void emu_setup_powered_remote_action(void);
+
/* Actions */
void dummy_action(void);
void bluetooth_enable_action(void);
--
1.9.1