API Reference

pytest-embedded

class pytest_embedded.app.App(app_path: Optional[str] = None, build_dir: Optional[str] = None, **kwargs)

Bases: object

Built binary files base class

app_path

application folder path

Type:

str

binary_path

binary folder path

Type:

str

class pytest_embedded.dut.Dut(*args, **kwargs)

Bases: _InjectMixinCls

Device under test (DUT) base class

pexpect_proc

PexpectProcess instance

Type:

PexpectProcess

app

App instance

Type:

App

logfile

log file path

Type:

str

test_case_name

test case name

Type:

str

close() None
expect(pattern, **kwargs) Match

Expect the pattern from the internal buffer. All the arguments will be passed to pexpect.expect().

Parameters:

pattern – string, or compiled regex, or a list of string and compiled regex.

Keyword Arguments:
  • timeout (float) – would raise pexpect.TIMEOUT exception when pattern is not matched after timeout

  • expect_all (bool) – need to match all specified patterns if this flag is True. Otherwise match any of them could pass

  • not_matching – string, or compiled regex, or a list of string and compiled regex.

Returns:

AnyStr or re.Match

  • AnyStr: if you’re matching pexpect.EOF or pexpect.TIMEOUT to get all the current buffers.

  • re.Match: if matched given string.

expect_exact(pattern, **kwargs) Match

Expect the pattern from the internal buffer. All the arguments will be passed to pexpect.expect_exact().

Parameters:

pattern – string, or a list of string

Keyword Arguments:
  • timeout (float) – would raise pexpect.TIMEOUT exception when pattern is not matched after timeout

  • expect_all (bool) – need to match all specified patterns if this flag is True. Otherwise match any of them could pass

  • not_matching – string, or compiled regex, or a list of string and compiled regex.

Returns:

AnyStr or re.Match

  • AnyStr: if you’re matching pexpect.EOF or pexpect.TIMEOUT to get all the current buffers.

  • re.Match: if matched given string.

expect_unity_test_output(remove_asci_escape_code: bool = True, timeout: float = 60, extra_before: Optional[AnyStr] = None) None

Expect a unity test summary block and parse the output into junit report.

Would combine the junit report into the main one if you use pytest --junitxml feature.

Parameters:
  • remove_asci_escape_code – remove asci escape code in the message field. (default: True)

  • timeout – timeout. (default: 60 seconds)

  • extra_before – would append before the expected bytes. Use this argument when need to run expect functions between one unity test call.

Note

  • Would raise AssertionError at the end of the test if any unity test case result is “FAIL”

  • Would raise TIMEOUT exception at the end of the test if any unity test case execution took longer than timeout value

Warning

  • All unity test cases record would be missed if the final report block is uncaught.

property logdir
run_all_single_board_cases(group: Optional[str] = None, reset: bool = False, timeout: float = 30, run_ignore_cases: bool = False) None

Run all multi_stage cases

Parameters:
  • group – test case group

  • reset – whether to perform a hardware reset before running a case

  • timeout – timeout. (Default: 30 seconds)

  • run_ignore_cases – run ignored test cases or not

Warning

requires enable service idf

write(s: AnyStr) None

Write to the MessageQueue instance

class pytest_embedded.log.DuplicateStdoutPopen(msg_queue: MessageQueue, cmd: Union[str, List[str]], meta: Optional[Meta] = None, **kwargs)

Bases: Popen

Subclass of subprocess.Popen that redirect the output into the MessageQueue instance

REDIRECT_CLS

alias of _PopenRedirectProcess

SOURCE = 'POPEN'
close()
terminate()

Terminate the process with SIGTERM

write(s: AnyStr) None

Write to stdin via stdin.write.

  • If the input is str, will encode to bytes and add a b’\n’ automatically in the end.

  • If the input is bytes, will pass this directly.

Parameters:

s – bytes or str

class pytest_embedded.log.MessageQueue(maxsize=0, *, ctx)

Bases: Queue

flush()
isatty()
put(obj, **kwargs)
write(s: AnyStr)
class pytest_embedded.log.PexpectProcess(fd, args=None, timeout=30, maxread=2000, searchwindowsize=None, logfile=None, encoding=None, codec_errors='strict', use_poll=False)

Bases: fdspawn

Use a temp file to gather multiple inputs into one output, and do pexpect.expect() from one place.

property buffer_debug_str
read_nonblocking(size: int = 1, timeout: int = -1) bytes

Since we’re using real file stream, here we only raise an EOF error when the file stream has been closed. This could solve the os.read() blocked issue.

Parameters:
  • size – Read at most size bytes.

  • timeout – Wait timeout seconds for file descriptor to be ready to read. When -1 (default), use self.timeout. When 0, poll.

Returns:

String containing the bytes read

terminate(force=False)

Close the temporary file stream and itself.

pytest_embedded.log.live_print_call(*args, msg_queue: Optional[MessageQueue] = None, expect_returncode: int = 0, **kwargs)

live print the subprocess.Popen process

Parameters:
  • msg_queueMessageQueue instance, would redirect to message queue instead of sys.stdout if specified

  • expect_returncode – expect return code. (Default 0). Would raise exception when return code is different

Note

This function behaves the same as subprocess.call(), it would block your current process.

class pytest_embedded.unity.JunitMerger(main_junit: Optional[str])

Bases: object

SUB_JUNIT_FILENAME = 'dut.xml'
property junit: ElementTree
merge(junit_files: List[str])
class pytest_embedded.unity.TestCase(name: str, result: str, **kwargs)

Bases: object

to_xml() Element
class pytest_embedded.unity.TestFormat(value)

Bases: Enum

An enumeration.

BASIC = 0
FIXTURE = 1
class pytest_embedded.unity.TestSuite(name: Optional[str] = None, **kwargs)

Bases: object

add_unity_test_cases(s: AnyStr, additional_attrs: Optional[Dict[str, Any]] = None) None
dump(path: str) None
property failed_cases: List[TestCase]
to_xml() Element
pytest_embedded.unity.escape_dict_value(d: Dict[str, Any]) Dict[str, str]
pytest_embedded.unity.escape_illegal_xml_chars(s: str) str
class pytest_embedded.utils.Meta(logdir: str, port_target_cache: Dict[str, str], port_app_cache: Dict[str, str], logfile_extension: str = '.log')

Bases: object

Meta info for testing, session scope

drop_port_app_cache(port: str) None
drop_port_target_cache(port: str) None
hit_port_app_cache(port: str, app: App) bool
hit_port_target_cache(port: str, target: str) bool
logdir: str
logfile_extension: str = '.log'
port_app_cache: Dict[str, str]
port_target_cache: Dict[str, str]
set_port_app_cache(port: str, app: App) None
set_port_target_cache(port: str, target: str) None
exception pytest_embedded.utils.PackageNotInstalledError(service: str)

Bases: SystemExit

exception pytest_embedded.utils.RequireServiceError(func_name: str, services: Union[str, List[str]])

Bases: SystemExit

exception pytest_embedded.utils.UnknownServiceError(service: str)

Bases: SystemExit

exception pytest_embedded.utils.UserHint

Bases: Warning

pytest_embedded.utils.find_by_suffix(suffix: str, path: str) List[str]
pytest_embedded.utils.lazy_load(base_module: module, name_obj_dict: Dict[str, Any], obj_module_dict: Dict[str, str]) Callable[[str], Any]

use __getattr__ in the __init__.py file to lazy load some objects

Parameters:
  • base_module (ModuleType) – base package module

  • name_obj_dict (dict[str, any]) – name, real object dict, used to store real objects, no need to add lazy-load objects

  • obj_module_dict (dict[str, str]) – dict of object name and module name

Returns:

__getattr__ function

Example

__getattr__ = lazy_load(
    importlib.import_module(__name__),
    {
        'IdfApp': IdfApp,
        'LinuxDut': LinuxDut,
        'LinuxSerial': LinuxSerial,
        'CaseTester': CaseTester,
    },
    {
        'IdfSerial': '.serial',
        'IdfDut': '.dut',
    },
)
pytest_embedded.utils.remove_asci_color_code(s: AnyStr) str
pytest_embedded.utils.to_bytes(bytes_str: AnyStr, ending: Optional[AnyStr] = None) bytes

Turn bytes or str to bytes

Parameters:
  • bytes_strbytes or str

  • endingbytes or str, will add to the end of the result. Only works when the bytes_str is str

Returns:

utf8-encoded bytes

pytest_embedded.utils.to_list(s: _T) List[_T]
Parameters:

s – Anything

Returns:

List (list[_T])

  • list(s) (List. If s is a tuple or a set.

  • itself. If s is a list.

  • [s]. If s is other types.

pytest_embedded.utils.to_str(bytes_str: AnyStr) str

Turn bytes or str to str

Parameters:

bytes_strbytes or str

Returns:

utf8-decoded string

pytest-embedded-serial

class pytest_embedded_serial.serial.Serial(msg_queue: MessageQueue, port: Optional[str] = None, port_location: Optional[str] = None, baud: int = 115200, meta: Optional[Meta] = None, **kwargs)

Bases: object

Custom serial class

port

port address

Type:

str

baud

baud rate

Type:

int

proc

process created by serial.serial_for_url()

Type:

pyserial.Serial

Warning

  • make sure this Serial.__init__() run the last in MRO, it would create and start the redirect serial process

DEFAULT_BAUDRATE = 115200
DEFAULT_PORT_CONFIG: ClassVar[Dict[str, Any]] = {'baudrate': 115200, 'bytesize': 8, 'parity': 'N', 'rtscts': False, 'stopbits': 1, 'timeout': 0.05, 'xonxoff': False}
close()
disable_redirect_thread() bool

kill the redirect thread, and start a new one after got yield back

Yields:

True if redirect serial thread has been terminated

occupied_ports: ClassVar[Dict[str, None]] = {}
start_redirect_thread() None
stop_redirect_thread() bool
class pytest_embedded_serial.dut.SerialDut(*args, **kwargs)

Bases: Dut

Dut class for serial ports

serial

Serial instance

Type:

Serial

openocd

OpenOcd instance, applied only when jtag service is activated

Type:

OpenOcd

gdb

Gdb instance, applied only when jtag service is activated

Type:

Gdb

telnet

Telnet instance, applied only when jtag service is activated

Type:

Telnet

setup_jtag()
write(data: AnyStr) None

Write to the MessageQueue instance

pytest-embedded-serial-esp

class pytest_embedded_serial_esp.serial.EspSerial(pexpect_proc: PexpectProcess, msg_queue: MessageQueue, target: Optional[str] = None, beta_target: Optional[str] = None, port: Optional[str] = None, port_mac: Optional[str] = None, baud: int = 115200, esptool_baud: int = 921600, esp_flash_force: bool = False, skip_autoflash: bool = False, erase_all: bool = False, meta: Optional[Meta] = None, **kwargs)

Bases: Serial

Serial class for ports connected to espressif products

ESPTOOL_DEFAULT_BAUDRATE = 921600
erase_flash(force: bool = False) None

Erase the complete flash

hard_reset()

Hard reset your espressif device

property stub
use_esptool(no_stub: bool = False)
  1. tell the redirect serial thread to stop reading from the pyserial instance

  2. esptool reuse the pyserial instance and call run_stub()

  3. call to the decorated function, could use self.stub inside the function as the stubbed loader

  4. call hard_reset(), if hard_reset_after is True

  5. tell the redirect serial thread to continue reading from serial

Parameters:
  • hard_reset_after – run hard reset after

  • no_stub – disable launching the flasher stub

class pytest_embedded_serial_esp.serial.EsptoolArgs(**kwargs)

Bases: object

fake args object, this is a hack until esptool Python API is improved

pytest-embedded-jtag

class pytest_embedded_jtag.openocd.OpenOcd(openocd_prog_path: Optional[str] = None, openocd_cli_args: Optional[str] = None, port_offset: int = 0, **kwargs)

Bases: DuplicateStdoutPopen

Class to communicate to OpenOCD

GDB_BASE_PORT = 3333
OPENOCD_DEFAULT_ARGS = '-f board/esp32-wrover-kit-3.3v.cfg'
OPENOCD_PROG_PATH = 'openocd'
REDIRECT_CLS = None
SOURCE = 'OPENOCD'
TCL_BASE_PORT = 6666
TELNET_BASE_PORT = 4444
write(s: AnyStr) str

Write to stdin via stdin.write.

  • If the input is str, will encode to bytes and add a b’\n’ automatically in the end.

  • If the input is bytes, will pass this directly.

Parameters:

s – bytes or str

class pytest_embedded_jtag.gdb.Gdb(gdb_prog_path: Optional[str] = None, gdb_cli_args: Optional[str] = None, **kwargs)

Bases: DuplicateStdoutPopen

GDB_DEFAULT_ARGS = '--quiet'
GDB_PROG_PATH = 'xtensa-esp32-elf-gdb'
REDIRECT_CLS = None
SOURCE = 'GDB'
write(s: AnyStr, non_blocking: bool = False, timeout: float = 30) Optional[str]

Write to stdin via stdin.write.

  • If the input is str, will encode to bytes and add a b’\n’ automatically in the end.

  • If the input is bytes, will pass this directly.

Parameters:

s – bytes or str

pytest-embedded-idf

class pytest_embedded_idf.app.FlashFile(offset, file_path, encrypted)

Bases: tuple

property encrypted

Alias for field number 2

property file_path

Alias for field number 1

property offset

Alias for field number 0

class pytest_embedded_idf.app.IdfApp(*args, part_tool: Optional[str] = None, **kwargs)

Bases: App

Idf App class

elf_file

elf file path

Type:

str

flash_args

dict of flasher_args.json

Type:

dict[str, Any]

flash_files

list of (offset, file path, encrypted) of files need to be flashed in

Type:

list[FlashFile]

flash_settings

dict of flash settings

Type:

dict[str, Any]

FLASH_ARGS_FILENAME = 'flash_args'
FLASH_ARGS_JSON_FILENAME = 'flasher_args.json'
FLASH_PROJECT_ARGS_FILENAME = 'flash_project_args'
RISCV32_TARGETS: ClassVar[List[str]] = ['esp32c3', 'esp32h2', 'esp32c2', 'esp32c6']
XTENSA_TARGETS: ClassVar[List[str]] = ['esp32', 'esp32s2', 'esp32s3']
get_sha256(filepath: str) Optional[str]

Get the sha256 of the file

Parameters:

filepath – path to the file

Returns:

sha256 value appended to app

property is_riscv32
property is_xtensa
property partition_table: Dict[str, Any]

Returns: partition table dict generated by the partition tool

property parttool_path: str

Returns: Partition tool path

property sdkconfig: Dict[str, Any]

Returns: dict contains all k-v pairs from the sdkconfig file

property target: str

Returns: target chip type

property write_flash_args

Returns: list of flash args

class pytest_embedded_idf.serial.IdfSerial(app: IdfApp, target: Optional[str] = None, confirm_target_elf_sha256: bool = False, erase_nvs: bool = False, **kwargs)

Bases: EspSerial

IDF serial Dut class

Auto flash the app while starting test.

DEFAULT_SHA256_OFFSET = 176
SUGGEST_FLASH_BAUDRATE = 921600
dump_flash(partition: Optional[str] = None, address: Optional[str] = None, size: Optional[str] = None, output: Optional[Union[str, TextIO]] = None) Optional[bytes]

Dump the flash bytes into the output file by partition name or by start address and size.

Parameters:
  • output – file path or file stream to write to. File stream should be opened with bytes mode.

  • partition – partition name

  • address – address that start reading from

  • size – read size

Returns:

None if output is str or file stream. bytes if output is None.

erase_flash(force: bool = False)

Erase the complete flash

erase_partition(partition_name: str) None

Erase the partition provided

Parameters:

partition_name – partition name

flash(app: Optional[IdfApp] = None) None

Flash the app.flash_files to the dut

is_target_flashed_same_elf() bool

Check if the sha256 values are matched between the flashed target and the self.app.elf_file

Returns:

True if the sha256 values are matched

load_ram() None
read_flash_elf_sha256() bytes

Read the sha256 digest of the flashed elf file

Returns:

bytes of sha256

class pytest_embedded_idf.linux.LinuxDut(*args, **kwargs)

Bases: Dut

Dut class for Linux targets

serial

LinuxSerial instance

Type:

LinuxSerial

write(data: AnyStr) None

Write to the MessageQueue instance

class pytest_embedded_idf.linux.LinuxSerial(app: IdfApp, **kwargs)

Bases: DuplicateStdoutPopen

Linux serial Dut class

hard_reset() None

Perform a fake hardware reset

class pytest_embedded_idf.dut.IdfDut(*args, **kwargs)

Bases: IdfUnityDutMixin, SerialDut

Dut class for serial ports connect to Espressif boards which are flashed with ESP-IDF apps

target

target chip type

Type:

str

skip_check_coredump

skip check core dumped or not while dut teardown if set to True

Type:

bool

COREDUMP_UART_END = b'================= CORE DUMP END ================='
COREDUMP_UART_REGEX = re.compile(b'================= CORE DUMP START =================(.+?)================= CORE DUMP END =================', re.DOTALL)
COREDUMP_UART_START = b'================= CORE DUMP START ================='
PANIC_END = b'ELF file SHA256:'
PANIC_START = b'register dump:'
RISCV32_TARGETS = ['esp32c3', 'esp32h2', 'esp32c2', 'esp32c6']
XTENSA_TARGETS = ['esp32', 'esp32s2', 'esp32s3']
app: IdfApp
close() None
flash_via_jtag()
property panic_output_decode_script: Optional[str]

Returns: Panic output decode script path

serial: EspSerial
setup_jtag()
property toolchain_prefix: str

Returns: Toolchain prefix according to the self.target

write(data: AnyStr) None

Write to the MessageQueue instance

class pytest_embedded_idf.unity_tester.CaseTester(dut: Union[IdfDut, List[IdfDut]])

Bases: object

The Generic tester of all the types

dut

The first dut if there is more than one

Type:

IdfDut

test_menu

The list of the cases

Type:

t.List[UnittestMenuCase]

run_all_cases(reset: bool = False, timeout: int = 90, start_retry: int = 3) None

Run all cases

Parameters:
  • reset – whether to perform a hardware reset before running a case

  • timeout – timeout in second

  • start_retry (int) – number of retries for a single case when it is failed to start

run_all_multi_dev_cases(reset: bool = False, timeout: float = 90, start_retry: int = 3) None

Run only multi_device cases

Parameters:
  • reset – whether to perform a hardware reset before running a case

  • timeout – timeout in second

  • start_retry (int) – number of retries for a single case when it is failed to start

run_all_multi_stage_cases(reset: bool = False, timeout: int = 90) None

Run all multi_stage cases

Parameters:
  • reset – whether do a hardware reset before running the case

  • timeout – timeout in second

run_all_normal_cases(reset: bool = False, timeout: int = 90) None

Run all normal cases

Parameters:
  • reset – whether do a hardware reset before running the case

  • timeout – timeout in second

run_case(case: UnittestMenuCase, reset: bool = False, timeout: int = 90, start_retry: int = 3) None

Run a specific case

Parameters:
  • case – the specific case that parsed in test menu

  • reset – whether to perform a hardware reset before running a case

  • timeout – timeout in second, setup time excluded

  • start_retry (int) – number of retries for a single case when it is failed to start

run_multi_dev_case(case: UnittestMenuCase, reset: bool = False, timeout: float = 90, start_retry: int = 3) None

Run a specific multi_device case

Note

Will skip with a warning if the case type is not multi_device

Parameters:
  • case – the specific case that parsed in test menu

  • reset – whether to perform a hardware reset before running a case

  • timeout – timeout in second

  • start_retry (int) – number of retries for a single case when it is failed to start

run_multi_stage_case(case: UnittestMenuCase, reset: bool = False, timeout: int = 90) None

Run a specific multi_stage case

Notes

Will skip if the case type is not multi_stage

Parameters:
  • case – the specific case that parsed in test menu

  • reset – whether do a hardware reset before running the case

  • timeout – timeout in second

run_normal_case(case: UnittestMenuCase, reset: bool = False, timeout: int = 90) None

Run a specific normal case

Notes

Will skip if the case type is not normal

Parameters:
  • case – the specific case that parsed in test menu

  • reset – whether do a hardware reset before running the case

  • timeout – timeout in second

class pytest_embedded_idf.unity_tester.IdfUnityDutMixin(*args, **kwargs)

Bases: object

This mixin class provide ESP-IDF modified unity test framework related functions.

confirm_write(write_str: Any, *, expect_pattern: Optional[Any] = None, expect_str: Optional[Any] = None, timeout: int = 1, retry_times: int = 3)
parse_test_menu(ready_line: str = 'Press ENTER to see the list of tests', pattern="Here's the test menu, pick your combo:(.+)Enter test for running.", trigger: str = '') List[UnittestMenuCase]
static parse_unity_menu_from_str(s: str) List[UnittestMenuCase]
run_all_single_board_cases(group: Optional[str] = None, reset: bool = False, timeout: float = 30, run_ignore_cases: bool = False) None

Run all single board cases, including multi_stage cases, and normal cases

Parameters:
  • group – test case group

  • reset – whether to perform a hardware reset before running a case

  • timeout – timeout. (Default: 30 seconds)

  • run_ignore_cases – run ignored test cases or not

run_single_board_case(name: str, reset: bool = False, timeout: float = 30) None
property test_menu: List[UnittestMenuCase]
class pytest_embedded_idf.unity_tester.MultiDevRunTestManager(duts, case, start_retry, wait_for_menu_timeout, runtest_timeout)

Bases: object

Manager for control dut generator function

add_report_to_first_dut(attrs)
gather()
static get_merge_data(test_cases_attr: List[Dict]) Dict
get_processed_report_data(res: List[Any]) List[Dict]
next_for_all()
class pytest_embedded_idf.unity_tester.UnittestMenuCase(index: int, name: str, type: str, keywords: List[str], groups: List[str], attributes: Dict[str, Any], subcases: List[Dict[str, Any]])

Bases: object

Dataclass of esp-idf unit test cases parsed from test menu

attributes: Dict[str, Any]

Dict of attributes of this case, which is used to describe timeout duration,

groups: List[str]

List of groups of this case, this is usually the component which this case belongs to.

index: int

The index of the case, which can be used to run this case.

property is_ignored
keywords: List[str]

List of additional keywords of this case. For now, we have disable and ignore.

name: str

The name of the case.

subcases: List[Dict[str, Any]]

List of dict of subcases of this case, if this case is a multi_stage or multi_device one.

type: str

Type of this case, which can be normal multi_stage or multi_device.

pytest-embedded-arduino

class pytest_embedded_arduino.app.ArduinoApp(**kwargs)

Bases: App

Arduino App class

sketch

Sketch name.

Type:

str

fqbn

Fully Qualified Board Name.

Type:

str

target

ESPxx chip.

Type:

str

flash_files

List of (offset, file path, encrypted) of files need to be flashed in.

Type:

List[Tuple[int, str, str]]

binary_offsets: ClassVar[Dict[str, List[int]]] = {'esp32': [4096, 32768, 65536], 'esp32c3': [0, 32768, 65536], 'esp32c6': [0, 32768, 65536], 'esp32h2': [0, 32768, 65536], 'esp32s2': [4096, 32768, 65536], 'esp32s3': [0, 32768, 65536]}

dict of binaries’ offset.

flash_settings: ClassVar[Dict[str, Dict[str, str]]] = {'esp32': {'flash_freq': '80m', 'flash_mode': 'dio', 'flash_size': 'detect'}, 'esp32c3': {'flash_freq': '80m', 'flash_mode': 'dio', 'flash_size': 'detect'}, 'esp32c6': {'flash_freq': '80m', 'flash_mode': 'dio', 'flash_size': 'detect'}, 'esp32h2': {'flash_freq': '48m', 'flash_mode': 'dio', 'flash_size': 'detect'}, 'esp32s2': {'flash_freq': '80m', 'flash_mode': 'dio', 'flash_size': 'detect'}, 'esp32s3': {'flash_freq': '80m', 'flash_mode': 'dio', 'flash_size': 'detect'}}

dict of flash settings

class pytest_embedded_arduino.serial.ArduinoSerial(app: ArduinoApp, target: Optional[str] = None, **kwargs)

Bases: EspSerial

Arduino serial Dut class

Auto flash the app while starting test.

SUGGEST_FLASH_BAUDRATE = 921600
flash() None

Flash the binary files to the board.

pytest-embedded-qemu

class pytest_embedded_qemu.app.IdfFlashImageMaker(app: ~pytest_embedded_qemu.app.QemuApp, image_path: str, *, qemu_version: ~packaging.version.Version = <Version('8.0.0')>)

Bases: object

Create a single image for QEMU based on the IdfApp’s partition table and all the flash files.

RISCV_FLASH_BIN_SIZES: ClassVar[List[Tuple[int, str]]] = [(262144, '256KB'), (524288, '512KB'), (1048576, '1MB'), (2097152, '2MB'), (4194304, '4MB'), (8388608, '8MB'), (16777216, '16MB'), (33554432, '32MB'), (67108864, '64MB'), (134217728, '128MB')]
XTENSA_FLASH_BIN_SIZES: ClassVar[List[Tuple[int, str]]] = [(2097152, '2MB'), (4194304, '4MB'), (8388608, '8MB'), (16777216, '16MB')]
make_bin() None

Create a single image file for qemu.

property qemu_flash_size: str

Get QEMU flash size.

If flash_size is set to keep or detect, the size will be automatically detected. Otherwise, the size will be taken from flash_size settings.

Returns:

QEMU flash size

Warning

QEMU < 8.0.0 only support 4MB flash image size for xtensa.

class pytest_embedded_qemu.app.QemuApp(msg_queue: MessageQueue, qemu_image_path: Optional[str] = None, skip_regenerate_image: Optional[bool] = False, encrypt: Optional[bool] = False, keyfile: Optional[str] = None, **kwargs)

Bases: IdfApp

QEMU App class

image_path

QEMU flash-able bin path

Type:

str

QEMU_VERSION_REGEX = re.compile('QEMU emulator version (\\d+\\.\\d+\\.\\d+)')
create_image() None

Create the image, if it doesn’t exist.

property qemu_version: Version

Get QEMU version

Returns:

QEMU version

class pytest_embedded_qemu.qemu.Qemu(qemu_image_path: Optional[str] = None, qemu_prog_path: Optional[str] = None, qemu_cli_args: Optional[str] = None, qemu_extra_args: Optional[str] = None, app: Optional[QemuApp] = None, **kwargs)

Bases: DuplicateStdoutPopen

QEMU class

QEMU_DEFAULT_ARGS = '-nographic -machine esp32'
QEMU_DEFAULT_FMT = '-nographic -machine {}'
QEMU_DEFAULT_QMP_FMT = '-qmp tcp:127.0.0.1:{},server,wait=off'
QEMU_PROG_FMT = 'qemu-system-{}'
QEMU_PROG_PATH = 'qemu-system-xtensa'
QEMU_SERIAL_TCP_FMT = '-serial tcp::{},server,nowait'
QEMU_STRAP_MODE_FMT = '-global driver=esp32.gpio,property=strap_mode,value={}'
SOURCE = 'QEMU'
property qemu_default_args
property qemu_prog_name
qmp_execute_cmd(execute, arguments=None)
take_screenshot(image_path)
class pytest_embedded_qemu.dut.QemuDut(*args, **kwargs)

Bases: Dut

QEMU dut class

hard_reset()
write(s: AnyStr) None

Write to the MessageQueue instance

pytest-embedded-wokwi