* [PATCH BlueZ] sco-tester: add timeout / close during connection tests
@ 2025-11-23 20:10 Pauli Virtanen
2025-11-23 21:00 ` [BlueZ] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Pauli Virtanen @ 2025-11-23 20:10 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Pauli Virtanen
Add tests:
eSCO CVSD - Timeout
eSCO CVSD - Close
---
tools/sco-tester.c | 77 +++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 70 insertions(+), 7 deletions(-)
diff --git a/tools/sco-tester.c b/tools/sco-tester.c
index d2ab51b35..660f36e07 100644
--- a/tools/sco-tester.c
+++ b/tools/sco-tester.c
@@ -56,9 +56,15 @@ struct sco_client_data {
const uint8_t *send_data;
uint16_t data_len;
+ /* Connect timeout */
+ unsigned int connect_timeout_us;
+
/* Shutdown socket after connect */
bool shutdown;
+ /* Close socket after connect */
+ bool close_after_connect;
+
/* Enable SO_TIMESTAMPING with these flags */
uint32_t so_timestamping;
@@ -247,7 +253,7 @@ static void test_data_free(void *test_data)
}
#define test_sco_full(name, data, setup, func, _disable_esco, _enable_codecs, \
- _disable_sco_flowctl) \
+ _disable_sco_flowctl, _timeout) \
do { \
struct test_data *user; \
user = malloc(sizeof(struct test_data)); \
@@ -264,28 +270,39 @@ static void test_data_free(void *test_data)
user->disable_sco_flowctl = _disable_sco_flowctl; \
tester_add_full(name, data, \
test_pre_setup, setup, func, NULL, \
- test_post_teardown, 2, user, test_data_free); \
+ test_post_teardown, _timeout, user, \
+ test_data_free); \
} while (0)
#define test_sco(name, data, setup, func) \
- test_sco_full(name, data, setup, func, false, false, false)
+ test_sco_full(name, data, setup, func, false, false, false, 2)
#define test_sco_no_flowctl(name, data, setup, func) \
- test_sco_full(name, data, setup, func, false, false, true)
+ test_sco_full(name, data, setup, func, false, false, true, 2)
#define test_sco_11(name, data, setup, func) \
- test_sco_full(name, data, setup, func, true, false, false)
+ test_sco_full(name, data, setup, func, true, false, false, 2)
#define test_sco_11_no_flowctl(name, data, setup, func) \
- test_sco_full(name, data, setup, func, true, false, true)
+ test_sco_full(name, data, setup, func, true, false, true, 2)
#define test_offload_sco(name, data, setup, func) \
- test_sco_full(name, data, setup, func, false, true, false)
+ test_sco_full(name, data, setup, func, false, true, false, 2)
static const struct sco_client_data connect_success = {
.expect_err = 0
};
+static const struct sco_client_data connect_timeout = {
+ .expect_err = ETIMEDOUT,
+ .connect_timeout_us = 1,
+};
+
+/* Check timeout handling if closed before connect finishes */
+static const struct sco_client_data connect_close = {
+ .close_after_connect = true,
+};
+
static const struct sco_client_data disconnect_success = {
.expect_err = 0,
.shutdown = true,
@@ -684,6 +701,7 @@ end:
static int create_sco_sock(struct test_data *data)
{
+ const struct sco_client_data *scodata = data->test_data;
const uint8_t *central_bdaddr;
struct sockaddr_sco addr;
int sk, err;
@@ -697,6 +715,19 @@ static int create_sco_sock(struct test_data *data)
return err;
}
+ if (scodata->connect_timeout_us) {
+ struct timeval timeout = {
+ .tv_sec = scodata->connect_timeout_us / 1000000,
+ .tv_usec = scodata->connect_timeout_us % 1000000
+ };
+
+ if (setsockopt(sk, SOL_SOCKET, SO_SNDTIMEO,
+ (void *)&timeout, sizeof(timeout))) {
+ tester_warn("failed to set timeout: %m");
+ return -EINVAL;
+ }
+ }
+
central_bdaddr = hciemu_get_central_bdaddr(data->hciemu);
if (!central_bdaddr) {
tester_warn("No central bdaddr");
@@ -923,6 +954,7 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond,
static void test_connect(const void *test_data)
{
struct test_data *data = tester_get_data();
+ const struct sco_client_data *scodata = data->test_data;
GIOChannel *io;
int sk;
@@ -938,6 +970,12 @@ static void test_connect(const void *test_data)
return;
}
+ if (scodata->close_after_connect) {
+ close(sk);
+ tester_test_passed();
+ return;
+ }
+
data->sk = sk;
io = g_io_channel_unix_new(sk);
@@ -1036,6 +1074,25 @@ end:
close(sk);
}
+static bool hook_delay_evt(const void *msg, uint16_t len, void *user_data)
+{
+ tester_print("Delaying emulator response...");
+ g_usleep(500000);
+ tester_print("Delaying emulator response... Done.");
+ return true;
+}
+
+static void test_connect_delayed(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_EVT,
+ BT_HCI_EVT_SYNC_CONN_COMPLETE,
+ hook_delay_evt, NULL);
+
+ test_connect(test_data);
+}
+
static bool hook_setup_sync_evt(const void *buf, uint16_t len, void *user_data)
{
struct test_data *data = tester_get_data();
@@ -1201,6 +1258,12 @@ int main(int argc, char *argv[])
test_sco("eSCO CVSD - Success", &connect_success, setup_powered,
test_connect);
+ test_sco_full("eSCO CVSD - Timeout", &connect_timeout, setup_powered,
+ test_connect_delayed, false, false, false, 8);
+
+ test_sco("eSCO CVSD - Close", &connect_close, setup_powered,
+ test_connect_delayed);
+
test_sco("eSCO mSBC - Success", &connect_success, setup_powered,
test_connect_transp);
--
2.51.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [BlueZ] sco-tester: add timeout / close during connection tests
2025-11-23 20:10 [PATCH BlueZ] sco-tester: add timeout / close during connection tests Pauli Virtanen
@ 2025-11-23 21:00 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2025-11-23 21:00 UTC (permalink / raw)
To: linux-bluetooth, pav
[-- Attachment #1: Type: text/plain, Size: 1552 bytes --]
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=1026741
---Test result---
Test Summary:
CheckPatch PENDING 0.29 seconds
GitLint PENDING 0.29 seconds
BuildEll PASS 20.25 seconds
BluezMake PASS 632.41 seconds
MakeCheck PASS 21.81 seconds
MakeDistcheck PASS 238.19 seconds
CheckValgrind PASS 295.20 seconds
CheckSmatch WARNING 342.21 seconds
bluezmakeextell PASS 180.04 seconds
IncrementalBuild PENDING 0.27 seconds
ScanBuild PASS 964.89 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:
tools/sco-tester.c: note: in included file:./lib/bluetooth/bluetooth.h:232:15: warning: array of flexible structures./lib/bluetooth/bluetooth.h:237:31: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-23 21:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-23 20:10 [PATCH BlueZ] sco-tester: add timeout / close during connection tests Pauli Virtanen
2025-11-23 21:00 ` [BlueZ] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox