Skip to content

fix: expose target on the emulator duts (CII-248) - #429

Merged
hfudev merged 1 commit into
espressif:mainfrom
Harshal5:fix/espemu_dut_target
Aug 27, 2026
Merged

fix: expose target on the emulator duts (CII-248)#429
hfudev merged 1 commit into
espressif:mainfrom
Harshal5:fix/espemu_dut_target

Conversation

@Harshal5

@Harshal5 Harshal5 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Description

Any test or fixture that selects behavior by target fails under --embedded-services idf,espemu or --embedded-services idf,qemu:

AttributeError: 'EspEmuDutWithIdfUnityDutMixin' object has no attribute 'target'
AttributeError: 'QemuDutWithIdfUnityDutMixin'   object has no attribute 'target'

EspEmuDut and QemuDut both extend the plain Dut, which knows self.app but not the target. The attribute is set by IdfDut.__init__ (self.target = app.target), and IdfDut(IdfUnityDutMixin, SerialDut) is serial based, so dut_factory.py correctly picks the emulator dut classes and the attribute is simply absent.

This is not a corner case for ESP-IDF users: dut.target is referenced by ESP-IDF's root conftest.py helpers, so a large share of ESP-IDF's test cases cannot run under either emulator. Reproduced with examples/get-started/hello_world on esp32c3 for both services:

$ pytest examples/get-started/hello_world -k test_hello_world
          --target esp32c3 --embedded-services idf,qemu
...
conftest.py:508: in real_func
    dut.target,
E   AttributeError: 'QemuDutWithIdfUnityDutMixin' object has no attribute 'target'

Fix

Take the target from the app in both duts. EspEmuApp and QemuApp are IdfApp subclasses, so the value is available; getattr keeps it optional for other app classes, since the base App has no target.

self.target: str | None = getattr(self.app, 'target', None)

NuttxQemuDut inherits QemuDut and picks this up too, with None for apps that have no target.

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.

`EspEmuDut` and `QemuDut` extend the plain `Dut`, so `dut.target` was missing
and every fixture that selects behavior by target failed. Take it from the app.
@github-actions

Copy link
Copy Markdown
Title Coverage Tests Skipped Failures Errors Time
Qemu Coverage 7 0 💤 0 ❌ 0 🔥 25.465s ⏱️
3.14 X64 Coverage 122 19 💤 1 ❌ 0 🔥 15m 23s ⏱️
Espemu Coverage 3 0 💤 0 ❌ 0 🔥 3.851s ⏱️
3.10 ARM64 Coverage 122 21 💤 0 ❌ 0 🔥 12m 53s ⏱️

@github-actions github-actions Bot changed the title fix: expose target on the emulator duts fix: expose target on the emulator duts (CII-248) Aug 27, 2026
@hfudev
hfudev merged commit bf8b4dc into espressif:main Aug 27, 2026
6 of 7 checks passed
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