mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
test: use pytest for examples/custom_bootloader
This commit is contained in:
parent
2cf17f802f
commit
5c3bc247cb
@ -39,6 +39,13 @@ build_examples_pytest_esp32:
|
|||||||
script:
|
script:
|
||||||
- python tools/ci/build_pytest_apps.py --all-pytest-apps --under-dir examples --target esp32 --size-info $SIZE_INFO_LOCATION -vv
|
- python tools/ci/build_pytest_apps.py --all-pytest-apps --under-dir examples --target esp32 --size-info $SIZE_INFO_LOCATION -vv
|
||||||
|
|
||||||
|
build_examples_pytest_esp32s2:
|
||||||
|
extends:
|
||||||
|
- .build_pytest_template
|
||||||
|
- .rules:build:example_test-esp32s2
|
||||||
|
script:
|
||||||
|
- python tools/ci/build_pytest_apps.py --all-pytest-apps --under-dir examples --target esp32s2 --size-info $SIZE_INFO_LOCATION -vv
|
||||||
|
|
||||||
build_examples_pytest_esp32c3:
|
build_examples_pytest_esp32c3:
|
||||||
extends:
|
extends:
|
||||||
- .build_pytest_template
|
- .build_pytest_template
|
||||||
|
@ -28,6 +28,19 @@ example_test_pytest_esp32_generic:
|
|||||||
- ESP32
|
- ESP32
|
||||||
- Example_GENERIC
|
- Example_GENERIC
|
||||||
|
|
||||||
|
example_test_pytest_esp32s2_generic:
|
||||||
|
extends:
|
||||||
|
- .pytest_examples_dir_template
|
||||||
|
- .rules:test:example_test-esp32s2
|
||||||
|
needs:
|
||||||
|
- build_examples_pytest_esp32s2
|
||||||
|
variables:
|
||||||
|
TARGET_MARKER: esp32s2
|
||||||
|
ENV_MARKER: generic
|
||||||
|
tags:
|
||||||
|
- ESP32S2
|
||||||
|
- Example_GENERIC
|
||||||
|
|
||||||
example_test_pytest_esp32c3_generic:
|
example_test_pytest_esp32c3_generic:
|
||||||
extends:
|
extends:
|
||||||
- .pytest_examples_dir_template
|
- .pytest_examples_dir_template
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import ttfw_idf
|
|
||||||
|
|
||||||
|
|
||||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32s2', 'esp32c3'])
|
|
||||||
def test_custom_bootloader_hooks_example(env, _): # type: ignore
|
|
||||||
# Test with default build configurations
|
|
||||||
dut = env.get_dut('main', 'examples/custom_bootloader/bootloader_hooks')
|
|
||||||
dut.start_app()
|
|
||||||
|
|
||||||
# Expect to read both hooks messages
|
|
||||||
dut.expect('This hook is called BEFORE bootloader initialization')
|
|
||||||
dut.expect('This hook is called AFTER bootloader initialization')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
test_custom_bootloader_hooks_example()
|
|
@ -0,0 +1,15 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded.dut import Dut
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32
|
||||||
|
@pytest.mark.esp32s2
|
||||||
|
@pytest.mark.esp32c3
|
||||||
|
@pytest.mark.generic
|
||||||
|
def test_custom_bootloader_hooks_example(dut: Dut) -> None:
|
||||||
|
# Expect to read both hooks messages
|
||||||
|
dut.expect_exact('This hook is called BEFORE bootloader initialization')
|
||||||
|
dut.expect_exact('This hook is called AFTER bootloader initialization')
|
@ -1,23 +0,0 @@
|
|||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
import ttfw_idf
|
|
||||||
|
|
||||||
|
|
||||||
@ttfw_idf.idf_example_test(env_tag='Example_GENERIC', target=['esp32', 'esp32s2', 'esp32c3'])
|
|
||||||
def test_custom_bootloader_impl_example(env, _): # type: ignore
|
|
||||||
# Test with default build configurations
|
|
||||||
dut = env.get_dut('main', 'examples/custom_bootloader/bootloader_override')
|
|
||||||
dut.start_app()
|
|
||||||
|
|
||||||
# Expect to read a message from the custom bootloader
|
|
||||||
# This message is defined in the Kconfig file, retrieve it while deleting
|
|
||||||
# leading and trailing quotes (")
|
|
||||||
welcome_message = dut.app.get_sdkconfig()['CONFIG_EXAMPLE_BOOTLOADER_WELCOME_MESSAGE'].strip("\"")
|
|
||||||
dut.expect(welcome_message)
|
|
||||||
|
|
||||||
# Expect to read a message from the user application
|
|
||||||
dut.expect('Application started!')
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
test_custom_bootloader_impl_example()
|
|
@ -0,0 +1,21 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from pytest_embedded.dut import Dut
|
||||||
|
from pytest_embedded_idf.app import IdfApp
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.esp32
|
||||||
|
@pytest.mark.esp32s2
|
||||||
|
@pytest.mark.esp32c3
|
||||||
|
@pytest.mark.generic
|
||||||
|
def test_custom_bootloader_impl_example(app: IdfApp, dut: Dut) -> None:
|
||||||
|
# Expect to read a message from the custom bootloader
|
||||||
|
# This message is defined in the Kconfig file, retrieve it while deleting
|
||||||
|
# leading and trailing quotes (")
|
||||||
|
welcome_message = app.sdkconfig['EXAMPLE_BOOTLOADER_WELCOME_MESSAGE']
|
||||||
|
dut.expect_exact(welcome_message)
|
||||||
|
|
||||||
|
# Expect to read a message from the user application
|
||||||
|
dut.expect_exact('Application started!')
|
@ -2,6 +2,7 @@
|
|||||||
# only the files with prefix `pytest_` would be recognized as pytest test scripts.
|
# only the files with prefix `pytest_` would be recognized as pytest test scripts.
|
||||||
python_files = pytest_*.py
|
python_files = pytest_*.py
|
||||||
|
|
||||||
|
# ignore PytestExperimentalApiWarning for record_xml_attribute
|
||||||
addopts =
|
addopts =
|
||||||
--embedded-services esp,idf
|
--embedded-services esp,idf
|
||||||
-W ignore::_pytest.warning_types.PytestExperimentalApiWarning
|
-W ignore::_pytest.warning_types.PytestExperimentalApiWarning
|
||||||
@ -9,6 +10,7 @@ addopts =
|
|||||||
markers =
|
markers =
|
||||||
esp32: support esp32 target
|
esp32: support esp32 target
|
||||||
esp32s2: support esp32s2 target
|
esp32s2: support esp32s2 target
|
||||||
|
esp32s3: support esp32s3 target
|
||||||
esp32c3: support esp32c3 target
|
esp32c3: support esp32c3 target
|
||||||
generic: tests should be run on generic runners
|
generic: tests should be run on generic runners
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user