diff mbox series

[BlueZ,v2,4/5] iso-tester: test with large CIS_ID and invalid CIG_ID/CIS_ID

Message ID 4126dc74da175954db56a40d4fa9cf47448c4e6c.1690907478.git.pav@iki.fi (mailing list archive)
State Accepted
Commit 10d83e3423bb3cc59fc0b5cb680c466b8658edfa
Headers show
Series Additional tests for ISO and hci_sync | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 19: B2 Line has trailing whitespace: " " 21: B2 Line has trailing whitespace: " " 22: B1 Line exceeds max length (83>80): " ISO QoS CIG 0xF0 - Invalid Timed out 2.301 seconds" 23: B1 Line exceeds max length (83>80): " ISO QoS CIS 0xF0 - Invalid Failed 0.117 seconds" 24: B1 Line exceeds max length (83>80): " ISO Connect2 CIG 0x01 - Success/Invalid Failed 0.189 seconds" 25: B1 Line exceeds max length (83>80): " ISO AC 6(ii) CIS 0xEF/auto - Success Failed 0.196 seconds"
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Pauli Virtanen Aug. 1, 2023, 4:38 p.m. UTC
Add test with a large CIS_ID and multiple CIS so it hits an error
condition in current kernels (which is why the AC configuration is
used).

Add tests for invalid configurations with bad or duplicate IDs, and for
trying to connect two CIS in same CIG without BT_DEFER_SETUP.

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

Notes:
    v2: no change
    
    Current bluetooth-next/master fails these tests with
    
    ISO QoS CIG 0xF0 - Invalid                           Timed out    2.301 seconds
    ISO QoS CIS 0xF0 - Invalid                           Failed       0.117 seconds
    ISO Connect2 CIG 0x01 - Success/Invalid              Failed       0.189 seconds
    ISO AC 6(ii) CIS 0xEF/auto - Success                 Failed       0.196 seconds

 tools/iso-tester.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 72 insertions(+)
diff mbox series

Patch

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 8f43d7bec..9f853a0f9 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -95,6 +95,10 @@ 
 	QOS_FULL(0x01, 0x02, \
 		{}, QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
 
+#define QOS_OUT_1_EF(_interval, _latency, _sdu, _phy, _rtn) \
+	QOS_FULL(0x01, 0xEF, \
+		{}, QOS_IO(_interval, _latency, _sdu, _phy, _rtn))
+
 #define QOS_IN(_interval, _latency, _sdu, _phy, _rtn) \
 	QOS_FULL(BT_ISO_QOS_CIG_UNSET, BT_ISO_QOS_CIS_UNSET, \
 		QOS_IO(_interval, _latency, _sdu, _phy, _rtn), {})
@@ -172,6 +176,7 @@ 
  */
 #define AC_6ii_1 QOS_OUT_1(10000, 10, 40, 0x02, 2)
 #define AC_6ii_2 QOS_OUT_1(10000, 10, 40, 0x02, 2)
+#define AC_6ii_1_EF QOS_OUT_1_EF(10000, 10, 40, 0x02, 2)  /* different CIS ID */
 /* Two unidirectional CISes. Unicast Server is Audio Sink and Audio Source.
  * #1 - CIG 1 CIS 1 (input)
  * #2 - CIG 1 CIS 2 (output)
@@ -801,6 +806,16 @@  static const struct iso_client_data connect_reject = {
 	.expect_err = -ENOSYS
 };
 
+static const struct iso_client_data connect_cig_f0_invalid = {
+	.qos = QOS_FULL(0xF0, 0x00, {}, QOS_IO(10000, 10, 40, 0x02, 2)),
+	.expect_err = -EINVAL
+};
+
+static const struct iso_client_data connect_cis_f0_invalid = {
+	.qos = QOS_FULL(0x00, 0xF0, {}, QOS_IO(10000, 10, 40, 0x02, 2)),
+	.expect_err = -EINVAL
+};
+
 static const uint8_t data_16_2_1[40] = { [0 ... 39] = 0xff };
 static const struct iovec send_16_2_1 = {
 	.iov_base = (void *)data_16_2_1,
@@ -960,6 +975,22 @@  static const struct iso_client_data reconnect_ac_6ii = {
 	.disconnect = true,
 };
 
+static const struct iso_client_data connect_ac_6ii_cis_ef_auto = {
+	.qos = AC_6ii_1_EF,
+	.qos_2 = AC_6ii_2,
+	.expect_err = 0,
+	.mconn = true,
+	.defer = true,
+};
+
+static const struct iso_client_data connect_ac_6ii_cis_ef_ef = {
+	.qos = AC_6ii_1_EF,
+	.qos_2 = AC_6ii_1_EF,
+	.expect_err = -EINVAL,
+	.mconn = true,
+	.defer = true,
+};
+
 static const struct iso_client_data connect_ac_7i = {
 	.qos = AC_7i_1,
 	.qos_2 = AC_7i_2,
@@ -2371,6 +2402,29 @@  static void test_connect2_seq(const void *test_data)
 	setup_connect(data, 0, iso_connect2_seq_cb);
 }
 
+static void test_connect2_nodefer(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	int sk, err;
+
+	/* Second connect() shall fail, because CIG is then busy,
+	 * but the first connect() shall succeed.
+	 */
+	setup_connect(data, 0, iso_connect_cb);
+
+	sk = create_iso_sock(data);
+	if (sk < 0) {
+		tester_test_failed();
+		return;
+	}
+
+	err = connect_iso_sock(data, 1, sk);
+	if (err != -EINVAL)
+		tester_test_failed();
+
+	close(sk);
+}
+
 static void test_bcast(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -2518,6 +2572,12 @@  int main(int argc, char *argv[])
 	test_iso("ISO QoS - Invalid", &connect_invalid, setup_powered,
 							test_connect);
 
+	test_iso("ISO QoS CIG 0xF0 - Invalid", &connect_cig_f0_invalid,
+			setup_powered, test_connect);
+
+	test_iso("ISO QoS CIS 0xF0 - Invalid", &connect_cis_f0_invalid,
+			setup_powered, test_connect);
+
 	test_iso_rej("ISO Connect - Reject", &connect_reject, setup_powered,
 			test_connect, BT_HCI_ERR_CONN_FAILED_TO_ESTABLISH);
 
@@ -2545,6 +2605,10 @@  int main(int argc, char *argv[])
 							setup_powered,
 							test_connect2);
 
+	test_iso2("ISO Connect2 CIG 0x01 - Success/Invalid", &connect_1_16_2_1,
+							setup_powered,
+							test_connect2_nodefer);
+
 	test_iso("ISO Defer Send - Success", &connect_16_2_1_defer_send,
 							setup_powered,
 							test_connect);
@@ -2630,6 +2694,14 @@  int main(int argc, char *argv[])
 							setup_powered,
 							test_reconnect);
 
+	test_iso2("ISO AC 6(ii) CIS 0xEF/auto - Success",
+						&connect_ac_6ii_cis_ef_auto,
+						setup_powered, test_connect);
+
+	test_iso2("ISO AC 6(ii) CIS 0xEF/0xEF - Invalid",
+						&connect_ac_6ii_cis_ef_ef,
+						setup_powered, test_connect);
+
 	test_iso("ISO Broadcaster - Success", &bcast_16_2_1_send, setup_powered,
 							test_bcast);
 	test_iso("ISO Broadcaster Encrypted - Success", &bcast_enc_16_2_1_send,