diff mbox series

[BlueZ,v2,2/2] sco-tester: Add test for BT_VOICE_TRANSPARENT_16BIT constant

Message ID 20241216184613.135538-3-frederic.danis@collabora.com (mailing list archive)
State Accepted
Commit ff07f10ee4da3d16b3be84c0acff231d2b152948
Headers show
Series Add constant for 16 bits transparent voice | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success

Commit Message

Frédéric Danis Dec. 16, 2024, 6:46 p.m. UTC
This test checks that BT_VOICE_TRANSPARENT_16BIT voice settings can
be set and get using [set|get]sockopt().
---
 tools/sco-tester.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/tools/sco-tester.c b/tools/sco-tester.c
index a56cb9153..6fc26b7af 100644
--- a/tools/sco-tester.c
+++ b/tools/sco-tester.c
@@ -527,6 +527,34 @@  static void test_setsockopt(const void *test_data)
 		goto end;
 	}
 
+	memset(&voice, 0, sizeof(voice));
+	voice.setting = BT_VOICE_TRANSPARENT_16BIT;
+
+	err = setsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, sizeof(voice));
+	if (err < 0) {
+		tester_warn("Can't set socket option : %s (%d)",
+							strerror(errno), errno);
+		tester_test_failed();
+		goto end;
+	}
+
+	len = sizeof(voice);
+	memset(&voice, 0, len);
+
+	err = getsockopt(sk, SOL_BLUETOOTH, BT_VOICE, &voice, &len);
+	if (err < 0) {
+		tester_warn("Can't get socket option : %s (%d)",
+							strerror(errno), errno);
+		tester_test_failed();
+		goto end;
+	}
+
+	if (voice.setting != BT_VOICE_TRANSPARENT_16BIT) {
+		tester_warn("Invalid voice setting");
+		tester_test_failed();
+		goto end;
+	}
+
 	memset(&voice, 0, sizeof(voice));
 	voice.setting = BT_VOICE_TRANSPARENT;