Pytest Embedded QEMU Plugin

2.7.0 · active · verified Thu Apr 16

pytest-embedded-qemu is a plugin for the pytest-embedded framework that enables running embedded tests on QEMU instead of actual hardware targets. It extends pytest-embedded with QEMU-specific functionalities, allowing for automated creation of QEMU bootable images and handling device output. It is currently at version 2.7.0 and is actively maintained with a regular release cadence as part of the broader `pytest-embedded` ecosystem by Espressif Systems.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates a basic test using the `dut` fixture provided by `pytest-embedded`, configured to interact with a QEMU instance. To run this test, save it as a Python file (e.g., `test_qemu.py`) and execute `pytest --embedded-services qemu` in your terminal. You will also need a QEMU-compatible application to run in the simulated environment.

import pytest
from pytest_embedded import Dut

def test_qemu_basic(dut: Dut):
    # This test requires QEMU to be running the target application.
    # The 'dut' fixture provides access to the QEMU's console output.
    # Run with: pytest --embedded-services qemu
    print(f"QEMU DUT received: {dut.read_until_timeout(1)}")
    dut.write("hello from pytest\n")
    dut.expect_exact("hello from pytest")
    print("Successfully communicated with QEMU DUT")

view raw JSON →