-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/storage_host_test_nvs' into 'master'
nvs_flash: Migrate host tests to CMake build system, use Linux partition API Closes IDF-4697 See merge request espressif/esp-idf!20671
- Loading branch information
Showing
28 changed files
with
2,999 additions
and
2,777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
components/nvs_flash/host_test/nvs_host_test/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
set(COMPONENTS main) | ||
# Freertos is included via common components. However, CATCH isn't compatible with the FreeRTOS component yet, hence | ||
# using the FreeRTOS mock component. | ||
# target. | ||
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/") | ||
|
||
project(nvs_host_test) | ||
|
||
add_dependencies(nvs_host_test.elf partition-table) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
| Supported Targets | Linux | | ||
| ----------------- | ----- | |
14 changes: 14 additions & 0 deletions
14
components/nvs_flash/host_test/nvs_host_test/main/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
idf_component_register(SRCS "main.cpp" | ||
"test_nvs.cpp" | ||
"test_partition_manager.cpp" | ||
"test_nvs_cxx_api.cpp" | ||
"test_nvs_handle.cpp" | ||
"test_nvs_initialization.cpp" | ||
"test_nvs_storage.cpp" | ||
INCLUDE_DIRS | ||
"../../../src" | ||
"../../../private_include" | ||
"../../../../mbedtls/mbedtls/include" | ||
"../../../../../tools/catch" | ||
WHOLE_ARCHIVE | ||
REQUIRES nvs_flash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#define CATCH_CONFIG_MAIN | ||
#include "catch.hpp" |
43 changes: 43 additions & 0 deletions
43
components/nvs_flash/host_test/nvs_host_test/main/test_fixtures.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
#include "nvs_partition.hpp" | ||
#include "esp_private/partition_linux.h" | ||
#include "nvs.h" | ||
|
||
class PartitionEmulationFixture { | ||
public: | ||
PartitionEmulationFixture( uint32_t start_sector = 0, | ||
uint32_t sector_size = 1, | ||
const char *partition_name = NVS_DEFAULT_PART_NAME) : | ||
esp_partition() | ||
{ | ||
|
||
if (esp_partition_file_mmap((const uint8_t **) &p_part_desc_addr_start) != ESP_OK) { | ||
throw ("Failed to initialize esp_partition_file_mmap"); | ||
} | ||
|
||
esp_partition.address = start_sector * SPI_FLASH_SEC_SIZE; | ||
esp_partition.size = sector_size * SPI_FLASH_SEC_SIZE; | ||
esp_partition.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE; | ||
strncpy(esp_partition.label, partition_name, PART_NAME_MAX_SIZE); | ||
p_part = new nvs::NVSPartition(&esp_partition); | ||
} | ||
|
||
~PartitionEmulationFixture() | ||
{ | ||
delete p_part; | ||
esp_partition_file_munmap(); | ||
} | ||
|
||
nvs::NVSPartition *part() | ||
{ | ||
return p_part; | ||
} | ||
|
||
nvs::NVSPartition *p_part; | ||
esp_partition_t esp_partition; | ||
uint8_t *p_part_desc_addr_start; | ||
}; |
Oops, something went wrong.