This adds a few tests checking ISO socket handling of invalid input
parameters and cleanup in some race conditions:
ISO QoS CIG 0xF0 - Invalid
ISO QoS CIS 0xF0 - Invalid
ISO Connect2 CIG 0x01 - Success/Invalid
ISO AC 6(ii) CIS 0xEF/auto - Success
ISO AC 6(ii) CIS 0xEF/0xEF - Invalid
ISO Defer Close - Success
ISO Connect Close - Success
ISO Defer Wait Close - Success
ISO Connect Wait Close - Success
There's also one for a hci_sync race condition that triggers GPF:
eSCO Simultaneous Disconnect - Failure
I have a patch series fixing these, but we'll revisit the
HCI_CONN_DELETED flag there, so maybe discussion needed.
These fail on current bluetooth-next/master, so it could make most sense
to wait for the fixes first.
v2:
- emit correct event from HCI_Create_Connection_Cancel + fix compile
Pauli Virtanen (5):
btdev: check error conditions for HCI_Create_Connection_Cancel
btdev: fix Command Status command opcodes for Setup Sync Conn
sco-tester: test local and remote disconnecting simultaneously
iso-tester: test with large CIS_ID and invalid CIG_ID/CIS_ID
iso-tester: add tests checking Remove CIG is emitted
emulator/btdev.c | 90 ++++++++++++++++++++----
monitor/bt.h | 4 ++
tools/iso-tester.c | 168 +++++++++++++++++++++++++++++++++++++++++++++
tools/sco-tester.c | 59 ++++++++++++++++
4 files changed, 308 insertions(+), 13 deletions(-)
--
2.41.0
Kernel should send LE Remove CIG after all CIS are shut down. Add tests
checking this, closing either immediately or after waiting connection to
complete.
ISO Defer Close - Success
ISO Connect Close - Success
ISO Defer Wait Close - Success
ISO Connect Wait Close - Success
---
Notes:
v2: no change
tools/iso-tester.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 9f853a0f9..bbf959420 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -2425,6 +2425,90 @@ static void test_connect2_nodefer(const void *test_data)
close(sk);
}
+static gboolean iso_connect_close_cb(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
+{
+ struct test_data *data = user_data;
+
+ data->io_id[0] = 0;
+
+ tester_print("Disconnected");
+
+ --data->step;
+ if (!data->step)
+ tester_test_passed();
+
+ return FALSE;
+}
+
+static bool hook_remove_cig(const void *msg, uint16_t len, void *user_data)
+{
+ struct test_data *data = user_data;
+
+ tester_print("Remove CIG");
+
+ --data->step;
+ if (!data->step)
+ tester_test_passed();
+
+ return true;
+}
+
+static void test_connect_close(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ int sk;
+ GIOChannel *io;
+
+ data->step = 2;
+
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_CMD,
+ BT_HCI_CMD_LE_REMOVE_CIG,
+ hook_remove_cig, data);
+
+ sk = setup_sock(data, 0);
+ if (sk < 0)
+ return;
+
+ io = g_io_channel_unix_new(sk);
+ g_io_channel_set_close_on_unref(io, TRUE);
+ data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_connect_close_cb,
+ data);
+
+ shutdown(sk, SHUT_RDWR);
+}
+
+static gboolean iso_connect_wait_close_cb(GIOChannel *io, GIOCondition cond,
+ gpointer user_data)
+{
+ struct test_data *data = tester_get_data();
+ int sk;
+
+ tester_print("Connected");
+
+ sk = g_io_channel_unix_get_fd(io);
+
+ data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_connect_close_cb,
+ data);
+
+ shutdown(sk, SHUT_RDWR);
+
+ return FALSE;
+}
+
+static void test_connect_wait_close(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ data->step = 1;
+
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_PRE_CMD,
+ BT_HCI_CMD_LE_REMOVE_CIG,
+ hook_remove_cig, data);
+
+ setup_connect(data, 0, iso_connect_wait_close_cb);
+}
+
static void test_bcast(const void *test_data)
{
struct test_data *data = tester_get_data();
@@ -2601,6 +2685,18 @@ int main(int argc, char *argv[])
test_iso("ISO Defer Connect - Success", &defer_16_2_1, setup_powered,
test_connect);
+ test_iso("ISO Defer Close - Success", &defer_16_2_1, setup_powered,
+ test_connect_close);
+
+ test_iso("ISO Connect Close - Success", &connect_16_2_1, setup_powered,
+ test_connect_close);
+
+ test_iso("ISO Defer Wait Close - Success", &defer_16_2_1,
+ setup_powered, test_connect_wait_close);
+
+ test_iso("ISO Connect Wait Close - Success", &connect_16_2_1,
+ setup_powered, test_connect_wait_close);
+
test_iso2("ISO Defer Connect2 CIG 0x01 - Success", &defer_1_16_2_1,
setup_powered,
test_connect2);
--
2.41.0
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:
On Tue, 1 Aug 2023 19:38:37 +0300 you wrote:
> This adds a few tests checking ISO socket handling of invalid input
> parameters and cleanup in some race conditions:
>
> ISO QoS CIG 0xF0 - Invalid
> ISO QoS CIS 0xF0 - Invalid
> ISO Connect2 CIG 0x01 - Success/Invalid
> ISO AC 6(ii) CIS 0xEF/auto - Success
> ISO AC 6(ii) CIS 0xEF/0xEF - Invalid
> ISO Defer Close - Success
> ISO Connect Close - Success
> ISO Defer Wait Close - Success
> ISO Connect Wait Close - Success
>
> [...]
Here is the summary with links:
- [BlueZ,v2,1/5] btdev: check error conditions for HCI_Create_Connection_Cancel
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5815a92423c3
- [BlueZ,v2,2/5] btdev: fix Command Status command opcodes for Setup Sync Conn
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=23a7d4003064
- [BlueZ,v2,3/5] sco-tester: test local and remote disconnecting simultaneously
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=80c8266ae20a
- [BlueZ,v2,4/5] iso-tester: test with large CIS_ID and invalid CIG_ID/CIS_ID
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=10d83e3423bb
- [BlueZ,v2,5/5] iso-tester: add tests checking Remove CIG is emitted
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=033b68cbb1bf
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html