From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v1 10/10] test: Cover A2DP reconnection with a pending disconnection
Date: Fri, 30 Oct 2026 17:29:39 -0400 [thread overview]
Message-ID: <20261030212940.753771-11-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261030212940.753771-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Stop bluetoothd on the sink while the source disconnects and connects
again, so that the disconnection of the previous link and the AVDTP
connection of the new one are pending together when it resumes, which
made the new connection be refused.
Assisted-by: Claude:claude-opus-5-5
---
doc/functional-a2dp.rst | 32 ++++++++++++++++++++++++++++++++
test/functional/test_a2dp.py | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/doc/functional-a2dp.rst b/doc/functional-a2dp.rst
index f38a458bb7c2..367992159b7b 100644
--- a/doc/functional-a2dp.rst
+++ b/doc/functional-a2dp.rst
@@ -134,3 +134,35 @@ test_a2dp_disconnect_during_setconf[accept|reject]
``auto_config()``. A late ``yes`` used to also leave the stale
transport registered, failing the next connection with
``Resource temporarily unavailable``.
+
+test_a2dp_reconnect_pending_disconnect
+--------------------------------------
+
+:Setup: As above, with the stream configured and the transport created.
+
+:Steps:
+ 1. Peripheral: stop `bluetoothd` with ``SIGSTOP``.
+ 2. Central: ``disconnect <peripheral bdaddr>``.
+ 3. Central: ``connect <peripheral bdaddr>``.
+ 4. Peripheral: once the new link is up, resume `bluetoothd` with
+ ``SIGCONT``.
+
+:Expected:
+ 1. `bluetoothd` on the peripheral stops processing events.
+ 2. ``Disconnection successful`` on the central.
+ 3. The new ACL link is established by the kernels, and the AVDTP
+ connection of the central waits for `bluetoothd` on the
+ peripheral to accept it.
+ 4. ``Connection successful`` on the central, and a transport
+ appears on both hosts.
+
+:Notes: Regression test for `bluetoothd` on the peripheral handling the
+ incoming AVDTP connection of the new link before the disconnection
+ of the previous one. It used to take the connection for a transport
+ channel of the A2DP channel of the previous link, still registered,
+ and refuse it, or, once that channel was gone, the disconnection
+ cancelled the service authorization of the new channel
+ (``Access denied: org.bluez.Error.Canceled``). In both cases the
+ central failed with ``Connection refused``. Without the pause the
+ two events are rarely pending at the same time, mostly under the
+ slower timing of User Mode Linux.
diff --git a/test/functional/test_a2dp.py b/test/functional/test_a2dp.py
index 12348ea05ae2..c07a2b2a1232 100644
--- a/test/functional/test_a2dp.py
+++ b/test/functional/test_a2dp.py
@@ -4,6 +4,9 @@
Tests for A2DP using bluetoothctl in VM instances
"""
+import signal
+import subprocess
+
import pytest
from pytest_bluezenv import Bluetoothd, Pexpect, find_exe, host_config
@@ -200,3 +203,36 @@ def test_a2dp_disconnect_during_setconf(hosts, reply):
sink.send("yes\n")
source.expect("Connection successful")
source.expect(TRANSPORT_RE)
+
+
+def vm_signal_bluetoothd(sig):
+ subprocess.run(["pkill", f"-{sig}", "-x", "bluetoothd"], check=True)
+
+
+@a2dp_host_config
+def test_a2dp_reconnect_pending_disconnect(a2dp_hosts):
+ host0, host1, source, sink = a2dp_hosts
+
+ source.expect(TRANSPORT_RE)
+ sink.expect(TRANSPORT_RE)
+
+ # Stop the sink's bluetoothd so that the disconnection of the link and
+ # the AVDTP connection on the new one are pending together when it
+ # resumes, as when it is slow to process the disconnection
+ host1.call(vm_signal_bluetoothd, signal.SIGSTOP)
+ try:
+ source.send(f"disconnect {host1.bdaddr}\n")
+ source.expect("Disconnection successful")
+
+ source.send(f"connect {host1.bdaddr}\n")
+ source.expect(f"Device {host1.bdaddr.upper()} Connected: yes")
+ finally:
+ host1.call(vm_signal_bluetoothd, signal.SIGCONT)
+
+ # The transport may be reported before or after the reply
+ pending = ["Connection successful", TRANSPORT_RE]
+ while pending:
+ idx, _ = source.expect(pending)
+ pending.pop(idx)
+
+ sink.expect(TRANSPORT_RE)
--
2.56.0
prev parent reply other threads:[~2026-10-30 21:29 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 21:29 [PATCH BlueZ v1 00/10] Run test-functional under User Mode Linux Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 01/10] tools/test-runner: Default to time travel with " Luiz Augusto von Dentz
2026-10-30 23:58 ` Run test-functional under " bluez.test.bot
2026-10-30 21:29 ` [PATCH BlueZ v1 02/10] tools/test-runner: Unbind virtio devices before powering off UML Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 03/10] emulator: Answer the time of a guest with a skew Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 04/10] adapter: Don't return Busy when a pending change sets the same value Luiz Augusto von Dentz
2026-10-30 21:34 ` Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 05/10] test: functional: wait for BAP transports to be configured Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 06/10] shared/mcp: Don't drop commands before supported opcodes are read Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 07/10] doc/test-functional: Document User Mode Linux VM hosts Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 08/10] a2dp: Fix refusing the AVDTP connection of a new link Luiz Augusto von Dentz
2026-10-30 21:29 ` [PATCH BlueZ v1 09/10] adapter: Don't cancel requests of a new link on stale disconnection Luiz Augusto von Dentz
2026-10-30 21:29 ` Luiz Augusto von Dentz [this message]
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=20261030212940.753771-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