tools/mgmt-tester: Fix expected HCI command accounting
authorInga Stotland <inga.stotland@intel.com>
Fri, 4 Jun 2021 17:59:13 +0000 (10:59 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:35 +0000 (19:08 +0530)
This fixes test condition count in the expected HCI command
callback.

When the expected HCI opcode is detected, mark the condition
as done. Any subsequent HCI commands are ignored.

Without this fix, in couple of test cases where the expected HCI
command is detected more than once, the test may be erroneously
reported as a failure or prematurely declared as a success before
waiting on an expected MGMT event condition.

The test cases where this behavior is fixed:
Remove Ext Advertising - Success 1
Remove Ext Advertising - Success 2
Reviewed-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mgmt-tester.c

index c5073fe..6109883 100755 (executable)
@@ -52,6 +52,7 @@ struct test_data {
        uint16_t mgmt_index;
        struct hciemu *hciemu;
        enum hciemu_type hciemu_type;
+       bool expect_hci_command_done;
        int unmet_conditions;
        int unmet_setup_conditions;
        int sk;
@@ -7021,9 +7022,11 @@ static void command_hci_callback(uint16_t opcode, const void *param,
 
        tester_print("HCI Command 0x%04x length %u", opcode, length);
 
-       if (opcode != test->expect_hci_command || data->unmet_conditions <= 0)
+       if (opcode != test->expect_hci_command || data->expect_hci_command_done)
                return;
 
+       data->expect_hci_command_done = true;
+
        if (test->expect_hci_func)
                expect_hci_param = test->expect_hci_func(&expect_hci_len);