Skip to content

Simplify audio sink iteration in docking station tests (New)#2442

Open
tomli380576 wants to merge 29 commits intomainfrom
auto-iter-audio-sinks
Open

Simplify audio sink iteration in docking station tests (New)#2442
tomli380576 wants to merge 29 commits intomainfrom
auto-iter-audio-sinks

Conversation

@tomli380576
Copy link
Copy Markdown
Contributor

@tomli380576 tomli380576 commented Apr 1, 2026

(the +6000 lines are the test data not actual code xD)

Description

The original test case dock/*-monitor-multi-head-audio-playback was a little cumbersome because the user has to wait until every single audio sink has been tested before re-testing any of the earlier ones. This PR modifies the flow to add automatic audio sink switching and shows a short menu to allow the user to quickly switch between audio sinks without leaving checkbox.

Also added some type annotations.

Resolved issues

QoL improvement only.

Documentation

For automatic sink switching, the basic idea here is to find all the node IDs associated with an "available" audio sink, use wpctl set-default <id> to change it, then run the speaker test. Pipewire doesn't seem to provide a convenient way to query all available sinks, so this script iterates through all the sink nodes, finds the parent device, then see if the sink node's card.profile.device matches an EnumRoute in the device. If there's a match and that EnumRoute is available, then we run the test.

1 caveat of this script is that if a pair of headphones is plugged into the built-in 3.5mm port of a DUT that has a built-in speaker, the speaker becomes hidden and can't be detected by this script. This behavior is:

  • consistent with wpctl status, which also doesn't list the speaker when headphones are connected
  • inconsistent with GNOME, which lists the built-in speaker AND the headphones

It's not a critical problem since we never test like this, but might be worth noting. Headphone ports on the dock will be correctly detected.

What the test data contains

They are essentially pw-dump results from a laptop, that has built-in speakers and HDMI, connected to an external display that also has built-in speakers.

Tests

C3 Submission:https://certification.canonical.com/hardware/202411-36032/submission/482965/

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 1, 2026

Codecov Report

❌ Patch coverage is 92.07921% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.89%. Comparing base (f631f0e) to head (a44c2ef).
⚠️ Report is 34 commits behind head on main.

Files with missing lines Patch % Lines
...support/checkbox_support/scripts/pipewire_utils.py 92.07% 5 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2442      +/-   ##
==========================================
+ Coverage   58.65%   58.89%   +0.23%     
==========================================
  Files         476      476              
  Lines       48027    48069      +42     
  Branches     8581     8583       +2     
==========================================
+ Hits        28172    28311     +139     
+ Misses      18961    18861     -100     
- Partials      894      897       +3     
Flag Coverage Δ
checkbox-support 68.18% <92.07%> (+0.44%) ⬆️
provider-base 34.00% <ø> (+0.48%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to automate docking-station multi-monitor audio playback verification by programmatically iterating through PipeWire audio sinks (using wpctl set-default <id>) and running a speaker test for each available sink.

Changes:

  • Update the dock multi-monitor audio playback job to call a new PipeWire utility subcommand that iterates sinks automatically.
  • Add an iter-audio-sinks subcommand to checkbox-support-pipewire-utils, including sink discovery and switching logic.
  • Refine some typing/return-shape behavior around pw-dump parsing and related helpers.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
providers/base/units/dock/jobs.pxu Switches the dock audio playback job to use the new automatic sink-iteration subcommand.
checkbox-support/checkbox_support/scripts/pipewire_utils.py Implements iter_audio_sinks() and wires it into the CLI; includes small refactors/typing adjustments.
Comments suppressed due to low confidence (1)

checkbox-support/checkbox_support/scripts/pipewire_utils.py:110

  • The _get_pw_dump() docstring still says it returns a dict and documents :"rtype": dict, but the function returns a JSON-decoded list (and now returns [] on decode failure). Please update the docstring to reflect the actual return type/shape to avoid misleading future callers.
    def _get_pw_dump(
        self, p_type: 't.Literal["Device", "Node"]'
    ) -> "list[dict[str, t.Any]]":
        """
        Use to convert the json output of pw-dump to dict object

        :param p_type: pipewire object type, such as "Node"
        :type p_type: str

        :returns: pw-dump in dict data structure
        :"rtype": dict
        """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread providers/base/units/dock/jobs.pxu Outdated
Comment thread checkbox-support/checkbox_support/scripts/pipewire_utils.py
Comment thread checkbox-support/checkbox_support/scripts/pipewire_utils.py Outdated
Comment thread checkbox-support/checkbox_support/scripts/pipewire_utils.py Outdated
Comment thread checkbox-support/checkbox_support/scripts/pipewire_utils.py
@tomli380576 tomli380576 changed the title Automatically iterate audio sinks in docking station tests Automatically iterate audio sinks in docking station tests (New) Apr 7, 2026
@tomli380576 tomli380576 changed the title Automatically iterate audio sinks in docking station tests (New) Simplify audio sink iteration in docking station tests (New) Apr 8, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

checkbox-support/checkbox_support/scripts/pipewire_utils.py:111

  • _get_pw_dump() now returns a list (and returns [] on failure), but the docstring still says it converts to/returns a dict (":rtype": dict). Please update the docstring (and wording like "dict object") to match the actual return type to avoid misleading callers and future maintenance issues.
    def _get_pw_dump(
        self, p_type: 't.Literal["Device", "Node"]'
    ) -> "list[dict[str, t.Any]]":
        """
        Use to convert the json output of pw-dump to dict object

        :param p_type: pipewire object type, such as "Node"
        :type p_type: str

        :returns: pw-dump in dict data structure
        :"rtype": dict
        """

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread checkbox-support/checkbox_support/scripts/pipewire_utils.py
Comment thread checkbox-support/checkbox_support/scripts/pipewire_utils.py Outdated
Comment thread checkbox-support/checkbox_support/scripts/pipewire_utils.py
@tomli380576 tomli380576 marked this pull request as ready for review April 10, 2026 06:33
@fernando79513 fernando79513 self-assigned this Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants