pytest-embedded-idf — pytest-embedded 1.x documentation (original) (raw)

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', 'esp32c2', 'esp32c6', 'esp32c5', 'esp32p4', 'esp32h2', 'esp32c61']

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.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', 'esp32c2', 'esp32c6', 'esp32c5', 'esp32p4', 'esp32h2', 'esp32c61']

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.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.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:

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.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

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:

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

Run only multi_device cases

Parameters:

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

Run all multi_stage cases

Parameters:

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

Run all normal cases

Parameters:

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

Run a specific case

Parameters:

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:

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:

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:

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)

run_all_single_board_cases(group: Optional[Union[str, list]] = None, reset: bool = False, timeout: float = 30, run_ignore_cases: bool = False, name: Optional[Union[str, list]] = None, attributes: Optional[dict] = None, dry_run: bool = False) → None

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

Note

If a group, name, and attributes are used together, then if test case matches any of them, it will be selected.

Parameters:

run_single_board_case(name: str, reset: bool = False, timeout: float = 30) → None

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

next_for_all()

Bases: object

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

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

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

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

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

The name of the case.

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

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