[BlueZ PATCH] tools/mgmt-tester: Add test case for scan response data is not updating

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tedd Ho-Jeong An <tedd.an@xxxxxxxxx>

This patch adds a test case to test if the scan response data is updated
when the following scenarios are performed.

1. Add Extended Advertising Parameters Command
2. Add Extended Advertising Data Command w/ Scan Resp Data
3. Remove Advertising Command
4. Add Extended Advertising Parameters Command
5. Add Extended Advertising Data Command w/ Scan Resp Data
6. Host should set Scan Resp Data
---
 tools/mgmt-tester.c | 85 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 1 deletion(-)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index 2b27394a1..f45a6c015 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -6156,6 +6156,23 @@ static void setup_pairing_acceptor(const void *test_data)
 	setup_bthost();
 }
 
+/* Generic callback for checking the mgmt evnet status
+ */
+static void generic_mgmt_status_callback(uint8_t status, uint16_t length,
+					const void *param, void *user_data)
+{
+	bool bthost = PTR_TO_INT(user_data);
+
+	if (status != MGMT_STATUS_SUCCESS) {
+		tester_setup_failed();
+		return;
+	}
+
+	if (bthost)
+		setup_bthost();
+}
+
+
 static void setup_powered_callback(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -6990,6 +7007,66 @@ static void setup_ext_adv_params(const void *test_data)
 					NULL, NULL);
 }
 
+static const uint8_t hci_set_ext_adv_data_name[] = {
+	0x01, /* Handle */
+	0x03, /* Operation */
+	0x01, /* Complete name */
+	0x06, 0x05, 0x08, 0x74, 0x65, 0x73, 0x74
+};
+
+static const struct generic_data add_ext_adv_scan_resp_off_on = {
+	.send_opcode = MGMT_OP_ADD_EXT_ADV_DATA,
+	.send_param = ext_adv_data_valid,
+	.send_len = sizeof(ext_adv_data_valid),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = ext_adv_data_mgmt_rsp_valid,
+	.expect_len = sizeof(ext_adv_data_mgmt_rsp_valid),
+	.expect_hci_command = BT_HCI_CMD_LE_SET_EXT_SCAN_RSP_DATA,
+	.expect_hci_param = hci_set_ext_adv_data_name,
+	.expect_hci_len = sizeof(hci_set_ext_adv_data_name),
+};
+
+static void setup_add_ext_adv_on_off(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	unsigned char param[] = { 0x01 };
+	int enable_bthost = 1;
+
+	mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+					sizeof(param), &param,
+					NULL, NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
+					sizeof(param), &param,
+					generic_mgmt_status_callback,
+					NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_ADD_EXT_ADV_PARAMS, data->mgmt_index,
+					sizeof(ext_adv_params_valid),
+					&ext_adv_params_valid,
+					generic_mgmt_status_callback,
+					NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_ADD_EXT_ADV_DATA, data->mgmt_index,
+					sizeof(ext_adv_data_valid),
+					&ext_adv_data_valid,
+					generic_mgmt_status_callback,
+					NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_REMOVE_ADVERTISING, data->mgmt_index,
+					sizeof(remove_advertising_param_1),
+					&remove_advertising_param_1,
+					generic_mgmt_status_callback,
+					NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_ADD_EXT_ADV_PARAMS, data->mgmt_index,
+					sizeof(ext_adv_params_valid),
+					&ext_adv_params_valid,
+					generic_mgmt_status_callback,
+					INT_TO_PTR(enable_bthost), NULL);
+
+}
+
 static void pin_code_request_callback(uint16_t index, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -13960,11 +14037,17 @@ int main(int argc, char *argv[])
 				setup_ext_adv_params,
 				test_command_generic);
 
-	test_bredrle50("zxcv Ext Adv MGMT - AD Scan Response (5.0) Success",
+	test_bredrle50("Ext Adv MGMT - AD Scan Response (5.0) Success",
 				&adv_scan_rsp_success,
 				setup_ext_adv_params,
 				test_command_generic);
 
+	test_bredrle50("Ext Adv MGMT - AD Scan Resp - Off and On",
+				&add_ext_adv_scan_resp_off_on,
+				setup_add_ext_adv_on_off,
+				test_command_generic);
+
+
 	/* MGMT_OP_SET_DEVICE_ID
 	 * Using Bluetooth SIG for source.
 	 */
-- 
2.34.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux