From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1] test: functional: connect instead of pairing a bonded BAP device
Date: Tue, 13 Oct 2026 11:03:36 -0400 [thread overview]
Message-ID: <20261013150336.579039-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The hosts are shared between tests, so a device bonded by an earlier one
is still bonded when a later one pairs it, and pairing it again fails
with AlreadyExists. cmd_pair is meant to connect it instead, but it
checks Paired, which is not set until the services are resolved, so it
can still issue the pairing:
FAILED test/functional/test_bap.py::test_bass_past_transport_acquire
AssertionError: Failed to pair: org.bluez.Error.AlreadyExists
Check Bonded, which is what the pairing is rejected for, and connect the
device instead when it is set.
Assisted-by: OpenCode:claude-opus-5.5
---
test/functional/test_bap.py | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/test/functional/test_bap.py b/test/functional/test_bap.py
index c4bd5fc6aa61..7cd9466bd5f7 100644
--- a/test/functional/test_bap.py
+++ b/test/functional/test_bap.py
@@ -112,12 +112,20 @@ def pair_le(host0, ctl0, host1, ctl1, advertise=True, services=False):
ctl1.send("advertise on\n")
ctl1.expect("Advertising object registered")
- ctl0.expect(f"Device {host1.bdaddr.upper()}")
- ctl0.send(f"pair {host1.bdaddr.upper()}\n")
+ addr = host1.bdaddr.upper()
+
+ ctl0.expect(f"Device {addr}")
+
+ # A device bonded by an earlier test on the same hosts is rejected
+ # with AlreadyExists if paired again, so connect it instead
+ if is_bonded(ctl0, addr):
+ ctl0.send(f"connect {addr}\n")
+ else:
+ ctl0.send(f"pair {addr}\n")
pending = [PAIRED]
if services:
- pending.append(f"Device {host1.bdaddr.upper()} ServicesResolved: yes")
+ pending.append(f"Device {addr} ServicesResolved: yes")
pair_wait(ctl0, ctl1, pending)
@@ -155,6 +163,25 @@ def list_transports(ctl0, hosts):
transports[idx - 1] = m[0].decode("utf-8")
+def is_bonded(ctl0, addr):
+ """
+ Tell whether the given device is bonded already.
+
+ This is what pairing it is rejected for, which Paired does not
+ reflect until the services are resolved, so cmd_pair, which checks
+ Paired, can still end up pairing a bonded device.
+ """
+ ctl0.send(f"info {addr}\n")
+
+ # Tab indented: the [CHG] lines and the LE. and BREDR. ones are not
+ idx, m = ctl0.expect(
+ [r"\tBonded: (yes|no)", rf"Device {addr} not available"],
+ timeout=REPLY_TIMEOUT,
+ )
+
+ return idx == 0 and m[0] == b"yes"
+
+
def remove_device(ctl0, host):
"""
Remove the given host, so the test starts from a state where it is
--
2.56.0
next reply other threads:[~2026-10-13 15:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 15:03 Luiz Augusto von Dentz [this message]
2026-10-13 19:29 ` [BlueZ,v1] test: functional: connect instead of pairing a bonded BAP device bluez.test.bot
2026-10-14 17:20 ` [PATCH BlueZ v1] " 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=20261013150336.579039-1-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