tools/sco-tester: add a test case for offload SCO connect
authorKiran K <kiran.k@intel.com>
Tue, 7 Sep 2021 11:25:56 +0000 (16:55 +0530)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:36 +0000 (19:08 +0530)
Add a test case for offload SCO connect with codec type set to mSBC

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/sco-tester.c

index 67ea476..b341fa4 100755 (executable)
@@ -675,6 +675,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);
@@ -709,5 +755,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();
 }