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
- flash_files
list of (offset, file path, encrypted) of files need to be flashed in
- 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']
- 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 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
- 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']
- flash_via_jtag()
- setup_jtag()
- class pytest_embedded_idf.linux.LinuxDut(*args, **kwargs)
Bases:
Dut
Dut class for Linux targets
- serial
LinuxSerial instance
- Type:
- class pytest_embedded_idf.linux.LinuxSerial(app: IdfApp, **kwargs)
Bases:
DuplicateStdoutPopen
Linux serial Dut class
- 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_partition(partition_name: str) None
Erase the partition provided
- Parameters:
partition_name – partition name
- class pytest_embedded_idf.unity_tester.CaseTester(dut: Union[IdfDut, List[IdfDut]])
Bases:
object
The Generic tester of all the types
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)
- 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:
group – test case group or a list of test case groups to run. Supports ‘and’ with ‘&’. Supports group inversion with ‘!’.
reset – Whether to perform a hardware reset before running a test case.
timeout – Timeout in seconds. (Default: 30 seconds)
run_ignore_cases – Whether to run ignored test cases or not.
name – test case name or a list of test case names to run.
attributes – Dictionary of attributes to filter and run test cases.
dry_run – If True, then just show a list of test case names without running them. (please set the logging level as INFO to see them)
- 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()
- 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.
- property is_ignored