mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/bootloader_support_mock' into 'master'
feat(bootloader_support): added bootloader_support mocks See merge request espressif/esp-idf!32603
This commit is contained in:
commit
90cc261916
18
tools/mocks/bootloader_support/CMakeLists.txt
Normal file
18
tools/mocks/bootloader_support/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
# NOTE: This kind of mocking currently works on Linux targets only.
|
||||
# On Espressif chips, too many dependencies are missing at the moment.
|
||||
message(STATUS "building BOOTLOADER SUPPORT MOCKS")
|
||||
|
||||
idf_component_get_property(original_bootloader_support_dir bootloader_support COMPONENT_OVERRIDEN_DIR)
|
||||
|
||||
# Note: bootloader_memory_utils.h, bootloader_util.h and esp_app_format.h are not mocked
|
||||
# since they only contain inline functions which we cannot mock without changing the build system.
|
||||
idf_component_mock(INCLUDE_DIRS "${original_bootloader_support_dir}/include"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/bootloader_clock.h"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/bootloader_common.h"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/bootloader_mem.h"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/bootloader_random.h"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/esp_flash_encrypt.h"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/esp_flash_partitions.h"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/esp_image_format.h"
|
||||
MOCK_HEADER_FILES "${original_bootloader_support_dir}/include/esp_secure_boot.h"
|
||||
)
|
12
tools/mocks/bootloader_support/mock/mock_config.yaml
Normal file
12
tools/mocks/bootloader_support/mock/mock_config.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
:cmock:
|
||||
:plugins:
|
||||
- expect
|
||||
- expect_any_args
|
||||
- return_thru_ptr
|
||||
- array
|
||||
- ignore
|
||||
- ignore_arg
|
||||
- callback
|
||||
:strippables:
|
||||
# esp_secure_boot_verify_sbv2_signature_block uses an ets type that is not yet available
|
||||
- ['(?:esp_secure_boot_verify_sbv2_signature_block\s*\(+.*?\)+)']
|
@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
set(COMPONENTS main)
|
||||
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/tools/mocks/bootloader_support)
|
||||
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/tools/mocks/esp_wifi)
|
||||
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/tools/mocks/esp_netif)
|
||||
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/tools/mocks/esp_event)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRCS "mock_build_test.c"
|
||||
INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES driver esp_wifi)
|
||||
PRIV_REQUIRES driver esp_wifi bootloader_support)
|
||||
|
@ -30,6 +30,14 @@
|
||||
#include "Mockrmt_common.h"
|
||||
#include "Mockrmt_tx.h"
|
||||
#include "Mockrmt_rx.h"
|
||||
#include "Mockbootloader_clock.h"
|
||||
#include "Mockbootloader_common.h"
|
||||
#include "Mockbootloader_mem.h"
|
||||
#include "Mockbootloader_random.h"
|
||||
#include "Mockesp_flash_encrypt.h"
|
||||
#include "Mockesp_flash_partitions.h"
|
||||
#include "Mockesp_image_format.h"
|
||||
#include "Mockesp_secure_boot.h"
|
||||
|
||||
/* Test that mock functions exist and that required definitions are available */
|
||||
void app_main(void)
|
||||
@ -102,9 +110,9 @@ void app_main(void)
|
||||
esp_wifi_set_mode_IgnoreAndReturn(ESP_OK);
|
||||
esp_wifi_set_config_IgnoreAndReturn(ESP_OK);
|
||||
esp_wifi_start_IgnoreAndReturn(ESP_OK);
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, NULL) );
|
||||
ESP_ERROR_CHECK(esp_wifi_start() );
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, NULL));
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
|
||||
esp_wifi_connect_IgnoreAndReturn(ESP_OK);
|
||||
esp_wifi_connect();
|
||||
@ -130,5 +138,34 @@ void app_main(void)
|
||||
esp_now_init_IgnoreAndReturn(ESP_OK);
|
||||
ESP_ERROR_CHECK(esp_now_init());
|
||||
|
||||
// Bootloader Support
|
||||
bootloader_clock_configure_Ignore();
|
||||
bootloader_clock_configure();
|
||||
|
||||
bootloader_configure_spi_pins_Ignore();
|
||||
bootloader_configure_spi_pins(0);
|
||||
|
||||
bootloader_init_mem_Ignore();
|
||||
bootloader_init_mem();
|
||||
|
||||
bootloader_random_enable_Ignore();
|
||||
bootloader_random_enable();
|
||||
|
||||
esp_flash_encryption_enabled_IgnoreAndReturn(true);
|
||||
bool flash_encrypted = esp_flash_encryption_enabled();
|
||||
(void)flash_encrypted;
|
||||
|
||||
esp_partition_main_flash_region_safe_IgnoreAndReturn(true);
|
||||
bool region_is_safe = esp_partition_main_flash_region_safe(0, 0);
|
||||
(void) region_is_safe;
|
||||
|
||||
esp_image_verify_bootloader_IgnoreAndReturn(ESP_OK);
|
||||
esp_err_t bootloader_is_ok = esp_image_verify_bootloader(NULL);
|
||||
(void)bootloader_is_ok;
|
||||
|
||||
esp_secure_boot_cfg_verify_release_mode_IgnoreAndReturn(true);
|
||||
bool release_mode_enabled = esp_secure_boot_cfg_verify_release_mode();
|
||||
(void)release_mode_enabled;
|
||||
|
||||
printf("Mock build test done\n");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user