Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 10/11] test: functional: fail as soon as an operation fails
Date: Tue, 15 Sep 2026 17:15:27 -0400	[thread overview]
Message-ID: <20260915211528.1223784-11-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20260915211528.1223784-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

A test waiting for what an operation reports on success only learns
that it failed when the wait times out, 20 seconds later, and what it
reports then is the pattern it was waiting for, not the error.

Watch for the failures alongside it, so a test fails right away and
tells what went wrong, e.g. "Failed to pair:
org.bluez.Error.AlreadyExists".

Assisted-by: opencode:claude-opus-5
---
 test/functional/test_bap.py | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/test/functional/test_bap.py b/test/functional/test_bap.py
index bc9bcfb83ad8..6ffbf0371e0e 100644
--- a/test/functional/test_bap.py
+++ b/test/functional/test_bap.py
@@ -32,16 +32,32 @@ def dev_addr(host):
     return host.bdaddr.upper().replace(":", "_")
 
 
-def expect_all(ctl, patterns):
+# Reported when an operation cannot complete, so a test does not have to
+# wait for its timeout to know it is not going to
+FAILURES = [
+    r"(Failed to \w+[^\r\n]*)",
+    r"(Device \S+ not available)",
+]
+
+
+def expect_all(ctl, patterns, failures=FAILURES):
     """
     Expect all the given patterns, in any order, returning the groups
     each of them matched.
+
+    Fail as soon as one of the failures shows up, e.g. a request that
+    was rejected, instead of waiting for the timeout.
     """
     pending = list(enumerate(patterns))
     groups = [None] * len(patterns)
 
     while pending:
-        idx, m = ctl.expect([pattern for _, pattern in pending])
+        idx, m = ctl.expect(list(failures) + [pattern for _, pattern in pending])
+
+        if idx < len(failures):
+            raise AssertionError(m[0].decode("utf-8") if m else "failed")
+
+        idx -= len(failures)
         groups[pending[idx][0]] = m
         pending.pop(idx)
 
@@ -88,7 +104,12 @@ def pair_le(host0, ctl0, host1, ctl1, advertise=True, services=False):
     legacy = r"\[agent\].*Passkey:.*m(\d+)"
 
     while pending:
-        idx, m = ctl0.expect([legacy] + pending)
+        idx, m = ctl0.expect(FAILURES + [legacy] + pending)
+
+        if idx < len(FAILURES):
+            raise AssertionError(m[0].decode("utf-8") if m else "failed")
+
+        idx -= len(FAILURES)
 
         if idx == 0:
             warnings.warn(
-- 
2.55.0


  parent reply	other threads:[~2026-09-15 21:15 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-15 21:15 [PATCH BlueZ v1 00/11] Cover a BAP stream to a coordinated set Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 01/11] shared/bass: add a ready callback Luiz Augusto von Dentz
2026-09-15 21:58   ` Cover a BAP stream to a coordinated set bluez.test.bot
2026-09-16  0:55   ` bluez.test.bot
2026-09-15 21:15 ` [PATCH BlueZ v1 02/11] bass: wait for the session to be ready before pushing a source Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 03/11] test: functional: report what a test is waiting for Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 04/11] test: functional: answer the notification registered by the victim Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 05/11] doc: describe the BAP coordinated set test cases Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 06/11] emulator: use the handle of the receiving side Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 07/11] emulator: allow the maximum number of CIS of a CIG Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 08/11] device: keep the long term key of both roles Luiz Augusto von Dentz
2026-09-15 21:15 ` [PATCH BlueZ v1 09/11] client: allow a capability with the auto agent Luiz Augusto von Dentz
2026-09-15 21:15 ` Luiz Augusto von Dentz [this message]
2026-09-15 21:15 ` [PATCH BlueZ v1 11/11] test: functional: add the BAP coordinated set tests Luiz Augusto von Dentz
2026-09-16 18:30 ` [PATCH BlueZ v1 00/11] Cover a BAP stream to a coordinated set 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=20260915211528.1223784-11-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