Skip to content

Commit

Permalink
Merge branch 'feature/storage_host_test' into 'master'
Browse files Browse the repository at this point in the history
spiffs: convert host tests from Make to CMake

See merge request espressif/esp-idf!19786
  • Loading branch information
rrtandler committed Sep 12, 2022
2 parents 45d1582 + 723adae commit d6d8324
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 285 deletions.
12 changes: 9 additions & 3 deletions .gitlab/ci/host-test.yml
Expand Up @@ -125,9 +125,7 @@ test_lwip_dhcps_fuzzer_on_host:
test_spiffs_on_host:
extends: .host_test_template
script:
- cd components/spiffs/test_spiffs_host/
- make test
- cd ../test_spiffsgen
- cd components/spiffs/test_spiffsgen/
- ./test_spiffsgen.py

test_fatfsgen_on_host:
Expand Down Expand Up @@ -447,6 +445,14 @@ test_partition_api_host:
- timeout 5 ./build/partition_api_test.elf >test.log
- grep " 0 Failures" test.log

test_spiffs_host:
extends: .host_test_template
script:
- cd ${IDF_PATH}/components/spiffs/host_test
- idf.py build
- timeout 5 ./build/host_test_spiffs.elf >test.log
- grep " 0 Failures" test.log

test_gen_soc_caps_kconfig:
extends: .host_test_template
script:
Expand Down
1 change: 1 addition & 0 deletions components/README.md
@@ -1,3 +1,4 @@

# Core Components

## Overview
Expand Down
4 changes: 4 additions & 0 deletions components/spiffs/.build-test-rules.yml
@@ -0,0 +1,4 @@
components/spiffs/host_test:
enable:
- if: IDF_TARGET == "linux"
reason: only test on linux
30 changes: 19 additions & 11 deletions components/spiffs/CMakeLists.txt
@@ -1,14 +1,22 @@
idf_component_register(SRCS "esp_spiffs.c"
"spiffs_api.c"
"spiffs/src/spiffs_cache.c"
"spiffs/src/spiffs_check.c"
"spiffs/src/spiffs_gc.c"
"spiffs/src/spiffs_hydrogen.c"
"spiffs/src/spiffs_nucleus.c"
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "." "spiffs/src"
REQUIRES spi_flash
PRIV_REQUIRES bootloader_support esptool_py vfs)
idf_build_get_property(target IDF_TARGET)

list(APPEND srcs "spiffs_api.c"
"spiffs/src/spiffs_cache.c"
"spiffs/src/spiffs_check.c"
"spiffs/src/spiffs_gc.c"
"spiffs/src/spiffs_hydrogen.c"
"spiffs/src/spiffs_nucleus.c")

if(NOT ${target} STREQUAL "linux")
list(APPEND pr bootloader_support esptool_py vfs)
list(APPEND srcs "esp_spiffs.c")
endif()

idf_component_register(SRCS ${srcs}
INCLUDE_DIRS "include"
PRIV_INCLUDE_DIRS "." "spiffs/src"
REQUIRES spi_flash
PRIV_REQUIRES ${pr})

if(CMAKE_C_COMPILER_ID MATCHES "GNU")
set_source_files_properties(spiffs/src/spiffs_nucleus.c PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation)
Expand Down
3 changes: 3 additions & 0 deletions components/spiffs/esp_spiffs.c
Expand Up @@ -37,6 +37,9 @@ _Static_assert(CONFIG_SPIFFS_META_LENGTH >= sizeof(spiffs_time_t),
"SPIFFS_META_LENGTH size should be >= sizeof(spiffs_time_t)");
#endif //CONFIG_SPIFFS_USE_MTIME

_Static_assert(ESP_SPIFFS_PATH_MAX == ESP_VFS_PATH_MAX,
"SPIFFS max path length has to be aligned with the VFS max path length");

/**
* @brief SPIFFS DIR structure
*/
Expand Down
25 changes: 25 additions & 0 deletions components/spiffs/host_test/CMakeLists.txt
@@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 3.16)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main)
# Freertos is included via common components, however, currently only the mock component is compatible with linux
# target.
list(APPEND EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/mocks/freertos/")

project(host_test_spiffs)

# Custom procedure to build/clean image.bin
add_custom_target(image.bin)

# Expand image.bin to the same size as "spiffs" partition in partition_table.csv - 2*1024*1024 = 2097152 = 2M
add_custom_command(
TARGET image.bin
POST_BUILD
COMMAND python ../../spiffsgen.py 2097152 ../../spiffs ../image.bin
)

set_property(
DIRECTORY
APPEND PROPERTY ADDITIONAL_CLEAN_FILES "../image.bin")

add_dependencies(host_test_spiffs.elf partition-table image.bin)
17 changes: 17 additions & 0 deletions components/spiffs/host_test/README.md
@@ -0,0 +1,17 @@
| Supported Targets | Linux |
| ----------------- | ----- |

This is a test project for spiffs-related APIs on Linux target (CONFIG_IDF_TARGET_LINUX).

# Build
Source the IDF environment as usual.

Once this is done, build the application:
```bash
idf.py build
```

# Run
```bash
build/host_test_spiffs.elf
```
3 changes: 3 additions & 0 deletions components/spiffs/host_test/main/CMakeLists.txt
@@ -0,0 +1,3 @@
idf_component_register(SRCS "host_test_spiffs.c"
PRIV_INCLUDE_DIRS "../.." "../../spiffs/src"
REQUIRES spiffs unity)

0 comments on commit d6d8324

Please sign in to comment.