Skip to content

feat: add pytest-embedded-espemu service for esp-emu (CII-245) - #427

Merged
hfudev merged 4 commits into
espressif:mainfrom
shubhamdp:feat/espemu-service
Aug 21, 2026
Merged

feat: add pytest-embedded-espemu service for esp-emu (CII-245)#427
hfudev merged 4 commits into
espressif:mainfrom
shubhamdp:feat/espemu-service

Conversation

@shubhamdp

@shubhamdp shubhamdp commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Description

Add a new espemu service that runs tests on esp-emulator, Espressif's emulator for ESP RISC-V series SoCs, instead of a real target — analogous to the existing qemu service:

pytest --embedded-services idf,espemu --target esp32c3

How it works:

  • EspEmuApp merges the app's flash files into a single image (esptool merge-bin, no flash-size padding needed)

  • 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

  • New 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 espemu to keep the service key, fixture, module, and CLI prefix identical (like qemu)

Related

Testing

  • pytest-embedded-espemu/tests/test_espemu.py — pytester-based tests mirroring the qemu service's, against the hello_world_esp32c3 fixture app (skipped when esp-emu is not on PATH): basic expect, multi-count with two emulator instances, and the unsupported-target error

  • pytest-embedded/tests/test_base.py — service-to-classes parametrization extended with idf,espemu (covers the plugin wiring without needing the emulator binary)

  • New test-espemu job in test-python.yml installs esp-emu via its upstream install script and runs the tests with coverage

  • Full suite also verified in a clean venv (bash foreach.sh install) on macOS

  • Also 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:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

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).
@shubhamdp shubhamdp changed the title Feat/espemu service feat: add pytest-embedded-espemu service for esp-emu Aug 11, 2026
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
shubhamdp force-pushed the feat/espemu-service branch from 702c796 to c0ef895 Compare August 11, 2026 09:18
@github-actions github-actions Bot changed the title feat: add pytest-embedded-espemu service for esp-emu feat: add pytest-embedded-espemu service for esp-emu (CII-245) Aug 11, 2026
@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Title Coverage Tests Skipped Failures Errors Time
Qemu Coverage 7 0 💤 0 ❌ 0 🔥 22.629s ⏱️
3.14 X64 Coverage 120 19 💤 0 ❌ 0 🔥 15m 28s ⏱️
Espemu Coverage 3 0 💤 0 ❌ 0 🔥 3.322s ⏱️
3.10 ARM64 Coverage 120 21 💤 0 ❌ 0 🔥 12m 48s ⏱️

Comment thread .github/workflows/test-python.yml Outdated
@hfudev

hfudev commented Aug 21, 2026

Copy link
Copy Markdown
Member

Thank you. All looks good to me. I'll merge it and release the 2.9.0 version next Monday

@hfudev
hfudev merged commit aeb7d87 into espressif:main Aug 21, 2026
7 checks passed
@shubhamdp

Copy link
Copy Markdown
Contributor Author

Thank you. All looks good to me. I'll merge it and release the 2.9.0 version next Monday

Thank you!

@shubhamdp
shubhamdp deleted the feat/espemu-service branch August 25, 2026 06:23
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