diff mbox series

[BlueZ,v3,8/8] test-bap: Add SCC Update Metadata tests

Message ID 20231204221527.2990674-8-luiz.dentz@gmail.com
State New
Headers show
Series [BlueZ,v3,1/8] shared/lc3: Add QoS definitions | expand

Commit Message

Luiz Augusto von Dentz Dec. 4, 2023, 10:15 p.m. UTC
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

4.8.8 Unicast Client Initiates Update Metadata Operation (Page 53):

  Test Purpose:
  Verify that a Unicast Client IUT can update the Metadata of an ASE by
  initiating an Update Metadata operation.

  Pass verdict:
  The IUT successfully writes to the ASE Control Point characteristic with the
  opcode set to 0x07 (Update Metadata) and the specified parameters.

Test Summary
------------
BAP/UCL/SCC/BV-115-C [UCL SNK Update Metadata in Enabling State] Passed
BAP/UCL/SCC/BV-116-C [UCL SRC Update Metadata in Enabling or Streaming state]
Passed
BAP/UCL/SCC/BV-117-C [UCL SNK Update Metadata in Streaming State] Passed
Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
---
 unit/test-bap.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 139 insertions(+)
diff mbox series

Patch

diff --git a/unit/test-bap.c b/unit/test-bap.c
index fa6e65219beb..ecd5e2897093 100644
--- a/unit/test-bap.c
+++ b/unit/test-bap.c
@@ -2687,6 +2687,144 @@  static void test_scc_release(void)
 			SCC_SRC_DISABLE_RELEASE);
 }
 
+static void bap_metadata(struct bt_bap_stream *stream,
+					uint8_t code, uint8_t reason,
+					void *user_data)
+{
+	if (code)
+		tester_test_failed();
+}
+
+static void state_enable_metadata(struct bt_bap_stream *stream,
+					uint8_t old_state, uint8_t new_state,
+					void *user_data)
+{
+	struct test_data *data = user_data;
+	struct iovec iov = {};
+	uint8_t id;
+
+	switch (new_state) {
+	case BT_BAP_STREAM_STATE_ENABLING:
+		id = bt_bap_stream_metadata(data->stream, &iov, bap_metadata,
+						data);
+		g_assert(id);
+		break;
+	}
+}
+
+static struct test_config cfg_snk_metadata = {
+	.cc = LC3_CONFIG_16_2,
+	.qos = LC3_QOS_16_2_1,
+	.snk = true,
+	.state = BT_BAP_STREAM_STATE_ENABLING,
+	.state_func = state_enable_metadata
+};
+
+/* ATT: Write Command (0x52) len 23
+ *  Handle: 0x0022
+ *    Data: 07010100
+ * ATT: Handle Value Notification (0x1b) len 7
+ *  Handle: 0x0022
+ *    Data: 0701010000
+ * ATT: Handle Value Notification (0x1b) len 37
+ *   Handle: 0x0016
+ *     Data: 01010102010a00204e00409c00204e00409c00_qos
+ */
+#define ASE_SNK_METADATA \
+	IOV_DATA(0x52, 0x22, 0x00, 0x07, 0x01, 0x01, 0x00), \
+	IOV_DATA(0x1b, 0x22, 0x00, 0x07, 0x01, 0x01, 0x00, 0x00), \
+	IOV_NULL, \
+	IOV_DATA(0x1b, 0x16, 0x00, 0x01, 0x05, 0x00, 0x00, 0x4c, 0x1d, 0x00, \
+			0x00, 0x02, 0x1a, 0x00, 0x02, 0x08, 0x00, 0x40, 0x9c, \
+			0x00)
+
+#define SCC_SNK_METADATA \
+	SCC_SNK_ENABLE, \
+	ASE_SNK_METADATA
+
+static struct test_config cfg_src_metadata = {
+	.cc = LC3_CONFIG_16_2,
+	.qos = LC3_QOS_16_2_1,
+	.src = true,
+	.state = BT_BAP_STREAM_STATE_ENABLING,
+	.state_func = state_enable_metadata
+};
+
+/* ATT: Write Command (0x52) len 23
+ *  Handle: 0x0022
+ *    Data: 07010300
+ * ATT: Handle Value Notification (0x1b) len 7
+ *  Handle: 0x0022
+ *    Data: 0701030000
+ * ATT: Handle Value Notification (0x1b) len 37
+ *   Handle: 0x001c
+ *     Data: 030300000403020100
+ */
+#define ASE_SRC_METADATA \
+	IOV_DATA(0x52, 0x22, 0x00, 0x07, 0x01, 0x03, 0x00), \
+	IOV_DATA(0x1b, 0x22, 0x00, 0x07, 0x01, 0x03, 0x00, 0x00), \
+	IOV_NULL, \
+	IOV_DATA(0x1b, 0x1c, 0x00, 0x03, 0x05, 0x00, 0x00, 0x4c, 0x1d, 0x00, \
+			0x00, 0x02, 0x1a, 0x00, 0x04, 0x08, 0x00, 0x40, 0x9c, \
+			0x00)
+#define SCC_SRC_METADATA \
+	SCC_SRC_ENABLE, \
+	ASE_SRC_METADATA
+
+static void state_start_metadata(struct bt_bap_stream *stream,
+					uint8_t old_state, uint8_t new_state,
+					void *user_data)
+{
+	struct test_data *data = user_data;
+	struct iovec iov = {};
+	uint8_t id;
+
+	switch (new_state) {
+	case BT_BAP_STREAM_STATE_STREAMING:
+		id = bt_bap_stream_metadata(data->stream, &iov, bap_metadata,
+						data);
+		g_assert(id);
+		break;
+	}
+}
+
+static struct test_config cfg_src_metadata_streaming = {
+	.cc = LC3_CONFIG_16_2,
+	.qos = LC3_QOS_16_2_1,
+	.src = true,
+	.state = BT_BAP_STREAM_STATE_STREAMING,
+	.state_func = state_start_metadata
+};
+
+#define SCC_SRC_METADATA_STREAMING \
+	SCC_SRC_ENABLE, \
+	ASE_SRC_START, \
+	ASE_SRC_METADATA
+
+/* Unicast Client Initiates Update Metadata Operation
+ *
+ * Test Purpose:
+ * Verify that a Unicast Client IUT can update the Metadata of an ASE by
+ * initiating an Update Metadata operation.
+ *
+ * Pass verdict:
+ * The IUT successfully writes to the ASE Control Point characteristic with the
+ * opcode set to 0x07 (Update Metadata) and the specified parameters.
+ */
+static void test_scc_metadata(void)
+{
+	define_test("BAP/UCL/SCC/BV-115-C [UCL SNK Update Metadata in Enabling "
+			"State]",
+			test_client, &cfg_src_metadata, SCC_SRC_METADATA);
+	define_test("BAP/UCL/SCC/BV-116-C [UCL SRC Update Metadata in Enabling "
+			"or Streaming state]",
+			test_client, &cfg_snk_metadata, SCC_SNK_METADATA);
+	define_test("BAP/UCL/SCC/BV-117-C [UCL SNK Update Metadata in Streaming"
+			" State]",
+			test_client, &cfg_src_metadata_streaming,
+			SCC_SRC_METADATA_STREAMING);
+}
+
 static void test_scc(void)
 {
 	test_scc_cc_lc3();
@@ -2696,6 +2834,7 @@  static void test_scc(void)
 	test_scc_enable();
 	test_scc_disable();
 	test_scc_release();
+	test_scc_metadata();
 }
 
 int main(int argc, char *argv[])