* [PATCH BlueZ] sco-tester: add test for disconnecting SCO
@ 2025-02-27 19:36 Pauli Virtanen
2025-02-27 21:15 ` [BlueZ] " bluez.test.bot
2025-02-28 20:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
0 siblings, 2 replies; 3+ messages in thread
From: Pauli Virtanen @ 2025-02-27 19:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Pauli Virtanen, eadavis, luiz.von.dentz
Add test that checks that shutdown(sk) results to
HCI_Disconnection_Complete for the SCO handle:
SCO Disconnect - Success
---
Notes:
It seems after the following commit closing SCO connections no longer
works, as kernel does not seem to be sending HCI Disconnect after the
SCO socket is shutdown & closed:
commit ed9588554943 ("Bluetooth: SCO: remove the redundant sco_conn_put")
The test added here passes with that commit reverted.
tools/sco-tester.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/tools/sco-tester.c b/tools/sco-tester.c
index 6fc26b7af..7f37ca5cf 100644
--- a/tools/sco-tester.c
+++ b/tools/sco-tester.c
@@ -45,6 +45,7 @@ struct test_data {
bool disable_esco;
bool enable_codecs;
int step;
+ uint16_t handle;
struct tx_tstamp_data tx_ts;
};
@@ -53,6 +54,9 @@ struct sco_client_data {
const uint8_t *send_data;
uint16_t data_len;
+ /* Shutdown socket after connect */
+ bool shutdown;
+
/* Enable SO_TIMESTAMPING with these flags */
uint32_t so_timestamping;
@@ -268,6 +272,11 @@ static const struct sco_client_data connect_success = {
.expect_err = 0
};
+static const struct sco_client_data disconnect_success = {
+ .expect_err = 0,
+ .shutdown = true,
+};
+
static const struct sco_client_data connect_failure = {
.expect_err = EOPNOTSUPP
};
@@ -751,6 +760,11 @@ static gboolean sco_connect_cb(GIOChannel *io, GIOCondition cond,
}
}
+ if (scodata->shutdown) {
+ tester_print("Disconnecting...");
+ shutdown(sk, SHUT_RDWR);
+ }
+
if (-err != scodata->expect_err)
tester_test_failed();
else if (!data->step)
@@ -875,6 +889,69 @@ end:
close(sk);
}
+static bool hook_setup_sync_evt(const void *buf, uint16_t len, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct bt_hci_evt_sync_conn_complete *evt = buf;
+
+ if (len < sizeof(*evt)) {
+ tester_warn("Bad event size");
+ tester_test_failed();
+ return true;
+ }
+
+ data->handle = le16_to_cpu(evt->handle);
+ tester_print("SCO Handle %u", data->handle);
+ return true;
+}
+
+static bool hook_disconnect_evt(const void *buf, uint16_t len, void *user_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct bt_hci_evt_disconnect_complete *evt = buf;
+ uint16_t handle;
+
+ if (len < sizeof(*evt)) {
+ tester_warn("Bad event size");
+ tester_test_failed();
+ return true;
+ }
+
+ handle = le16_to_cpu(evt->handle);
+ tester_print("Disconnected Handle %u", handle);
+
+ if (handle != data->handle)
+ return true;
+
+ if (evt->status) {
+ tester_test_failed();
+ return true;
+ }
+
+ data->step--;
+ if (!data->step)
+ tester_test_passed();
+
+ return true;
+}
+
+static void test_disconnect(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+
+ data->step++;
+
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_EVT,
+ BT_HCI_EVT_SYNC_CONN_COMPLETE,
+ hook_setup_sync_evt, NULL);
+
+ hciemu_add_hook(data->hciemu, HCIEMU_HOOK_POST_EVT,
+ BT_HCI_EVT_DISCONNECT_COMPLETE,
+ hook_disconnect_evt, NULL);
+
+ test_connect(test_data);
+}
+
static bool hook_simult_disc(const void *msg, uint16_t len, void *user_data)
{
const struct bt_hci_evt_sync_conn_complete *ev = msg;
@@ -972,6 +1049,9 @@ int main(int argc, char *argv[])
test_sco("eSCO mSBC - Success", &connect_success, setup_powered,
test_connect_transp);
+ test_sco("SCO Disconnect - Success", &disconnect_success, setup_powered,
+ test_disconnect);
+
test_sco("eSCO Simultaneous Disconnect - Failure",
&connect_failure_reset, setup_powered,
test_connect_simult_disc);
--
2.48.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* RE: [BlueZ] sco-tester: add test for disconnecting SCO
2025-02-27 19:36 [PATCH BlueZ] sco-tester: add test for disconnecting SCO Pauli Virtanen
@ 2025-02-27 21:15 ` bluez.test.bot
2025-02-28 20:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2025-02-27 21:15 UTC (permalink / raw)
To: linux-bluetooth, pav
[-- Attachment #1: Type: text/plain, Size: 1532 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=938658
---Test result---
Test Summary:
CheckPatch PENDING 0.20 seconds
GitLint PENDING 0.22 seconds
BuildEll PASS 21.15 seconds
BluezMake PASS 1610.57 seconds
MakeCheck PASS 13.42 seconds
MakeDistcheck PASS 163.53 seconds
CheckValgrind PASS 220.02 seconds
CheckSmatch WARNING 293.41 seconds
bluezmakeextell PASS 103.51 seconds
IncrementalBuild PENDING 0.24 seconds
ScanBuild PASS 936.72 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.h:232:15: warning: array of flexible structures./lib/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] 3+ messages in thread
* Re: [PATCH BlueZ] sco-tester: add test for disconnecting SCO
2025-02-27 19:36 [PATCH BlueZ] sco-tester: add test for disconnecting SCO Pauli Virtanen
2025-02-27 21:15 ` [BlueZ] " bluez.test.bot
@ 2025-02-28 20:40 ` patchwork-bot+bluetooth
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2025-02-28 20:40 UTC (permalink / raw)
To: Pauli Virtanen; +Cc: linux-bluetooth, eadavis, luiz.von.dentz
Hello:
This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Thu, 27 Feb 2025 21:36:42 +0200 you wrote:
> Add test that checks that shutdown(sk) results to
> HCI_Disconnection_Complete for the SCO handle:
>
> SCO Disconnect - Success
> ---
>
> Notes:
> It seems after the following commit closing SCO connections no longer
> works, as kernel does not seem to be sending HCI Disconnect after the
> SCO socket is shutdown & closed:
>
> [...]
Here is the summary with links:
- [BlueZ] sco-tester: add test for disconnecting SCO
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=711424319562
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-02-28 20:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 19:36 [PATCH BlueZ] sco-tester: add test for disconnecting SCO Pauli Virtanen
2025-02-27 21:15 ` [BlueZ] " bluez.test.bot
2025-02-28 20:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox