From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 02/27] shared/tester: Time out teardown
Date: Thu, 22 Oct 2026 11:46:35 -0400 [thread overview]
Message-ID: <20261022154701.3959500-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261022154701.3959500-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
A teardown with no timeout blocks every following test if what it waits
for never happens, e.g. mgmt-tester waiting for the removal of an index
the kernel never added since the controller failed to initialize:
Set Low Energy on 6.2 - SCI Setting - test timed out
Set Low Energy on 6.2 - SCI Setting - teardown
Give teardown the timeout of the test, but at least 30 seconds, as it
may have to wait for the kernel to time out commands still sent to a
controller being removed, 2 seconds each. When it expires report the
test as timed out and do not run the remaining tests: the callbacks of
the test may still complete later, and would be taken for those of the
test running then.
Assisted-by: Claude:claude-opus-5-5
---
src/shared/tester.c | 66 ++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 62 insertions(+), 4 deletions(-)
diff --git a/src/shared/tester.c b/src/shared/tester.c
index eb2e923fd790..4065545793aa 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -423,6 +423,55 @@ static int tester_summarize(void)
return failed;
}
+static gboolean done_callback(gpointer user_data);
+
+static bool teardown_timeout(gpointer user_data)
+{
+ struct test_case *test = user_data;
+
+ test->timeout_id = 0;
+
+ if (!test_current || test_current->data != test)
+ return FALSE;
+
+ /* Give up waiting, e.g. for an index that was never added to be
+ * removed, rather than blocking for good. Its callbacks may still
+ * complete later, and would be taken for those of the test running
+ * then, so do not run the remaining tests.
+ */
+ test->result = TEST_RESULT_TIMED_OUT;
+ test->stage = TEST_STAGE_INVALID;
+
+ print_progress(test->name, COLOR_RED, "teardown timed out");
+ tester_warn("Not running the remaining tests");
+
+ while (test_current->next)
+ test_current = test_current->next;
+
+ g_idle_add(done_callback, test);
+
+ return FALSE;
+}
+
+/* Teardown may have to wait for the kernel to time out commands still sent
+ * to a controller being removed, 2 seconds each, so only give up on a
+ * teardown that clearly does not complete.
+ */
+#define TEARDOWN_TIMEOUT 30
+
+static void teardown_timeout_start(struct test_case *test)
+{
+ if (test->timeout_id > 0) {
+ timeout_remove(test->timeout_id);
+ test->timeout_id = 0;
+ }
+
+ if (test->timeout > 0)
+ test->timeout_id = timeout_add_seconds(
+ MAX(test->timeout, TEARDOWN_TIMEOUT),
+ teardown_timeout, test, NULL);
+}
+
static gboolean teardown_callback(gpointer user_data)
{
struct test_case *test = user_data;
@@ -430,6 +479,8 @@ static gboolean teardown_callback(gpointer user_data)
test->teardown_id = 0;
test->stage = TEST_STAGE_TEARDOWN;
+ teardown_timeout_start(test);
+
print_progress(test->name, COLOR_MAGENTA, "teardown");
test->teardown_func(test->test_data);
@@ -629,10 +680,7 @@ void tester_setup_failed(void)
test->result = TEST_RESULT_FAILED;
test->stage = TEST_STAGE_POST_TEARDOWN;
- if (test->timeout_id > 0) {
- timeout_remove(test->timeout_id);
- test->timeout_id = 0;
- }
+ teardown_timeout_start(test);
print_progress(test->name, COLOR_RED, "setup failed");
print_progress(test->name, COLOR_MAGENTA, "teardown");
@@ -745,6 +793,11 @@ void tester_post_teardown_complete(void)
if (test->stage != TEST_STAGE_POST_TEARDOWN)
return;
+ if (test->timeout_id > 0) {
+ timeout_remove(test->timeout_id);
+ test->timeout_id = 0;
+ }
+
print_progress(test->name, COLOR_MAGENTA, "teardown complete");
g_idle_add(done_callback, test);
@@ -762,6 +815,11 @@ void tester_post_teardown_failed(void)
if (test->stage != TEST_STAGE_POST_TEARDOWN)
return;
+ if (test->timeout_id > 0) {
+ timeout_remove(test->timeout_id);
+ test->timeout_id = 0;
+ }
+
print_progress(test->name, COLOR_RED, "teardown failed");
g_idle_add(done_callback, test);
--
2.56.0
next prev parent reply other threads:[~2026-10-22 15:47 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 15:46 [PATCH BlueZ v1 00/27] Run the testers under User Mode Linux with time travel Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 01/27] tools/test-runner: Do not report filesystems already mounted Luiz Augusto von Dentz
2026-10-22 20:02 ` Run the testers under User Mode Linux with time travel bluez.test.bot
2026-10-22 15:46 ` Luiz Augusto von Dentz [this message]
2026-10-22 15:46 ` [PATCH BlueZ v1 03/27] mgmt-tester: Wait for LL Privacy setup to complete Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 04/27] iso-tester: Fix leaking socket watches Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 05/27] l2cap-tester: Fix race in LE Client - Close socket 2 Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 06/27] iso-tester: Fix busy waiting in PAST tests Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 07/27] doc: Enable IPv6 in tester.config Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 08/27] 6lowpan-tester: Find the interface of the controller Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 09/27] emulator: Remove -T option from btvirt Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 10/27] doc: Add btvirt documentation Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 11/27] emulator: Add vhost-user backend Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 12/27] emulator: Add vhost-user virtio server to btvirt Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 13/27] emulator: Add time travel calendar " Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 14/27] emulator: Add virtio console and time travel client " Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 15/27] tools/test-runner: Add User Mode Linux support Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 16/27] doc: Add virtio documentation Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 17/27] shared/mainloop: Add idle callbacks Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 18/27] shared/timeout: Run timeouts of 0 once idle Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 19/27] shared/tester: Remove GLib dependency Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 20/27] emulator/hciemu: " Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 21/27] tools: Build testers that do not need GLib with the mainloop Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 22/27] shared/mainloop: Add deferred callbacks Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 23/27] tools: Add socket watches for testers without GLib Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 24/27] tools: Run sco-tester, rfcomm-tester and 6lowpan-tester on the mainloop Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 25/27] tools: Run l2cap-tester and iso-tester " Luiz Augusto von Dentz
2026-10-22 15:46 ` [PATCH BlueZ v1 26/27] doc/virtio: Update measurements of the testers Luiz Augusto von Dentz
2026-10-22 15:47 ` [PATCH BlueZ v1 27/27] doc: Split tester.config for QEMU and User Mode Linux Luiz Augusto von Dentz
2026-10-29 18:40 ` [PATCH BlueZ v1 00/27] Run the testers under User Mode Linux with time travel patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261022154701.3959500-3-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox