[PATCH BlueZ] sco-tester: Add tests for sending data
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Date: 2021-09-15 23:01:59
Subsystem:
the rest · Maintainer:
Linus Torvalds
From: Luiz Augusto von Dentz <redacted> This adds tests for sending data over the socket. --- tools/sco-tester.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
diff --git a/tools/sco-tester.c b/tools/sco-tester.c
index b341fa49f..b31fd5aac 100644
--- a/tools/sco-tester.c
+++ b/tools/sco-tester.c@@ -43,6 +43,8 @@ struct test_data { struct sco_client_data { int expect_err; + const uint8_t *send_data; + uint16_t data_len; }; static void print_debug(const char *str, void *user_data)
@@ -248,6 +250,14 @@ static const struct sco_client_data connect_failure = { .expect_err = EOPNOTSUPP }; +const uint8_t data[] = {0, 1, 2, 3, 4, 5, 6, 7, 8}; + +static const struct sco_client_data connect_send_success = { + .expect_err = 0, + .data_len = sizeof(data), + .send_data = data +}; + static void client_connectable_complete(uint16_t opcode, uint8_t status, const void *param, uint8_t len, void *user_data)
@@ -600,6 +610,20 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond, else tester_print("Successfully connected"); + if (scodata->send_data) { + ssize_t ret; + + tester_print("Writing %u bytes of data", scodata->data_len); + + ret = write(sk, scodata->send_data, scodata->data_len); + if (scodata->data_len != ret) { + tester_warn("Failed to write %u bytes: %zu %s (%d)", + scodata->data_len, ret, strerror(errno), + errno); + err = -errno; + } + } + if (-err != scodata->expect_err) tester_test_failed(); else
@@ -749,6 +773,9 @@ int main(int argc, char *argv[]) test_sco_11("SCO mSBC 1.1 - Failure", &connect_failure, setup_powered, test_connect_transp); + test_sco("SCO CVSD Send - Success", &connect_send_success, + setup_powered, test_connect); + test_offload_sco("Basic SCO Get Socket Option - Offload - Success", NULL, setup_powered, test_codecs_getsockopt);
--
2.31.1