* [PATCH BlueZ v2 1/4] shared/bap: ignore NULL attach/detach callbacks
2025-06-20 13:51 [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments Kirill Samburskiy
@ 2025-06-20 13:51 ` Kirill Samburskiy
2025-06-20 15:12 ` test-vcp: Fix test failing in some environments bluez.test.bot
2025-06-20 13:51 ` [PATCH BlueZ v2 2/4] test-vcp: remove unnecessary bt_vcp allocation Kirill Samburskiy
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Kirill Samburskiy @ 2025-06-20 13:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Kirill Samburskiy
Allow registering NULL attach/detach callbacks with bt_bap_register
for cases when one of callbacks is not needed, e.g. in tests.
---
src/shared/bap.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/shared/bap.c b/src/shared/bap.c
index f0c6f6485..76340d565 100644
--- a/src/shared/bap.c
+++ b/src/shared/bap.c
@@ -4415,6 +4415,9 @@ static void bap_detached(void *data, void *user_data)
struct bt_bap_cb *cb = data;
struct bt_bap *bap = user_data;
+ if (!cb->detached)
+ return;
+
cb->detached(bap, cb->user_data);
}
@@ -4499,6 +4502,9 @@ static void bap_attached(void *data, void *user_data)
struct bt_bap_cb *cb = data;
struct bt_bap *bap = user_data;
+ if (!cb->attached)
+ return;
+
cb->attached(bap, cb->user_data);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* RE: test-vcp: Fix test failing in some environments
2025-06-20 13:51 ` [PATCH BlueZ v2 1/4] shared/bap: ignore NULL attach/detach callbacks Kirill Samburskiy
@ 2025-06-20 15:12 ` bluez.test.bot
0 siblings, 0 replies; 7+ messages in thread
From: bluez.test.bot @ 2025-06-20 15:12 UTC (permalink / raw)
To: linux-bluetooth, k.samburskiy
[-- Attachment #1: Type: text/plain, Size: 1864 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=974291
---Test result---
Test Summary:
CheckPatch PENDING 0.44 seconds
GitLint PENDING 0.40 seconds
BuildEll PASS 20.10 seconds
BluezMake PASS 2643.80 seconds
MakeCheck PASS 20.88 seconds
MakeDistcheck PASS 196.59 seconds
CheckValgrind PASS 274.06 seconds
CheckSmatch WARNING 306.77 seconds
bluezmakeextell PASS 127.66 seconds
IncrementalBuild PENDING 0.39 seconds
ScanBuild PASS 918.78 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:
src/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: warning: array of flexible structuressrc/shared/bap.c:317:25: warning: array of flexible structuressrc/shared/bap.c: note: in included file:./src/shared/ascs.h:88:25: 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] 7+ messages in thread
* [PATCH BlueZ v2 2/4] test-vcp: remove unnecessary bt_vcp allocation
2025-06-20 13:51 [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments Kirill Samburskiy
2025-06-20 13:51 ` [PATCH BlueZ v2 1/4] shared/bap: ignore NULL attach/detach callbacks Kirill Samburskiy
@ 2025-06-20 13:51 ` Kirill Samburskiy
2025-06-20 13:51 ` [PATCH BlueZ v2 3/4] test-micp: remove unnecessary bt_micp allocation Kirill Samburskiy
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Kirill Samburskiy @ 2025-06-20 13:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Kirill Samburskiy
Do not create bt_vcp in test_server since it is not necessary for this
test. Also register bt_vcp detached callback to unref and free
objects created by vcp_get_session.
---
unit/test-vcp.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/unit/test-vcp.c b/unit/test-vcp.c
index 6a61ea2c4..2a6e77eb0 100644
--- a/unit/test-vcp.c
+++ b/unit/test-vcp.c
@@ -33,11 +33,11 @@
struct test_data {
struct gatt_db *db;
- struct bt_vcp *vcp;
struct bt_gatt_server *server;
struct queue *ccc_states;
size_t iovcnt;
struct iovec *iov;
+ unsigned int vcp_id;
};
struct notify {
@@ -82,7 +82,6 @@ static void test_teardown(const void *user_data)
{
struct test_data *data = (void *)user_data;
- bt_vcp_unref(data->vcp);
bt_gatt_server_unref(data->server);
util_iov_free(data->iov, data->iovcnt);
@@ -90,6 +89,7 @@ static void test_teardown(const void *user_data)
queue_destroy(data->ccc_states, free);
+ bt_vcp_unregister(data->vcp_id);
tester_teardown_complete();
}
@@ -163,6 +163,15 @@ done:
sizeof(value));
}
+static void vcp_client_attached(struct bt_vcp *vcp, void *user_data)
+{
+}
+
+static void vcp_client_detached(struct bt_vcp *vcp, void *user_data)
+{
+ bt_vcp_unref(vcp);
+}
+
static void test_server(const void *user_data)
{
struct test_data *data = (void *)user_data;
@@ -185,8 +194,10 @@ static void test_server(const void *user_data)
gatt_db_ccc_register(data->db, gatt_ccc_read_cb, NULL,
gatt_notify_cb, data);
- data->vcp = bt_vcp_new(data->db, NULL);
- g_assert(data->vcp);
+ bt_vcp_add_db(data->db);
+
+ data->vcp_id = bt_vcp_register(vcp_client_attached,
+ vcp_client_detached, NULL);
data->server = bt_gatt_server_new(data->db, att, 64, 0);
g_assert(data->server);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH BlueZ v2 3/4] test-micp: remove unnecessary bt_micp allocation
2025-06-20 13:51 [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments Kirill Samburskiy
2025-06-20 13:51 ` [PATCH BlueZ v2 1/4] shared/bap: ignore NULL attach/detach callbacks Kirill Samburskiy
2025-06-20 13:51 ` [PATCH BlueZ v2 2/4] test-vcp: remove unnecessary bt_vcp allocation Kirill Samburskiy
@ 2025-06-20 13:51 ` Kirill Samburskiy
2025-06-20 13:51 ` [PATCH BlueZ v2 4/4] shared/tester: shutdown tester IO before test teardown Kirill Samburskiy
2025-06-20 15:10 ` [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments patchwork-bot+bluetooth
4 siblings, 0 replies; 7+ messages in thread
From: Kirill Samburskiy @ 2025-06-20 13:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Kirill Samburskiy
Do not create bt_micp in test_server since it is not necessary for this
test. Also register bt_micp detached callback to unref and free
objects created by micp_get_session.
---
unit/test-micp.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/unit/test-micp.c b/unit/test-micp.c
index a7fc7fb32..87fde8ed0 100644
--- a/unit/test-micp.c
+++ b/unit/test-micp.c
@@ -33,12 +33,12 @@
struct test_data_mics {
struct gatt_db *db;
- struct bt_micp *micp;
struct bt_gatt_server *server;
struct bt_gatt_client *client;
struct queue *ccc_states;
size_t iovcnt;
struct iovec *iov;
+ unsigned int micp_id;
};
struct test_data_micp {
@@ -98,10 +98,10 @@ static void test_teardown_mics(const void *user_data)
{
struct test_data_mics *data = (void *)user_data;
- bt_micp_unref(data->micp);
bt_gatt_server_unref(data->server);
util_iov_free(data->iov, data->iovcnt);
gatt_db_unref(data->db);
+ bt_micp_unregister(data->micp_id);
queue_destroy(data->ccc_states, free);
@@ -269,6 +269,15 @@ done:
gatt_db_attribute_read_result(attrib, id, ecode, value, len);
}
+static void micp_attached(struct bt_micp *micp, void *user_data)
+{
+}
+
+static void micp_detached(struct bt_micp *micp, void *user_data)
+{
+ bt_micp_unref(micp);
+}
+
static void test_server(const void *user_data)
{
struct test_data_mics *data = (void *)user_data;
@@ -291,8 +300,9 @@ static void test_server(const void *user_data)
gatt_db_ccc_register(data->db, gatt_ccc_read_cb, NULL,
gatt_notify_cb, data);
- data->micp = bt_micp_new(data->db, NULL);
- g_assert(data->micp);
+ bt_micp_add_db(data->db);
+
+ data->micp_id = bt_micp_register(micp_attached, micp_detached, NULL);
data->server = bt_gatt_server_new(data->db, att, 64, 0);
g_assert(data->server);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH BlueZ v2 4/4] shared/tester: shutdown tester IO before test teardown
2025-06-20 13:51 [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments Kirill Samburskiy
` (2 preceding siblings ...)
2025-06-20 13:51 ` [PATCH BlueZ v2 3/4] test-micp: remove unnecessary bt_micp allocation Kirill Samburskiy
@ 2025-06-20 13:51 ` Kirill Samburskiy
2025-06-20 15:10 ` [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments patchwork-bot+bluetooth
4 siblings, 0 replies; 7+ messages in thread
From: Kirill Samburskiy @ 2025-06-20 13:51 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Kirill Samburskiy
Some tests may require shutdown of tester IO for proper teardown.
Add function tester_shutdown_io to accomplish that and call it
automatically when test finishes.
---
src/shared/tester.c | 8 ++++++++
src/shared/tester.h | 1 +
2 files changed, 9 insertions(+)
diff --git a/src/shared/tester.c b/src/shared/tester.c
index 371ccaced..62a14d073 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -654,6 +654,8 @@ static void test_result(enum test_result result)
test->timeout_id = 0;
}
+ tester_shutdown_io();
+
if (test->result == TEST_RESULT_FAILED)
result = TEST_RESULT_FAILED;
@@ -1047,6 +1049,12 @@ struct io *tester_setup_io(const struct iovec *iov, int iovcnt)
return ios[0];
}
+void tester_shutdown_io(void)
+{
+ io_shutdown(ios[0]);
+ io_shutdown(ios[1]);
+}
+
void tester_io_send(void)
{
struct test_case *test = tester_get_test();
diff --git a/src/shared/tester.h b/src/shared/tester.h
index 1f8138434..dfc1ca3a8 100644
--- a/src/shared/tester.h
+++ b/src/shared/tester.h
@@ -81,5 +81,6 @@ void tester_wait(unsigned int seconds, tester_wait_func_t func,
void *user_data);
struct io *tester_setup_io(const struct iovec *iov, int iovcnt);
+void tester_shutdown_io(void);
void tester_io_send(void);
void tester_io_set_complete_func(tester_data_func_t func);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments
2025-06-20 13:51 [PATCH BlueZ v2 0/4] test-vcp: Fix test failing in some environments Kirill Samburskiy
` (3 preceding siblings ...)
2025-06-20 13:51 ` [PATCH BlueZ v2 4/4] shared/tester: shutdown tester IO before test teardown Kirill Samburskiy
@ 2025-06-20 15:10 ` patchwork-bot+bluetooth
4 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+bluetooth @ 2025-06-20 15:10 UTC (permalink / raw)
To: Kirill Samburskiy; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Fri, 20 Jun 2025 16:51:42 +0300 you wrote:
> This patch fixes test-vcp failing on some environments. It is done by
> shutting down tester IO before test teardown and registering detach
> callbacks to ensure proper cleanup. Similar changes are introduced to
> test-micp to avoid similar problems in the future.
>
> ---
> Note: this is the second version of the patch, the original discussion
> can be found at:
> https://lore.kernel.org/all/20250619153120.126315-1-k.samburskiy@omp.ru
> See patch changelog below for changes in the new version.
>
> [...]
Here is the summary with links:
- [BlueZ,v2,1/4] shared/bap: ignore NULL attach/detach callbacks
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=71b5ea9bf373
- [BlueZ,v2,2/4] test-vcp: remove unnecessary bt_vcp allocation
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f5a4e95d73fe
- [BlueZ,v2,3/4] test-micp: remove unnecessary bt_micp allocation
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=659fc8fa7037
- [BlueZ,v2,4/4] shared/tester: shutdown tester IO before test teardown
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a209d69767db
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] 7+ messages in thread