test: functional: connect instead of pairing a bonded BAP device
Luiz Augusto von Dentz
maintainerPATCH 1/1 test: functional: connect instead of pairing a bonded BAP device
From: Luiz Augusto von Dentz <[email protected]>
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.
--- test/functional/test_bap.py | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-)
test/functional/test_bap.py +30 -3
@@ -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
Signature · 1 line
2.56.0
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/series/1184865/
---Test result---
Test Summary:
CheckPatch PASS 0.30 seconds GitLint PASS 0.24 seconds BuildEll PASS 17.55 seconds BluezMake PASS 272.61 seconds MakeCheck PASS 13.65 seconds MakeDistcheck PASS 131.54 seconds CheckValgrind PASS 225.56 seconds CheckSmatch PASS 246.14 seconds bluezmakeextell PASS 88.43 seconds TestFunctional PASS 1035.10 seconds IncrementalBuild PASS 265.87 seconds ScanBuild PASS 988.13 seconds
https://github.com/bluez/bluez/pull/2673
---
Regards,
Linux Bluetooth
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This patch was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 9 lines · On Tue, 13 Oct 2026 11:03:36 -0400 you wrote:
From: Luiz Augusto von Dentz <[email protected]>
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_pairis 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:[...]
Here is the summary with links:
- [BlueZ,v1] test: functional: connect instead of pairing a bonded BAP device
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0a48b5ef5e3d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html