This patch adds new test cases for the Add Advertising command for the
following conditions:
- ADV_SCAN_IND, ADV_NONCONN_IND, and ADV_IND correctly configured based on the
global "connectable" setting and the instance scan response length.
- ADV_IND is used when the global "connectable" setting is "on" and instance
flags is 0.
---
tools/mgmt-tester.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 0721a64..d3fba97 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4234,6 +4234,74 @@ static const struct generic_data add_advertising_success_12 = {
.expect_hci_len = sizeof(set_adv_data_8),
};
+static uint16_t settings_powered_le_connectable[] = {
+ MGMT_OP_SET_POWERED,
+ MGMT_OP_SET_LE,
+ MGMT_OP_SET_CONNECTABLE, 0 };
+
+static const struct generic_data add_advertising_success_13 = {
+ .setup_settings = settings_powered_le_connectable,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_1,
+ .send_len = sizeof(add_advertising_param_1),
+ .expect_param = advertising_instance_param,
+ .expect_len = sizeof(advertising_instance_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ .expect_hci_param = set_connectable_on_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_adv_param),
+};
+
+static uint8_t set_connectable_off_scan_adv_param[] = {
+ 0x00, 0x08, /* min_interval */
+ 0x00, 0x08, /* max_interval */
+ 0x02, /* type */
+ 0x01, /* own_addr_type */
+ 0x00, /* direct_addr_type */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* direct_addr */
+ 0x07, /* channel_map */
+ 0x00, /* filter_policy */
+};
+
+static const struct generic_data add_advertising_success_14 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_2,
+ .send_len = sizeof(add_advertising_param_2),
+ .expect_param = advertising_instance_param,
+ .expect_len = sizeof(advertising_instance_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ .expect_hci_param = set_connectable_off_scan_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_scan_adv_param),
+};
+
+static const struct generic_data add_advertising_success_15 = {
+ .setup_settings = settings_powered_le,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_1,
+ .send_len = sizeof(add_advertising_param_1),
+ .expect_param = advertising_instance_param,
+ .expect_len = sizeof(advertising_instance_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ .expect_hci_param = set_connectable_off_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_adv_param),
+};
+
+static const struct generic_data add_advertising_success_16 = {
+ .setup_settings = settings_powered_le_connectable,
+ .send_opcode = MGMT_OP_ADD_ADVERTISING,
+ .send_param = add_advertising_param_1,
+ .send_len = sizeof(add_advertising_param_1),
+ .expect_param = advertising_instance_param,
+ .expect_len = sizeof(advertising_instance_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ .expect_hci_param = set_connectable_on_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_adv_param),
+};
+
static const char set_powered_off_le_settings_param[] = {
0x80, 0x02, 0x00, 0x00
};
@@ -6201,6 +6269,18 @@ int main(int argc, char *argv[])
test_bredrle("Add Advertising - Success 9 - Flag 4",
&add_advertising_success_12,
NULL, test_command_generic);
+ test_bredrle("Add Advertising - Success 10 - connectable on",
+ &add_advertising_success_13,
+ NULL, test_command_generic);
+ test_bredrle("Add Advertising - Success 11 - ADV_SCAN_IND",
+ &add_advertising_success_14,
+ NULL, test_command_generic);
+ test_bredrle("Add Advertising - Success 12 - ADV_NONCONN_IND",
+ &add_advertising_success_15,
+ NULL, test_command_generic);
+ test_bredrle("Add Advertising - Success 13 - ADV_IND",
+ &add_advertising_success_16,
+ NULL, test_command_generic);
test_bredrle("Remove Advertising - Invalid Params 1",
&remove_advertising_fail_1,
--
2.2.0.rc0.207.ga3a616c
---
doc/test-coverage.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt
index 268d310..53d0ba4 100644
--- a/doc/test-coverage.txt
+++ b/doc/test-coverage.txt
@@ -40,7 +40,7 @@ Automated end-to-end testing
Application Count Description
-------------------------------------------
-mgmt-tester 274 Kernel management interface testing
+mgmt-tester 280 Kernel management interface testing
l2cap-tester 27 Kernel L2CAP implementation testing
rfcomm-tester 9 Kernel RFCOMM implementation testing
smp-tester 5 Kernel SMP implementation testing
@@ -48,7 +48,7 @@ sco-tester 8 Kernel SCO implementation testing
gap-tester 1 Daemon D-Bus API testing
hci-tester 14 Controller hardware testing
-----
- 338
+ 344
Android end-to-end testing
--
2.2.0.rc0.207.ga3a616c
This patch adds test cases for correctly updating the advertising type
when the global connectable setting changes.
---
tools/mgmt-tester.c | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 74 insertions(+)
diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index d3fba97..bc18911 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -4302,6 +4302,33 @@ static const struct generic_data add_advertising_success_16 = {
.expect_hci_len = sizeof(set_connectable_on_adv_param),
};
+static const char set_connectable_settings_param_3[] = {
+ 0x83, 0x02, 0x00, 0x00 };
+
+static const struct generic_data add_advertising_success_17 = {
+ .send_opcode = MGMT_OP_SET_CONNECTABLE,
+ .send_param = set_connectable_on_param,
+ .send_len = sizeof(set_connectable_on_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_connectable_settings_param_3,
+ .expect_len = sizeof(set_connectable_settings_param_3),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ .expect_hci_param = set_connectable_on_adv_param,
+ .expect_hci_len = sizeof(set_connectable_on_adv_param),
+};
+
+static const struct generic_data add_advertising_success_18 = {
+ .send_opcode = MGMT_OP_SET_CONNECTABLE,
+ .send_param = set_connectable_off_param,
+ .send_len = sizeof(set_connectable_off_param),
+ .expect_status = MGMT_STATUS_SUCCESS,
+ .expect_param = set_le_settings_param_2,
+ .expect_len = sizeof(set_le_settings_param_2),
+ .expect_hci_command = BT_HCI_CMD_LE_SET_ADV_PARAMETERS,
+ .expect_hci_param = set_connectable_off_adv_param,
+ .expect_hci_len = sizeof(set_connectable_off_adv_param),
+};
+
static const char set_powered_off_le_settings_param[] = {
0x80, 0x02, 0x00, 0x00
};
@@ -4792,6 +4819,45 @@ static void setup_add_advertising(const void *test_data)
NULL, NULL);
}
+static void setup_add_advertising_connectable(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ struct mgmt_cp_add_advertising *cp;
+ unsigned char adv_param[sizeof(*cp) + 6];
+ unsigned char param[] = { 0x01 };
+
+ tester_print("Adding advertising instance while unpowered");
+
+ cp = (struct mgmt_cp_add_advertising *) adv_param;
+ memset(cp, 0, sizeof(*cp));
+
+ cp->instance = 1;
+ cp->adv_data_len = 6;
+ cp->data[0] = 0x05;
+ cp->data[1] = 0x08;
+ cp->data[2] = 't';
+ cp->data[3] = 'e';
+ cp->data[4] = 's';
+ cp->data[5] = 't';
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index,
+ sizeof(param), ¶m,
+ NULL, NULL, NULL);
+
+ mgmt_send(data->mgmt, MGMT_OP_ADD_ADVERTISING, data->mgmt_index,
+ sizeof(adv_param), adv_param,
+ setup_add_advertising_callback,
+ NULL, NULL);
+}
+
static void setup_add_advertising_timeout(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -6281,6 +6347,14 @@ int main(int argc, char *argv[])
test_bredrle("Add Advertising - Success 13 - ADV_IND",
&add_advertising_success_16,
NULL, test_command_generic);
+ test_bredrle("Add Advertising - Success 14 - connectable -> on",
+ &add_advertising_success_17,
+ setup_add_advertising,
+ test_command_generic);
+ test_bredrle("Add Advertising - Success 15 - connectable -> off",
+ &add_advertising_success_18,
+ setup_add_advertising_connectable,
+ test_command_generic);
test_bredrle("Remove Advertising - Invalid Params 1",
&remove_advertising_fail_1,
--
2.2.0.rc0.207.ga3a616c