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,
	tedd.an@intel.com, luiz.von.dentz@intel.com,
	michaelfsun@google.com, Kiran K <kiran.k@intel.com>
Subject: [PATCH v2 2/3] tools/sco-tester: Add a test case for setting offload codec
Date: Tue,  7 Sep 2021 16:55:55 +0530	[thread overview]
Message-ID: <20210907112556.11848-2-kiran.k@intel.com> (raw)
In-Reply-To: <20210907112556.11848-1-kiran.k@intel.com>

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

Notes:
    changes in v2:
     - No changes

 tools/sco-tester.c | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/tools/sco-tester.c b/tools/sco-tester.c
index 0c4d9d76e4df..67ea4769ef2b 100644
--- a/tools/sco-tester.c
+++ b/tools/sco-tester.c
@@ -375,6 +375,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;
@@ -669,5 +706,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 11:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 11:25 [PATCH v2 1/3] tools/sco-tester: add test cases to get offload codecs Kiran K
2021-09-07 11:25 ` Kiran K [this message]
2021-09-07 11:25 ` [PATCH v2 3/3] tools/sco-tester: add a test case for offload SCO connect Kiran K
2021-09-07 11:53 ` [v2,1/3] tools/sco-tester: add test cases to get offload codecs bluez.test.bot
2021-09-07 22:07   ` Luiz Augusto von Dentz

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=20210907112556.11848-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 \
    --cc=tedd.an@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.