feat: add pytest-embedded-espemu service for esp-emu (CII-245) - #427
Merged
Conversation
Add an 'espemu' service that runs tests on esp-emu (https://github.com/espressif/esp-emulator), Espressif's emulator for ESP RISC-V series SoCs, instead of a real target: pytest --embedded-services idf,espemu --target esp32c3 EspEmuApp merges the app's flash files into a single image (esptool merge-bin, no padding needed) and EspEmu launches esp-emu with UART0 on stdio, so DUT I/O rides the standard DuplicateStdoutPopen redirection — no serial ports or TCP bridges involved. hard_reset raises NotImplementedError, which IdfUnityDutMixin already handles by re-triggering the Unity test menu. Supported targets: esp32c3, esp32c6, esp32h2, esp32p4, esp32s31. Extra emulator flags pass through --espemu-cli-args/--espemu-extra-args (e.g. '--net user,restrict=yes' to isolate tests from LAN noise).
Cover the service wiring in test_base's service-to-classes parametrization, and add pytester-based tests mirroring pytest-embedded-qemu's against the hello_world_esp32c3 fixture app, skipped when esp-emu is not on PATH: basic expect, multi-count (two emulator instances), and a clear error for unsupported (non-RISC-V) targets. Run them in a test-espemu job that installs esp-emu via its upstream install script.
shubhamdp
force-pushed
the
feat/espemu-service
branch
from
August 11, 2026 09:18
702c796 to
c0ef895
Compare
mahavirj
reviewed
Aug 13, 2026
Member
|
Thank you. All looks good to me. I'll merge it and release the 2.9.0 version next Monday |
Contributor
Author
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a new
espemuservice that runs tests on esp-emulator, Espressif's emulator for ESP RISC-V series SoCs, instead of a real target — analogous to the existingqemuservice:How it works:
EspEmuAppmerges the app's flash files into a single image (esptool merge-bin, no flash-size padding needed)EspEmulaunchesesp-emuwith UART0 on stdio, so DUT I/O rides the standard DuplicateStdoutPopen` redirection — no serial ports or TCP bridges involvedhard_resetraisesNotImplementedError, whichIdfUnityDutMixinalready handles by re-triggering the Unity test menuNew CLI options:
--espemu-image-path,--espemu-prog-path,--espemu-cli-args,--espemu-extra-args(e.g."--net user,restrict=yes"to isolate tests from LAN multicast noise)Supported targets:
esp32c3,esp32c6,esp32h2,esp32p4,esp32s31; other targets fail with a clear error.Motivation: an emulator-backed DUT lets test suites that today run on QEMU or real hardware run anywhere with a single static binary — notably faster and with less CI setup.
Naming: went with
espemuto keep the service key, fixture, module, and CLI prefix identical (likeqemu)Related
Testing
pytest-embedded-espemu/tests/test_espemu.py— pytester-based tests mirroring the qemu service's, against thehello_world_esp32c3fixture app (skipped whenesp-emuis not on PATH): basic expect, multi-count with two emulator instances, and the unsupported-target errorpytest-embedded/tests/test_base.py— service-to-classes parametrization extended withidf,espemu(covers the plugin wiring without needing the emulator binary)New
test-espemujob intest-python.ymlinstalls esp-emu via its upstream install script and runs the tests with coverageFull suite also verified in a clean venv (
bash foreach.sh install) on macOSAlso verified with the esp-matter project where this unit-test-app is ran with this pytest-plugin using esp-emu
Checklist
Before submitting a Pull Request, please ensure the following: