mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
test(cmakev2): add pytest scripts for cmakev2 build system examples
Add pytest test coverage for cmakev2 build system examples that had none. CMakeLists.txt fixes required to enable testing: conditional_component and plugins: added idf_build_generate_flasher_args() since these use the low-level build API (idf_build_executable / idf_flash_binary) which unlike idf_project_default() does not call it automatically. Without it, flasher_args.json was missing from the build output and pytest-embedded could not initialize the DUT. multi_binary: both app1 and app2 were registered in the global flash target via idf_flash_binary(...FLASH), creating a duplicate key at offset 0x10000 in the flasher_args.json generator expression and preventing the file from being generated. Fixed by removing FLASH from app2's call so only app1 is registered in the global flash target. idf_build_generate_flasher_args() now produces a valid flasher_args.json with app1 as the default app binary. The test patches the binary path to app2.bin when testing the second app.
This commit is contained in:
@@ -28,7 +28,8 @@ idf_check_binary_size(${CMAKE_PROJECT_NAME}_binary)
|
||||
# Create app target
|
||||
add_custom_target(app ALL DEPENDS ${CMAKE_PROJECT_NAME}_binary)
|
||||
|
||||
# Generate metadata
|
||||
# Generate flasher_args.json and metadata
|
||||
idf_build_generate_flasher_args()
|
||||
idf_build_generate_metadata(BINARY ${CMAKE_PROJECT_NAME}_binary)
|
||||
|
||||
# Create other utility targets
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
import textwrap
|
||||
|
||||
import pytest
|
||||
from pytest_embedded import Dut
|
||||
from pytest_embedded_idf.utils import idf_parametrize
|
||||
|
||||
|
||||
@pytest.mark.generic
|
||||
@idf_parametrize('target', ['esp32', 'esp32c3'], indirect=['target'])
|
||||
def test_cmakev2_plugins(dut: Dut) -> None:
|
||||
log_text = textwrap.dedent(r"""
|
||||
Hello plugin performing self-registration...
|
||||
Successfully registered plugin 'Hello'
|
||||
Nihao plugin performing self-registration...
|
||||
Successfully registered plugin 'Nihao'
|
||||
main_task: Calling app_main()
|
||||
List of plugins:
|
||||
- Plugin 'Hello'
|
||||
- Plugin 'Nihao'
|
||||
Calling greet function of plugin 'Hello'...
|
||||
Hello, World!
|
||||
Done with greet function of plugin 'Hello'.
|
||||
Calling greet function of plugin 'Nihao'...
|
||||
你好 World!
|
||||
Done with greet function of plugin 'Nihao'.
|
||||
""").strip('\n')
|
||||
|
||||
for line in log_text.split('\n'):
|
||||
dut.expect_exact(line.encode('utf-8'))
|
||||
Reference in New Issue
Block a user