linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] tools/mgmt-tester: Fix expected HCI command accounting
@ 2021-05-25  5:39 Inga Stotland
  2021-05-26  5:45 ` [BlueZ] " bluez.test.bot
  0 siblings, 1 reply; 2+ messages in thread
From: Inga Stotland @ 2021-05-25  5:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.dentz, Inga Stotland

This fixes test condition accounting in the expected HCI command
callback.

When the expected opcode has been detected, the test condition
is either marked as completed in case of passing the checks or the
test failure is reported. Any subsequent HCI commandis logged only as
informational and does not contribute towards test accounting.

Without the fix, in number of test cases where the expected HCI command
is detected more than once, the test condition countdown goes into
negative numbers or the test is erroneously reported as failed.
---
 tools/mgmt-tester.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c
index c9de770c1..22b6a3387 100644
--- a/tools/mgmt-tester.c
+++ b/tools/mgmt-tester.c
@@ -6882,6 +6882,22 @@ static void command_setup_hci_callback(uint16_t opcode, const void *param,
 	test_setup_condition_complete(data);
 }
 
+static void command_hci_plus_callback(uint16_t opcode, const void *param,
+					uint8_t length, void *user_data)
+{
+	tester_print("Post HCI Command 0x%04x length %u", opcode, length);
+}
+
+static gboolean hci_command_idle(void *user_data)
+{
+	struct test_data *data = user_data;
+
+	hciemu_clear_master_post_command_hooks(data->hciemu);
+	hciemu_add_master_post_command_hook(data->hciemu,
+					command_hci_plus_callback, data);
+	return FALSE;
+}
+
 static void command_hci_callback(uint16_t opcode, const void *param,
 					uint8_t length, void *user_data)
 {
@@ -6896,6 +6912,8 @@ static void command_hci_callback(uint16_t opcode, const void *param,
 	if (opcode != test->expect_hci_command || data->unmet_conditions <= 0)
 		return;
 
+	g_idle_add(hci_command_idle, data);
+
 	if (test->expect_hci_func)
 		expect_hci_param = test->expect_hci_func(&expect_hci_len);
 
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-26  5:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-25  5:39 [PATCH BlueZ] tools/mgmt-tester: Fix expected HCI command accounting Inga Stotland
2021-05-26  5:45 ` [BlueZ] " bluez.test.bot

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).