feat: Add group class for better control of multi dut tests#415
feat: Add group class for better control of multi dut tests#415lucasssvaz wants to merge 6 commits into
Conversation
|
@lucasssvaz Thank you for this big improvement. I kinda like this idea. Please ping me again once the CI passed! |
|
@hfudev Fixed. Looks like the rest of the errors are related to not finding USB ports on the runner. I had the idea of creating this class while working on tests that require precise synchronization of the devices. Let me know if there is anything you would like me to change or add. |
|
Hi @lucasssvaz Thanks for the PR again. def dut_gn(
_fixture_classes_and_options: ClassCliOptions,
openocd: t.Optional['OpenOcd'],
gdb: t.Optional['Gdb'],
app: App,
serial: t.Union['Serial', 'LinuxSerial'] | None,
qemu: t.Optional['Qemu'],
wokwi: t.Optional['Wokwi'],
) -> Dut | list[Dut]:I'm thinking probably the then it would be more IDE-friendly, but that requries a lot more refactor. WDYT? Do you want to do it? Or I can do it in a future PR? |
|
@hfudev Updated it with the requested changes. Tested it locally and everything works well. PTAL. I don't know what are the future plans of the library so I tried doing it in the least intrusive way possible. |
Description
This pull request introduces multi-DUT (Device Under Test) synchronization support to the
pytest-embeddedframework, allowing users to control and coordinate multiple DUTs in parallel within tests. The main addition is the newDutGroupclass, which provides a transparent, parallel proxy for running commands and assertions across multiple DUTs. The documentation and tests have been updated to reflect and validate this new functionality.Key changes:
Multi-DUT Synchronization Feature
DutGroupclass inpytest_embedded/group.py, providing a container-like proxy to run anyDutmethod in parallel across multiple DUTs. Special handling is included forexpectandexpect_exactto support both broadcast and per-DUT patterns, as well as container protocol support (indexing, iteration, etc.). (pytest-embedded/pytest_embedded/group.py)DutGroupin the main package API and as a class attribute onDutfor discoverability. (pytest-embedded/pytest_embedded/__init__.py,pytest-embedded/pytest_embedded/dut.py) [1] [2] [3]Documentation Updates
pytest_embedded.groupand updated usage documentation to explain multi-DUT synchronization, how to useDutGroup, and its benefits for parallel test execution. (docs/apis/pytest-embedded.rst,docs/usages/expecting.rst) [1] [2] [3]Testing
DutGroupcovering container protocol, parallel execution, broadcasting, per-DUT patterns, proxying, multi-phase synchronization, and error handling. (pytest-embedded/tests/test_base.py)These changes significantly enhance the usability of
pytest-embeddedfor scenarios involving multiple devices, making it easier to write robust, synchronized, and efficient multi-device tests.Testing
Tested locally