test: functional: add mpris-proxy end-to-end tests
Subsystems (2)
cover test: functional: add mpris-proxy end-to-end tests
Add tests for:
MPRIS -> local player -> AVRCP / MCP -> remote player -> MPRIS
Connection and basic operations are tested on smoketest level.
The code is LLM-assisted, with manual design and details input. I reviewed and tested the result.
Pauli Virtanen (3):
test: functional: add mpris-proxy BR/EDR test cases
test: functional: deduce pairing bearer in shared fixtures
test: functional: run mpris-proxy tests over LE via MCP
Makefile.am | 1 + doc/functional-mpris-proxy.rst | 180 +++++++++++ doc/functional-testing.rst | 7 +- test/functional/conftest.py | 23 +- test/functional/le_utils.py | 195 ++++++++++++ test/functional/test_avrcp.py | 4 +- test/functional/test_mpris_proxy.py | 467 ++++++++++++++++++++++++++++ test/functional/test_obex.py | 8 +- 8 files changed, 873 insertions(+), 12 deletions(-) create mode 100644 doc/functional-mpris-proxy.rst create mode 100644 test/functional/le_utils.py create mode 100644 test/functional/test_mpris_proxy.py
Signature · 1 line
2.55.0
PATCH 1/3 test: functional: add mpris-proxy BR/EDR test cases
Add functional tests for mpris-proxy over BR/EDR: a dummy MPRIS player on the server is bridged by mpris-proxy to an AVRCP Target, and a second mpris-proxy on the client, run with --export, exports the remote player back to the client session bus as an MPRIS player, which the tests control as MPRIS clients.
test/functional/test_mpris_proxy.py::test_mpris_proxy_playback_control test/functional/test_mpris_proxy.py::test_mpris_proxy_track_control
--- Makefile.am | 1 + doc/functional-mpris-proxy.rst | 145 ++++++++++ doc/functional-testing.rst | 1 + test/functional/test_mpris_proxy.py | 428 ++++++++++++++++++++++++++++ 4 files changed, 575 insertions(+) create mode 100644 doc/functional-mpris-proxy.rst create mode 100644 test/functional/test_mpris_proxy.py
Makefile.am +1 -0
@@ -501,6 +501,7 @@ EXTRA_DIST += doc/assigned-numbers.rst doc/supported-features.txt \ doc/functional-a2dp.rst \ doc/functional-avrcp.rst \ doc/functional-bap.rst \ + doc/functional-mpris-proxy.rst \ doc/functional-obex.rst \ doc/settings-storage.txt
doc/functional-mpris-proxy.rst new file +145 -0
145 lines not on this page · raw message
doc/functional-testing.rst +1 -0
@@ -15,6 +15,7 @@ are documented separately: - **functional-a2dp(7)**: `test/functional/test_a2dp.py` - **functional-avrcp(7)**: `test/functional/test_avrcp.py` - **functional-bap(7)**: `test/functional/test_bap.py` +- **functional-mpris-proxy(7)**: `test/functional/test_mpris_proxy.py` - **functional-obex(7)**: `test/functional/test_obex.py` Each test case is described as:
test/functional/test_mpris_proxy.py new file +428 -0
428 lines not on this page · raw message
Signature · 1 line
2.55.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/1164934/
---Test result---
Test Summary:
CheckPatch PASS 1.42 seconds GitLint PASS 0.98 seconds BuildEll PASS 19.69 seconds BluezMake PASS 377.40 seconds MakeCheck PASS 14.22 seconds MakeDistcheck PASS 141.53 seconds CheckValgrind PASS 236.33 seconds CheckSmatch PASS 314.14 seconds bluezmakeextell PASS 97.81 seconds TestFunctional FAIL 1081.13 seconds IncrementalBuild PASS 386.98 seconds ScanBuild PASS 1170.83 seconds
Details
##############################
Test: TestFunctional - FAIL
Desc: Run test-functional
Output:
FAIL functional.test_kernel_testers::test_kernel_selftest[hosts11-vm1-noc]: failed on setup with "ConnectionResetError: [Errno 104] Connection reset by peer" FAIL functional.test_adv_monitor::test_adv_monitor_GHSA_hhgc_hfgf_8m4x[hosts1-vm1]: failed on setup with "ConnectionResetError: [Errno 104] Connection reset by peer" FAIL functional.test_btmgmt::test_btmgmt_info[hosts10-vm1]: failed on setup with "pytest_bluezenv.rpc.RemoteTimeoutError: Failed to establish connection" FAIL functional.test_bluetoothctl::test_bluetoothctl_show[hosts7-vm1]: failed on setup with "ConnectionResetError: [Errno 104] Connection reset by peer" FAIL functional.test_bluetoothctl::test_bluetoothctl_list[hosts7-vm1]: failed on setup with "pytest_bluezenv.rpc.RemoteTimeoutError: Failed to establish connection" FAIL functional.test_bluetoothctl::test_bluetoothctl_script_show[hosts7-vm1]: failed on setup with "ConnectionResetError: [Errno 104] Connection reset by peer" FAIL functional.test_bluetoothctl::test_bluetoothctl_script_list[hosts7-vm1]: failed on setup with "pytest_bluezenv.rpc.RemoteTimeoutError: Failed to establish connection" FAIL functional.test_a2dp::test_a2dp_transport_created[hosts0-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_a2dp::test_a2dp_transport_acquire[hosts0-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_mpris_proxy::test_mpris_proxy_playback_control[bredr-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_mpris_proxy::test_mpris_proxy_track_control[bredr-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_obex::test_obex_ftp_list[hosts14-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_obex::test_obex_ftp_get[hosts14-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_obex::test_obexctl_list[hosts14-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_agent::test_agent_pair_bredr[accept-hosts2-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_agent::test_agent_pair_bredr[reject-hosts2-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_avrcp::test_avrcp_GHSA_m2vx_pw5f_rc8v[hosts3-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_bap::test_bap_unicast_transport_created[hosts4-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_bap::test_bap_unicast_transport_acquire[hosts4-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_bap::test_bap_broadcast_transport_created[lc3-hosts5-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_bap::test_bap_broadcast_transport_created[pbp-hosts5-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_bap::test_bap_broadcast_transport_acquire[lc3-hosts5-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_bap::test_bap_broadcast_transport_acquire[pbp-hosts5-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_bap::test_bass_past_transport_acquire[hosts6-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_bluetoothctl::test_bluetoothctl_pair_bredr[hosts8-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_bluetoothctl::test_bluetoothctl_pair_le[hosts9-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
FAIL functional.test_mpris_proxy::test_mpris_proxy_playback_control[le-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly" FAIL functional.test_mpris_proxy::test_mpris_proxy_track_control[le-vm2]: failed on setup with "RuntimeError: Process exited unexpectedly"
https://github.com/bluez/bluez/pull/2529
---
Regards,
Linux Bluetooth
PATCH 2/3 test: functional: deduce pairing bearer in shared fixtures
In reply to Pauli VirtanenMake paired_hosts deduce the pairing bearer from the host configuration instead of using BR/EDR only, with the LE pairing helper pair_le in le_utils. No behavior change.
--- doc/functional-testing.rst | 6 ++--- test/functional/conftest.py | 23 ++++++++++++++++--- test/functional/le_utils.py | 35 +++++++++++++++++++++++++++++ test/functional/test_avrcp.py | 4 ++-- test/functional/test_mpris_proxy.py | 4 ++-- test/functional/test_obex.py | 8 +++---- 6 files changed, 66 insertions(+), 14 deletions(-) create mode 100644 test/functional/le_utils.py
doc/functional-testing.rst +3 -3
@@ -83,9 +83,9 @@ test_agent_pair_bredr[accept] passkey. 4. ``org.bluez.Device1.Pair`` replies successfully. -:Notes: This test is also used as the ``paired_hosts_bredr`` fixture - (see `test/functional/conftest.py`), which other tests reuse to - get two already paired hosts. +:Notes: This test is also used by the ``paired_hosts`` fixture (see + `test/functional/conftest.py`), which other tests reuse to get two + already paired hosts. test_agent_pair_bredr[reject] -----------------------------
test/functional/conftest.py +20 -3
@@ -5,6 +5,8 @@ import re from pathlib import Path import pytest +from .le_utils import host_setup_is_le, pair_le + def pytest_addoption(parser): parser.addoption(
@@ -66,11 +68,26 @@ def pytest_collection_modifyitems(session, config, items): @pytest.fixture -def paired_hosts_bredr(hosts): +def is_le(host_setup): + """True if the current host configuration runs bluetoothd in LE-only mode.""" + return host_setup_is_le(host_setup) + + [email protected] +def paired_hosts(hosts, is_le): + """ + Two hosts, paired over the bearer their host configuration uses. + """ from .test_agent import test_agent_pair_bredr - if hosts[0].agent.has_device(hosts[1].bdaddr): + host0, host1 = hosts + + if host0.agent.has_device(host1.bdaddr): return hosts - test_agent_pair_bredr(hosts, True) + if is_le: + pair_le(host0, host1) + else: + test_agent_pair_bredr([host0, host1], True) + return hosts
test/functional/le_utils.py new file +35 -0
@@ -0,0 +1,35 @@ +# -*- coding: utf-8; mode: python; eval: (blacken-mode); -*- +# SPDX-License-Identifier: GPL-2.0-or-later +"""Generic LE helpers for functional tests.""" + +from pytest_bluezenv import ( + Bluetoothd, + wait_until, +) + + +def host_setup_is_le(host_setup): + """True if the hosts run bluetoothd in LE-only mode.""" + return any( + "ControllerMode = le" in (p.conf or "") + for plugins in host_setup["setup"] + for p in plugins + if isinstance(p, Bluetoothd) + ) + + +def pair_le(client, server): + """ + Pair Just Works over LE: client initiates and server authorizes, so + only a single RequestAuthorization is expected. + """ + server.agent.adapter_set("Pairable", True) + + client.agent.adapter_method("StartDiscovery") + client.agent.expect("org.bluez.Adapter1.StartDiscovery:reply") + wait_until(client.agent.has_device, server.bdaddr) + + client.agent.device_method(server.bdaddr, "Pair") + server.agent.expect("org.bluez.Agent1.RequestAuthorization") + server.agent.reply() + client.agent.expect("org.bluez.Device1.Pair:reply")
test/functional/test_avrcp.py +2 -2
@@ -43,8 +43,8 @@ class CheckAvrcpCrash_GHSA_m2vx_pw5f_rc8v(HostPlugin): Agent(), ], ) -def test_avrcp_GHSA_m2vx_pw5f_rc8v(paired_hosts_bredr): - client, server = paired_hosts_bredr +def test_avrcp_GHSA_m2vx_pw5f_rc8v(paired_hosts): + client, server = paired_hosts client.agent.device_method( server.bdaddr, "ConnectProfile", "0000110c-0000-1000-8000-00805f9b34fb"
test/functional/test_mpris_proxy.py +2 -2
@@ -325,7 +325,7 @@ def vm_set_trusted(bdaddr): @pytest.fixture -def mpris_player(paired_hosts_bredr): +def mpris_player(paired_hosts): """ Two paired and trusted hosts, the client connected to the dummy MPRIS player of the server, exported on the client session bus by
@@ -336,7 +336,7 @@ def mpris_player(paired_hosts_bredr): Yields (client, server, exported player bus name). """ - client, server = paired_hosts_bredr + client, server = paired_hosts client.call(vm_set_trusted, server.bdaddr) server.call(vm_set_trusted, client.bdaddr)
test/functional/test_obex.py +4 -4
@@ -194,11 +194,11 @@ obex_host_config = host_config( @pytest.fixture -def obex_hosts(paired_hosts_bredr): - host0, host1 = paired_hosts_bredr +def obex_hosts(paired_hosts): + host0, host1 = paired_hosts if hasattr(host0, "session"): - return paired_hosts_bredr + return paired_hosts host0.obex.connect(host1.bdaddr)
@@ -208,7 +208,7 @@ def obex_hosts(paired_hosts_bredr): host0.obex.expect("org.bluez.obex.Client1.CreateSession:reply") - yield paired_hosts_bredr + yield paired_hosts host1.obex_agent.cleanup()
Signature · 1 line
2.55.0
PATCH 3/3 test: functional: run mpris-proxy tests over LE via MCP
In reply to Pauli VirtanenAlso run the mpris-proxy tests over LE, where the player is exposed via MCS instead of AVRCP.
Add an LE advertisement helper for connecting the service.
test/functional/test_mpris_proxy.py::test_mpris_proxy_playback_control[le-vm2] test/functional/test_mpris_proxy.py::test_mpris_proxy_track_control[le-vm2]
--- doc/functional-mpris-proxy.rst | 91 +++++++++++----- test/functional/le_utils.py | 162 +++++++++++++++++++++++++++- test/functional/test_mpris_proxy.py | 93 +++++++++++----- 3 files changed, 290 insertions(+), 56 deletions(-)
doc/functional-mpris-proxy.rst +63 -28
@@ -16,17 +16,20 @@ exports a remote ``org.bluez.MediaPlayer1`` object to the session bus as an MPRIS player. The upper tester drives two VM hosts, host0 as the client and host1 as -the server, connected over BR/EDR, where the bridge is an AVRCP Target -and Controller. The server presents a dummy MPRIS player. The client -runs a second `mpris-proxy` with ``--export``, which exports that -remote player on the client session bus, and the upper tester controls -it there as an ordinary MPRIS client. +the server. The server presents a dummy MPRIS player. The client runs +a second `mpris-proxy` with ``--export``, which exports that remote +player on the client session bus, and the upper tester controls it +there as an ordinary MPRIS client. Each case runs once over BR/EDR, +where the bridge is an AVRCP Target and Controller, and once over LE, +where it is a Generic Media Control Service (GMCS) server and client. SETUP ===== .. code-block:: + BR/EDR: + +--------------------------------+ +--------------------------------+ | host0 / client | BR/EDR | host1 / server | | bluetoothd | AVCTP | bluetoothd |
@@ -36,6 +39,18 @@ SETUP | <name> (session bus) | | blueztest (session bus) | +--------------------------------+ +--------------------------------+ + LE: + + +--------------------------------+ +--------------------------------+ + | host0 / client | LE | host1 / server | + | bluetoothd | GMCS | bluetoothd | + | mpris-proxy --export | (MCP) | mpris-proxy | + | MPRIS client (upper tester) | -------> | dummy MPRIS player | + | org.mpris.MediaPlayer2. | | LE advertisement (GMCS) | + | <name> (session bus) | | org.mpris.MediaPlayer2. | + | | | blueztest (session bus) | + +--------------------------------+ +--------------------------------+ + The server host owns the session bus name ``org.mpris.MediaPlayer2.blueztest`` and exports ``/org/mpris/MediaPlayer2`` with the ``org.mpris.MediaPlayer2`` and
@@ -47,33 +62,45 @@ tester tells it to, and then emits The `mpris-proxy` on the server registers that player with its **bluetoothd** through ``org.bluez.Media1.RegisterPlayer``, so the -server host is the AVRCP Target. The `mpris-proxy --export` on the -client exports the ``org.bluez.MediaPlayer1`` object its bluetoothd -creates for the remote player as ``org.mpris.MediaPlayer2.<name>``, -where ``<name>`` is derived from the remote device alias, at -``/org/mpris/MediaPlayer2`` on the client session bus. Both proxies use -adapter index 0. +server host is the AVRCP Target over BR/EDR and the GMCS server over +LE. The `mpris-proxy --export` on the client exports the +``org.bluez.MediaPlayer1`` object its bluetoothd creates for the +remote player as ``org.mpris.MediaPlayer2.<name>``, where ``<name>`` +is derived from the remote device alias, at +``/org/mpris/MediaPlayer2`` on the client session bus. Both proxies +use adapter index 0. + +In the LE configuration both hosts run bluetoothd with +``ControllerMode = le`` and ``Experimental = true``, and both hosts +register an ``org.bluez.Agent1`` with ``NoInputNoOutput`` capability. +The server also registers a connectable ``org.bluez.LEAdvertisement1`` +advertising GMCS (``00001849-0000-1000-8000-00805f9b34fb``) through +``org.bluez.LEAdvertisingManager1.RegisterAdvertisement``, to connect +the service. Before each case the upper tester does the following, and checks each step: - 1. Pair the hosts over BR/EDR, unless they are already paired, as - the host setup is reused between cases: the client discovers - the server and calls ``org.bluez.Device1.Pair``, and both - agents confirm the passkey. + 1. Pair the hosts over the bearer in use, unless they are already + paired, as the host setup is reused between cases. Over BR/EDR + the client discovers the server and calls ``Device1.Pair``, and + both agents confirm the passkey. Over LE pairing is Just + Works: the server agent authorizes it. 2. On both hosts, set ``Trusted`` to true with ``org.freedesktop.DBus.Properties.Set`` on the ``org.bluez.Device1`` object of the peer host. - 3. Connect on the client with ``org.bluez.Device1.ConnectProfile`` - and the AVRCP Controller UUID - (``0000110c-0000-1000-8000-00805f9b34fb``). The call must - reply, or fail with ``AlreadyConnected`` since a previous case - may still be connected. + 3. Connect on the client: ``org.bluez.Device1.ConnectProfile`` + with the AVRCP Controller UUID + (``0000110c-0000-1000-8000-00805f9b34fb``) over BR/EDR, or + ``org.bluez.Device1.Connect`` over LE. The call must reply, or + fail with ``AlreadyConnected`` since a previous case may still + be connected. 4. Wait until the client session bus has exactly one name with the prefix ``org.mpris.MediaPlayer2.``, listed with ``org.freedesktop.DBus.ListNames``. That is the exported player. 5. Wait until its ``PlaybackStatus``, read with - ``org.freedesktop.DBus.Properties.Get``, is ``Stopped``. + ``org.freedesktop.DBus.Properties.Get``, is the idle status: + ``Stopped`` over BR/EDR, ``Paused`` over LE. The same connection and exported player are used by both cases.
@@ -84,9 +111,9 @@ After each case, also on failure, the upper tester resets the dummy player on the server to stopped and track 0, which emits ``PropertiesChanged`` for ``PlaybackStatus`` and ``Metadata``, and drops the method calls left over from the previous case. It then waits -until the exported player on the client reads ``Stopped`` again. The -hosts, both bluetoothd instances, both proxies and the connection are -left running. +until the exported player on the client again reads the idle status. +The hosts, both bluetoothd instances, both proxies and the connection +are left running. TEST CASES ==========
@@ -114,7 +141,12 @@ test_mpris_proxy_playback_control 2. The dummy player on the server receives ``Play``, ``Pause`` and ``Stop``. 3. The exported player on the client reports ``Playing``, - ``Paused`` and ``Stopped``. + ``Paused`` and ``Stopped`` over BR/EDR. Over LE, ``Stop`` is + reported as ``Paused``. + +:Notes: GMCS has no stopped state, so a stopped player is published by + the server in the paused state, and reads as ``Paused`` on the + client. test_mpris_proxy_track_control ------------------------------
@@ -138,8 +170,11 @@ test_mpris_proxy_track_control 1. The dummy player on the server receives ``Next`` and ``Previous``. 2. The metadata of the new track reaches the exported player on - the client: both its ``xesam:title`` and its - ``xesam:trackNumber`` match the new track. + the client: the title matches over both bearers, and + ``xesam:trackNumber`` matches over BR/EDR. :Notes: The dummy player changes its state only once the upper tester - has observed the corresponding call. + has observed the corresponding call. Over LE bluetoothd knows + only the GMCS object name of the remote player, so the client + sees the title but no track number, which is why the track number + is checked over BR/EDR only.
test/functional/le_utils.py +161 -1
173 lines not on this page · raw message
test/functional/test_mpris_proxy.py +66 -27
164 lines not on this page · raw message
Signature · 1 line
2.55.0
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Hello:
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:
Quoted 10 lines · On Tue, 15 Sep 2026 03:07:17 +0300 you wrote:
Add tests for:
MPRIS -> local player -> AVRCP / MCP -> remote player -> MPRIS
Connection and basic operations are tested on smoketest level.
The code is LLM-assisted, with manual design and details input. I reviewed and tested the result.
[...]
Here is the summary with links:
- [BlueZ,1/3] test: functional: add mpris-proxy BR/EDR test cases
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=3e7fb4ac2e28 - [BlueZ,2/3] test: functional: deduce pairing bearer in shared fixtures https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=acab65d06795 - [BlueZ,3/3] test: functional: run mpris-proxy tests over LE via MCP https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e2ec6827f7be
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html