Message ID | b3bf384b8e710156dd2a0f7ee2c21b98da9f4c79.1740684902.git.pav@iki.fi (mailing list archive) |
---|---|
State | Accepted |
Commit | 711424319562ef2efcb7ad0d5f264400f72af8fd |
Headers | show |
Series | [BlueZ] sco-tester: add test for disconnecting SCO | expand |
Context | Check | Description |
---|---|---|
tedd_an/pre-ci_am | success | Success |
tedd_an/BuildEll | success | Build ELL PASS |
tedd_an/BluezMake | success | Bluez Make PASS |
tedd_an/MakeCheck | success | Bluez Make Check PASS |
tedd_an/MakeDistcheck | success | Make Distcheck PASS |
tedd_an/CheckValgrind | success | Check Valgrind PASS |
tedd_an/CheckSmatch | warning | CheckSparse WARNING 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 |
tedd_an/bluezmakeextell | success | Make External ELL PASS |
tedd_an/ScanBuild | success | Scan Build PASS |
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
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!
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);