iso-tester: add test for ACL disconnect before ISO created
authorPauli Virtanen <pav@iki.fi>
Sat, 19 Aug 2023 13:31:23 +0000 (16:31 +0300)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 5 Jan 2024 13:34:03 +0000 (19:04 +0530)
Simulate ACL being disconnected when connecting ISO, before LE Create
CIS got sent.  The kernel shall indicate connection failure for the ISO
socket immediately when the ACL is gone, since connecting the ISO can no
longer proceed.

ISO Connect ACL Disconnect - Failure

tools/iso-tester.c

index 75edc4380ba4e00eb40f989b3d432b49c2443a96..410da2c930aca1f84fe4784e671ce68154d7e175 100644 (file)
@@ -2654,6 +2654,40 @@ static void test_connect_suspend(const void *test_data)
        trigger_force_suspend((void *)test_data);
 }
 
+static bool hook_acl_disc(const void *msg, uint16_t len, void *user_data)
+{
+       const uint8_t *msg_data = msg;
+       const struct bt_hci_evt_le_enhanced_conn_complete *ev;
+       struct test_data *data = tester_get_data();
+       struct bthost *bthost;
+
+       if (msg_data[0] != BT_HCI_EVT_LE_ENHANCED_CONN_COMPLETE)
+               return true;
+
+       ev = (void *) &msg_data[1];
+
+       tester_print("Disconnect ACL");
+
+       bthost = hciemu_client_get_host(data->hciemu);
+       bthost_hci_disconnect(bthost, le16_to_cpu(ev->handle), 0x13);
+
+       hciemu_flush_client_events(data->hciemu);
+
+       return true;
+}
+
+static void test_connect_acl_disc(const void *test_data)
+{
+       struct test_data *data = tester_get_data();
+
+       /* ACL disconnected before ISO is created */
+       hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_EVT,
+                                       BT_HCI_EVT_LE_META_EVENT,
+                                       hook_acl_disc, NULL);
+
+       test_connect(test_data);
+}
+
 static void test_bcast(const void *test_data)
 {
        struct test_data *data = tester_get_data();
@@ -2876,6 +2910,10 @@ int main(int argc, char *argv[])
                                                        setup_powered,
                                                        test_connect2);
 
+       test_iso("ISO Connect ACL Disconnect - Failure", &connect_suspend,
+                                                       setup_powered,
+                                                       test_connect_acl_disc);
+
        test_iso("ISO Defer Send - Success", &connect_16_2_1_defer_send,
                                                        setup_powered,
                                                        test_connect);