diff --git a/tools/test_apps/system/startup/app_test.py b/tools/test_apps/system/startup/app_test.py index 9ce0a214f0..d7d1ee94bd 100644 --- a/tools/test_apps/system/startup/app_test.py +++ b/tools/test_apps/system/startup/app_test.py @@ -2,9 +2,11 @@ import glob import os +import re import ttfw_idf from tiny_test_fw import Utility +from ttfw_idf.IDFDUT import ESP32DUT @ttfw_idf.idf_custom_test(env_tag='Example_GENERIC', group='test-apps') @@ -15,7 +17,14 @@ def test_startup(env, extra_data): Utility.console_log("Checking config \"{}\"... ".format(name), end='') dut = env.get_dut('startup', 'tools/test_apps/system/startup', app_config_name=name) dut.start_app() - dut.expect('app_main running') + + if (name == 'single_core_variant' and isinstance(dut, ESP32DUT)): + dut.allow_dut_exception = True + dut.expect('Running on single core variant of a chip, but app is built with multi-core support.') + dut.expect(re.compile(r'abort\(\) was called at PC [0-9xa-f]+ on core 0')) + else: + dut.expect('app_main running') + env.close_dut(dut.name) Utility.console_log('done') diff --git a/tools/test_apps/system/startup/main/CMakeLists.txt b/tools/test_apps/system/startup/main/CMakeLists.txt index 53aa18c094..2ba0fd3b3f 100644 --- a/tools/test_apps/system/startup/main/CMakeLists.txt +++ b/tools/test_apps/system/startup/main/CMakeLists.txt @@ -1,2 +1,7 @@ idf_component_register(SRCS "test_startup_main.c" INCLUDE_DIRS ".") + +if(CONFIG_SINGLE_CORE_VARIANT) + target_sources(${COMPONENT_LIB} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/chip_info_patch.c") + target_link_libraries(${COMPONENT_LIB} INTERFACE "-Wl,--wrap=esp_chip_info") +endif() diff --git a/tools/test_apps/system/startup/main/Kconfig b/tools/test_apps/system/startup/main/Kconfig new file mode 100644 index 0000000000..220ac13799 --- /dev/null +++ b/tools/test_apps/system/startup/main/Kconfig @@ -0,0 +1,6 @@ +menu "Test app config" + config SINGLE_CORE_VARIANT + bool "Patch esp_chip_info to return single core in a multicore chip" + default "n" + depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3 +endmenu diff --git a/tools/test_apps/system/startup/main/chip_info_patch.c b/tools/test_apps/system/startup/main/chip_info_patch.c new file mode 100644 index 0000000000..21b6ac78bc --- /dev/null +++ b/tools/test_apps/system/startup/main/chip_info_patch.c @@ -0,0 +1,24 @@ +// Copyright 2013-2016 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "esp_system.h" + +extern void __real_esp_chip_info(esp_chip_info_t* out_info); + +// Fake a single core chip for testing purposes only, see CONFIG_SINGLE_CORE_VARIANT +void __wrap_esp_chip_info(esp_chip_info_t* out_info) +{ + __real_esp_chip_info(out_info); + out_info->cores = 1; +} diff --git a/tools/test_apps/system/startup/sdkconfig.ci.single_core_variant b/tools/test_apps/system/startup/sdkconfig.ci.single_core_variant new file mode 100644 index 0000000000..61216b07fa --- /dev/null +++ b/tools/test_apps/system/startup/sdkconfig.ci.single_core_variant @@ -0,0 +1 @@ +CONFIG_SINGLE_CORE_VARIANT=y