linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tedd Ho-Jeong An <hj.tedd.an@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [BlueZ PATCH 2/2] tools/mgmt-tester: Add test cases for remove uuid command
Date: Thu, 20 May 2021 23:24:41 -0700	[thread overview]
Message-ID: <20210521062441.155117-2-hj.tedd.an@gmail.com> (raw)
In-Reply-To: <20210521062441.155117-1-hj.tedd.an@gmail.com>

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

This patch adds test cases for the Remove UUID command.
---
 tools/mgmt-tester.c | 143 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 143 insertions(+)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index e3523dcd5..973e5966f 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -2534,6 +2534,65 @@ static const struct generic_data add_uuid_mix_test_1 = {
 	.expect_hci_len = sizeof(write_eir_uuid_mix_hci),
 };
 
+static const char remove_dun_uuid_param[] = {
+			0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+			0x00, 0x10, 0x00, 0x00, 0x03, 0x11, 0x00, 0x00 };
+
+static const char write_eir_remove_dun_hci[241] = {
+			0x00, 0x02, 0x0a, 0x00, 0x05, 0x03, 0x01, 0x11, 0x04,
+			0x11 };
+
+static const struct generic_data remove_uuid_success_1 = {
+	.send_opcode = MGMT_OP_REMOVE_UUID,
+	.send_param = remove_dun_uuid_param,
+	.send_len = sizeof(remove_dun_uuid_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = set_dev_class_zero_rsp,
+	.expect_len = sizeof(set_dev_class_zero_rsp),
+	.expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE,
+	.expect_hci_param = write_eir_remove_dun_hci,
+	.expect_hci_len = sizeof(write_eir_remove_dun_hci),
+};
+
+static const char remove_all_uuid_param[16] = { 0x00 };
+
+static const struct generic_data remove_uuid_all_success_2 = {
+	.send_opcode = MGMT_OP_REMOVE_UUID,
+	.send_param = remove_all_uuid_param,
+	.send_len = sizeof(remove_all_uuid_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = set_dev_class_zero_rsp,
+	.expect_len = sizeof(set_dev_class_zero_rsp),
+};
+
+static const struct generic_data remove_uuid_power_off_success_3 = {
+	.send_opcode = MGMT_OP_REMOVE_UUID,
+	.send_param = remove_dun_uuid_param,
+	.send_len = sizeof(remove_dun_uuid_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = set_dev_class_zero_rsp,
+	.expect_len = sizeof(set_dev_class_zero_rsp),
+};
+
+static const struct generic_data remove_uuid_power_off_on_success_4 = {
+	.send_opcode = MGMT_OP_SET_POWERED,
+	.send_param = set_powered_on_param,
+	.send_len = sizeof(set_powered_on_param),
+	.expect_status = MGMT_STATUS_SUCCESS,
+	.expect_param = set_ssp_settings_param_2,
+	.expect_len = sizeof(set_ssp_settings_param_2),
+	.expect_hci_command = BT_HCI_CMD_WRITE_EXT_INQUIRY_RESPONSE,
+	.expect_hci_param = write_eir_remove_dun_hci,
+	.expect_hci_len = sizeof(write_eir_remove_dun_hci),
+};
+
+static const struct generic_data remove_uuid_invalid_params_1 = {
+	.send_opcode = MGMT_OP_REMOVE_UUID,
+	.send_param = add_opp_uuid_param,
+	.send_len = sizeof(add_opp_uuid_param),
+	.expect_status = MGMT_STATUS_INVALID_PARAMS,
+};
+
 static const char load_link_keys_valid_param_1[] = { 0x00, 0x00, 0x00 };
 static const char load_link_keys_valid_param_2[] = { 0x01, 0x00, 0x00 };
 static const char load_link_keys_invalid_param_1[] = { 0x02, 0x00, 0x00 };
@@ -5893,6 +5952,56 @@ static void setup_multi_uuid16(const void *test_data)
 					setup_powered_callback, NULL, NULL);
 }
 
+static void setup_multi_uuid16_power_off(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	unsigned char param[] = { 0x01 };
+
+	tester_print("Adding UUIDs without powering on");
+
+	mgmt_send(data->mgmt, MGMT_OP_SET_SSP, data->mgmt_index,
+				sizeof(param), param, NULL, NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_ADD_UUID, data->mgmt_index,
+				sizeof(add_spp_uuid_param), add_spp_uuid_param,
+				NULL, NULL, NULL);
+	mgmt_send(data->mgmt, MGMT_OP_ADD_UUID, data->mgmt_index,
+				sizeof(add_dun_uuid_param), add_dun_uuid_param,
+				NULL, NULL, NULL);
+	mgmt_send(data->mgmt, MGMT_OP_ADD_UUID, data->mgmt_index,
+			sizeof(add_sync_uuid_param), add_sync_uuid_param,
+			NULL, NULL, NULL);
+
+	setup_bthost();
+}
+
+static void setup_multi_uuid16_power_off_remove(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	unsigned char param[] = { 0x01 };
+
+	tester_print("Adding UUIDs without powering on and remove UUID");
+
+	mgmt_send(data->mgmt, MGMT_OP_SET_SSP, data->mgmt_index,
+				sizeof(param), param, NULL, NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_ADD_UUID, data->mgmt_index,
+				sizeof(add_spp_uuid_param), add_spp_uuid_param,
+				NULL, NULL, NULL);
+	mgmt_send(data->mgmt, MGMT_OP_ADD_UUID, data->mgmt_index,
+				sizeof(add_dun_uuid_param), add_dun_uuid_param,
+				NULL, NULL, NULL);
+	mgmt_send(data->mgmt, MGMT_OP_ADD_UUID, data->mgmt_index,
+			sizeof(add_sync_uuid_param), add_sync_uuid_param,
+			NULL, NULL, NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_REMOVE_UUID, data->mgmt_index,
+			sizeof(remove_dun_uuid_param), remove_dun_uuid_param,
+			NULL, NULL, NULL);
+
+	setup_bthost();
+}
+
 static void setup_multi_uuid16_2(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -9817,6 +9926,40 @@ int main(int argc, char *argv[])
 				&add_uuid_mix_test_1,
 				setup_uuid_mix, test_command_generic);
 
+	/* MGMT_OP_REMOVE_UUID
+	 * Remove existing UUID.
+	 */
+	test_bredrle("Remove UUID - Success 1",
+				&remove_uuid_success_1,
+				setup_multi_uuid16, test_command_generic);
+	/* MGMT_OP_REMOVE_UUID
+	 * Remove all UUID by sending zero filled UUID
+	 */
+	test_bredrle("Remove UUID - All UUID - Success 2",
+				&remove_uuid_all_success_2,
+				setup_multi_uuid16, test_command_generic);
+	/* MGMT_OP_REMOVE_UUID
+	 * Remove UUID while powering off
+	 * Expect the 0x000000 for the class of device
+	 */
+	test_bredrle("Remove UUID - Power Off - Success 3",
+				&remove_uuid_power_off_success_3,
+				setup_multi_uuid16_power_off,
+				test_command_generic);
+	/* MGMT_OP_REMOVE_UUID
+	 * Remove UUID while powering off and then powering on
+	 */
+	test_bredrle("Remove UUID - Power Off and On - Success 4",
+				&remove_uuid_power_off_on_success_4,
+				setup_multi_uuid16_power_off_remove,
+				test_command_generic);
+	/* MGMT_OP_REMOVE_UUID
+	 * Remove UUID doesn't exist - Invalid parameter
+	 */
+	test_bredrle("Remove UUID - Not Exist - Invalid Params 1",
+				&remove_uuid_invalid_params_1,
+				setup_multi_uuid16, test_command_generic);
+
 	test_bredrle("Load Link Keys - Empty List Success 1",
 				&load_link_keys_success_test_1,
 				NULL, test_command_generic);
-- 
2.26.3


  reply	other threads:[~2021-05-21  6:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-21  6:24 [BlueZ PATCH 1/2] tools/mgmt-tester: Add test cases for set device id command Tedd Ho-Jeong An
2021-05-21  6:24 ` Tedd Ho-Jeong An [this message]
2021-05-21  6:50 ` [BlueZ,1/2] " bluez.test.bot
2021-05-21 23:53   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210521062441.155117-2-hj.tedd.an@gmail.com \
    --to=hj.tedd.an@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).