All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kiran K <kiran.k@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: ravishankar.srivatsa@intel.com, chethan.tumkur.narayan@intel.com,
	luiz.von.dentz@intel.com, michaelfsun@google.com,
	Kiran K <kiran.k@intel.com>
Subject: [PATCH v1 2/3] tools/sco-tester: Add a test case for setting offload codec
Date: Tue,  7 Sep 2021 15:45:19 +0530	[thread overview]
Message-ID: <20210907101520.8473-2-kiran.k@intel.com> (raw)
In-Reply-To: <20210907101520.8473-1-kiran.k@intel.com>

Add a test case to set codec for HFP offload use case
---
 tools/sco-tester.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tools/sco-tester.c b/tools/sco-tester.c
index bcef4ef8f76d..e412111ffd42 100644
--- a/tools/sco-tester.c
+++ b/tools/sco-tester.c
@@ -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();
 }
-- 
2.17.1


  reply	other threads:[~2021-09-07 10:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 10:15 [PATCH v1 1/3] tools/sco-tester: add test cases to get offload codecs Kiran K
2021-09-07 10:15 ` Kiran K [this message]
2021-09-07 10:15 ` [PATCH v1 3/3] tools/sco-tester: add a test case for offload SCO connect Kiran K
2021-09-07 10:36 ` [v1,1/3] tools/sco-tester: add test cases to get offload codecs bluez.test.bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210907101520.8473-2-kiran.k@intel.com \
    --to=kiran.k@intel.com \
    --cc=chethan.tumkur.narayan@intel.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.von.dentz@intel.com \
    --cc=michaelfsun@google.com \
    --cc=ravishankar.srivatsa@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.