Skip to content

feat: Add option to capture payloads#420

Open
lucasssvaz wants to merge 4 commits into
espressif:mainfrom
lucasssvaz:feat/echo_mute
Open

feat: Add option to capture payloads#420
lucasssvaz wants to merge 4 commits into
espressif:mainfrom
lucasssvaz:feat/echo_mute

Conversation

@lucasssvaz
Copy link
Copy Markdown
Member

Description

This pull request introduces a robust mechanism for selectively muting stdout echo from the serial listener process in pytest-embedded, allowing for more controlled and less noisy test output—especially when capturing sensitive or bulk payloads. The changes add both manual (event-based) and automatic (pattern-based) muting, as well as new helper methods for capturing serial payloads, with extensive support for customization via fixtures.

Key changes include:

Stdout Echo Muting and Payload Capture Enhancements:

  • Added a per-DUT _mute_event and mute_patterns to enable both manual and automatic suppression of stdout echo in the serial listener process, while still logging all output to file. This is exposed via new fixtures and passed through the test infrastructure. [1] [2] [3] [4]
  • Implemented mute_echo, unmute_echo, and a muted_echo context manager in Dut to allow test code to programmatically mute or unmute stdout echo.

Automatic Muting with Patterns:

  • Introduced the mute_patterns fixture, allowing projects to specify start/end string pairs that automatically trigger muting/unmuting of stdout echo based on serial output content. [1] [2] [3]

Serial Payload Capture Utilities:

  • Added capture_payload and capture_payload_to_file methods to Dut for extracting delimited payloads from serial output, with optional muting and file persistence.

Refactoring and Integration:

  • Refactored listener process creation and fixture setup to propagate _mute_event and mute_patterns throughout the test infrastructure, ensuring all components are aware of and can leverage the new muting capabilities. [1] [2] [3] [4]

Other:

  • Removed direct printing of serial data in the Wokwi plugin, delegating all echo and muting logic to the listener process for consistency. [1] [2]

These changes provide fine-grained control over test output, making it easier to capture and process serial data without cluttering stdout, and enable project-specific customization of muting behavior.

References:
[1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

Testing

Tested locally

@lucasssvaz lucasssvaz marked this pull request as draft May 20, 2026 18:32
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 20, 2026

Title Coverage Tests Skipped Failures Errors Time
Qemu Coverage 7 0 💤 0 ❌ 0 🔥 48.293s ⏱️
3.10 ARM64 Coverage 138 18 💤 0 ❌ 0 🔥 11m 44s ⏱️

Copy link
Copy Markdown
Member

@hfudev hfudev left a comment

Choose a reason for hiding this comment

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

the other parts LGTM. left some comments regarding the listener.

Comment thread pytest-embedded/pytest_embedded/dut_factory.py Outdated
Comment thread pytest-embedded/pytest_embedded/dut_factory.py Outdated
Comment thread pytest-embedded/pytest_embedded/dut_factory.py Outdated
@lucasssvaz
Copy link
Copy Markdown
Member Author

@hfudev Fixed the issues and added tests for these cases as well.

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.

2 participants