[PATCH BlueZ 4/4] iso-tester: add test for ACL disconnect before ISO created

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

 



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

Notes:
    Current bluetooth-next/master kernel fails this.

 tools/iso-tester.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index b1a2afba0..48c8ab52a 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -2628,6 +2628,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();
@@ -2850,6 +2884,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);
-- 
2.41.0




[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