Skip to contentSkip to conversation

tools/sco-tester: add test cases to get offload codecs

PATCH Superseded Kiran K 2 participants 4 messages Sep 7, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kiran K

author
#0 lore raw

PATCH 1/3 tools/sco-tester: add test cases to get offload codecs

Add a test case to query offload codecs supported over sco

---
 lib/bluetooth.h    | 18 +++++++++++
 tools/sco-tester.c | 79 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 94 insertions(+), 3 deletions(-)
lib/bluetooth.h +18 -0
index 9ab033ec41a4..0fcf412c6c6b 100644
@@ -140,6 +140,24 @@ struct bt_voice {
 
 #define BT_SCM_PKT_STATUS	0x03
 
+#define BT_CODEC 19
+struct bt_codec {
+	uint8_t id;
+	uint16_t cid;
+	uint16_t vid;
+	uint8_t data_path_id;
+	uint8_t num_caps;
+	struct codec_caps {
+		uint8_t len;
+		uint8_t data[];
+	} caps[];
+} __attribute__((packed));
+
+struct bt_codecs {
+	uint8_t num_codecs;
+	struct bt_codec codecs[];
+} __attribute__((packed));
+
 /* Connection and socket states */
 enum {
 	BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
tools/sco-tester.c +76 -3

128 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 2/3 tools/sco-tester: Add a test case for setting offload codec

Add a test case to set codec for HFP offload use case

---
 tools/sco-tester.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
tools/sco-tester.c +40 -0
index bcef4ef8f76d..e412111ffd42 100644
@@ -378,6 +378,43 @@ end:
 	close(sk);
 }
 
+static void test_codecs_setsockopt(const void *test_data)
+{
+	int sk, err;
+	char buffer[255];
+	struct bt_codecs *codecs;
+
+	sk = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_SCO);
+	if (sk < 0) {
+		tester_warn("Can't create socket: %s (%d)", strerror(errno),
+									errno);
+		tester_test_failed();
+		return;
+	}
+
+	memset(buffer, 0, sizeof(buffer));
+
+	codecs = (void *)buffer;
+
+	codecs->codecs[0].id = 0x05;
+	codecs->num_codecs = 1;
+	codecs->codecs[0].data_path_id = 1;
+	codecs->codecs[0].num_caps = 0x00;
+
+	err = setsockopt(sk, SOL_BLUETOOTH, BT_CODEC, codecs, sizeof(buffer));
+	if (err < 0) {
+		tester_warn("Can't set socket option : %s (%d)",
+			    strerror(errno), errno);
+		tester_test_failed();
+		goto end;
+	}
+
+	tester_test_passed();
+
+end:
+	close(sk);
+}
+
 static void test_getsockopt(const void *test_data)
 {
 	int sk, err;
@@ -672,5 +709,8 @@ int main(int argc, char *argv[])
 	test_offload_sco("Basic SCO Get Socket Option - Offload - Success",
 				NULL, setup_powered, test_codecs_getsockopt);
 
+	test_offload_sco("Basic SCO Set Socket Option - Offload - Success",
+				NULL, setup_powered, test_codecs_setsockopt);
+
 	return tester_run();
 }
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH 3/3 tools/sco-tester: add a test case for offload SCO connect

In reply to Kiran K

Add a test case for offload SCO connect with codec type set to mSBC

---
 tools/sco-tester.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
tools/sco-tester.c +49 -0
index e412111ffd42..06d3700f009c 100644
@@ -678,6 +678,52 @@ end:
 	close(sk);
 }
 
+static void test_connect_offload_msbc(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct sco_client_data *scodata = data->test_data;
+	int sk, err;
+	int len;
+	char buffer[255];
+	struct bt_codecs *codecs;
+
+	sk = create_sco_sock(data);
+	if (sk < 0) {
+		tester_test_failed();
+		return;
+	}
+
+	len = sizeof(buffer);
+	memset(buffer, 0, len);
+
+	codecs = (void *)buffer;
+
+	codecs->codecs[0].id = 0x05;
+	codecs->num_codecs = 1;
+	codecs->codecs[0].data_path_id = 1;
+	codecs->codecs[0].num_caps = 0x00;
+
+	err = setsockopt(sk, SOL_BLUETOOTH, BT_CODEC, codecs, sizeof(buffer));
+	if (err < 0) {
+		tester_warn("Can't set socket option : %s (%d)",
+			    strerror(errno), errno);
+		tester_test_failed();
+		goto end;
+	}
+	err = connect_sco_sock(data, sk);
+
+	tester_warn("Connect returned %s (%d), expected %s (%d)",
+			strerror(-err), -err,
+			strerror(scodata->expect_err), scodata->expect_err);
+
+	if (-err != scodata->expect_err)
+		tester_test_failed();
+	else
+		tester_test_passed();
+
+end:
+	close(sk);
+}
 int main(int argc, char *argv[])
 {
 	tester_init(&argc, &argv);
@@ -712,5 +758,8 @@ int main(int argc, char *argv[])
 	test_offload_sco("Basic SCO Set Socket Option - Offload - Success",
 				NULL, setup_powered, test_codecs_setsockopt);
 
+	test_offload_sco("eSCO mSBC - Offload - Success",
+		&connect_success, setup_powered, test_connect_offload_msbc);
+
 	return tester_run();
 }
Signature · 1 line
2.17.1
#3 lore raw
In reply to Kiran K

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=543037

---Test result---

Test Summary:

CheckPatch                    FAIL      0.97 seconds
GitLint                       PASS      0.43 seconds
Prep - Setup ELL              PASS      53.31 seconds
Build - Prep                  PASS      0.16 seconds
Build - Configure             PASS      9.31 seconds
Build - Make                  FAIL      91.77 seconds
Make Check                    FAIL      0.54 seconds
Make Distcheck                PASS      280.86 seconds
Build w/ext ELL - Configure   PASS      9.66 seconds
Build w/ext ELL - Make        FAIL      78.42 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script with rule in .checkpatch.conf
Output:
tools/sco-tester: add test cases to get offload codecs WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #27: FILE: lib/bluetooth.h:154:
+} __attribute__((packed));

WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #32: FILE: lib/bluetooth.h:159:
+} __attribute__((packed));

- total: 0 errors, 2 warnings, 152 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

"[PATCH] tools/sco-tester: add test cases to get offload codecs" has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - PASS
Desc: Run gitlint with rule in .gitlint

##############################
Test: Prep - Setup ELL - PASS
Desc: Clone, build, and install ELL

##############################
Test: Build - Prep - PASS
Desc: Prepare environment for build

##############################
Test: Build - Configure - PASS
Desc: Configure the BlueZ source tree

##############################
Test: Build - Make - FAIL
Desc: Build the BlueZ source tree
Output:
tools/sco-tester.c: In function ‘enable_codec_callback’:
tools/sco-tester.c:131:20: error: unused variable ‘data’ [-Werror=unused-variable]
131 | struct test_data *data = tester_get_data();
| ^~~~
tools/sco-tester.c: In function ‘test_codecs_getsockopt’:
tools/sco-tester.c:354:20: error: unused variable ‘codecs’ [-Werror=unused-variable]

  354 |  struct bt_codecs *codecs;
      |                    ^~~~~~

cc1: all warnings being treated as errors make[1]: *** [Makefile:6962: tools/sco-tester.o] Error 1
make: *** [Makefile:4151: all] Error 2

##############################
Test: Make Check - FAIL
Desc: Run 'make check'
Output:
tools/sco-tester.c: In function ‘enable_codec_callback’:
tools/sco-tester.c:131:20: error: unused variable ‘data’ [-Werror=unused-variable]
131 | struct test_data *data = tester_get_data();
| ^~~~
tools/sco-tester.c: In function ‘test_codecs_getsockopt’:
tools/sco-tester.c:354:20: error: unused variable ‘codecs’ [-Werror=unused-variable]

  354 |  struct bt_codecs *codecs;
      |                    ^~~~~~

cc1: all warnings being treated as errors make[1]: *** [Makefile:6962: tools/sco-tester.o] Error 1
make: *** [Makefile:10443: check] Error 2

##############################
Test: Make Distcheck - PASS
Desc: Run distcheck to check the distribution

##############################
Test: Build w/ext ELL - Configure - PASS
Desc: Configure BlueZ source with '--enable-external-ell' configuration

##############################
Test: Build w/ext ELL - Make - FAIL
Desc: Build BlueZ source with '--enable-external-ell' configuration Output:
tools/sco-tester.c: In function ‘enable_codec_callback’:
tools/sco-tester.c:131:20: error: unused variable ‘data’ [-Werror=unused-variable]
131 | struct test_data *data = tester_get_data();
| ^~~~
tools/sco-tester.c: In function ‘test_codecs_getsockopt’:
tools/sco-tester.c:354:20: error: unused variable ‘codecs’ [-Werror=unused-variable]

  354 |  struct bt_codecs *codecs;
      |                    ^~~~~~

cc1: all warnings being treated as errors make[1]: *** [Makefile:6962: tools/sco-tester.o] Error 1
make: *** [Makefile:4151: all] Error 2

---
Regards,
Linux Bluetooth