فهرست منبع

Merge branch 'feature/storage_host_test' into 'master'

spiffs: convert host tests from Make to CMake

See merge request espressif/esp-idf!19786
Radek Tandler 3 سال پیش
والد
کامیت
d6d8324ad9

+ 9 - 3
.gitlab/ci/host-test.yml

@@ -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:
@@ -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:

+ 1 - 0
components/README.md

@@ -1,3 +1,4 @@
+
 # Core Components
 
 ## Overview

+ 4 - 0
components/spiffs/.build-test-rules.yml

@@ -0,0 +1,4 @@
+components/spiffs/host_test:
+  enable:
+    - if: IDF_TARGET == "linux"
+      reason: only test on linux

+ 19 - 11
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)

+ 3 - 0
components/spiffs/esp_spiffs.c

@@ -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
  */

+ 25 - 0
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 - 0
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 - 0
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)

+ 83 - 53
components/spiffs/test_spiffs_host/test_spiffs.cpp → components/spiffs/host_test/main/host_test_spiffs.c

@@ -14,47 +14,64 @@
 #include <limits.h>
 #include <unistd.h>
 
+#include "Mockqueue.h"
+
 #include "esp_partition.h"
 #include "spiffs.h"
 #include "spiffs_nucleus.h"
 #include "spiffs_api.h"
 
-#include "catch.hpp"
+#include "unity.h"
+#include "unity_fixture.h"
+
+TEST_GROUP(spiffs);
+
+TEST_SETUP(spiffs)
+{
+    // CMock init for spiffs xSemaphore* use
+    xQueueSemaphoreTake_IgnoreAndReturn(0);
+    xQueueGenericSend_IgnoreAndReturn(0);
+}
 
-extern "C" void _spi_flash_init(const char* chip_size, size_t block_size, size_t sector_size, size_t page_size, const char* partition_bin);
+TEST_TEAR_DOWN(spiffs)
+{
+}
 
 static void init_spiffs(spiffs *fs, uint32_t max_files)
 {
-    spiffs_config cfg;
+    spiffs_config cfg = {};
     s32_t spiffs_res;
+    u32_t flash_sector_size;
 
     const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, "storage");
-    REQUIRE(partition);
+    TEST_ASSERT_NOT_NULL(partition);
 
     // Configure objects needed by SPIFFS
-    esp_spiffs_t *user_data = (esp_spiffs_t*) calloc(1, sizeof(*user_data));
+    esp_spiffs_t *user_data = (esp_spiffs_t *) calloc(1, sizeof(*user_data));
     user_data->partition = partition;
-    fs->user_data = (void*)user_data;
+    fs->user_data = (void *)user_data;
+
+    flash_sector_size = 4096;
 
     cfg.hal_erase_f = spiffs_api_erase;
     cfg.hal_read_f = spiffs_api_read;
     cfg.hal_write_f = spiffs_api_write;
-    cfg.log_block_size = CONFIG_WL_SECTOR_SIZE;
+    cfg.log_block_size = flash_sector_size;
     cfg.log_page_size = CONFIG_SPIFFS_PAGE_SIZE;
     cfg.phys_addr = 0;
-    cfg.phys_erase_block = CONFIG_WL_SECTOR_SIZE;
+    cfg.phys_erase_block = flash_sector_size;
     cfg.phys_size = partition->size;
 
     uint32_t work_sz = cfg.log_page_size * 2;
-    uint8_t *work = (uint8_t*) malloc(work_sz);
+    uint8_t *work = (uint8_t *) malloc(work_sz);
 
     uint32_t fds_sz = max_files * sizeof(spiffs_fd);
-    uint8_t *fds = (uint8_t*) malloc(fds_sz);
+    uint8_t *fds = (uint8_t *) malloc(fds_sz);
 
 #if CONFIG_SPIFFS_CACHE
     uint32_t cache_sz = sizeof(spiffs_cache) + max_files * (sizeof(spiffs_cache_page)
-                          + cfg.log_page_size);
-    uint8_t *cache = (uint8_t*) malloc(cache_sz);
+                        + cfg.log_page_size);
+    uint8_t *cache = (uint8_t *) malloc(cache_sz);
 #else
     uint32_t cache_sz = 0;
     uint8_t cache = NULL;
@@ -63,17 +80,17 @@ static void init_spiffs(spiffs *fs, uint32_t max_files)
     // Special mounting procedure: mount, format, mount as per
     // https://github.com/pellepl/spiffs/wiki/Using-spiffs
     spiffs_res = SPIFFS_mount(fs, &cfg, work, fds, fds_sz,
-                            cache, cache_sz, spiffs_api_check);
+                              cache, cache_sz, spiffs_api_check);
 
     if (spiffs_res == SPIFFS_ERR_NOT_A_FS) {
         spiffs_res = SPIFFS_format(fs);
-        REQUIRE(spiffs_res >= SPIFFS_OK);
+        TEST_ASSERT_TRUE(spiffs_res >= SPIFFS_OK);
 
         spiffs_res = SPIFFS_mount(fs, &cfg, work, fds, fds_sz,
-                                cache, cache_sz, spiffs_api_check);
+                                  cache, cache_sz, spiffs_api_check);
     }
 
-    REQUIRE(spiffs_res >= SPIFFS_OK);
+    TEST_ASSERT_TRUE(spiffs_res >= SPIFFS_OK);
 }
 
 static void deinit_spiffs(spiffs *fs)
@@ -89,7 +106,7 @@ static void deinit_spiffs(spiffs *fs)
 #endif
 }
 
-static void check_spiffs_files(spiffs *fs, const char *base_path, char* cur_path)
+static void check_spiffs_files(spiffs *fs, const char *base_path, char *cur_path)
 {
     DIR *dir;
     struct dirent *entry;
@@ -101,7 +118,7 @@ static void check_spiffs_files(spiffs *fs, const char *base_path, char* cur_path
     }
 
     dir = opendir(cur_path);
-    REQUIRE(dir != 0);
+    TEST_ASSERT_TRUE(dir != 0);
 
     while ((entry = readdir(dir)) != NULL) {
         char *name = entry->d_name;
@@ -117,20 +134,21 @@ static void check_spiffs_files(spiffs *fs, const char *base_path, char* cur_path
         stat(path, &sb);
 
         if (S_ISDIR(sb.st_mode)) {
-            if (!strcmp(name, ".") || !strcmp(name, ".."))
+            if (!strcmp(name, ".") || !strcmp(name, "..")) {
                 continue;
+            }
             cur_path[len] = '/';
             strcpy(cur_path + len + 1, name);
             check_spiffs_files(fs, base_path, cur_path);
             cur_path[len] = '\0';
         } else {
-            FILE* f = fopen(path , "r");
-            REQUIRE(f);
+            FILE *f = fopen(path, "r");
+            TEST_ASSERT_NOT_NULL(f);
             fseek(f, 0, SEEK_END);
             long sz = ftell(f);
             fseek(f, 0, SEEK_SET);
 
-            char *f_contents = (char*) malloc(sz);
+            char *f_contents = (char *) malloc(sz);
             fread(f_contents, 1, sz, f);
             fclose(f);
 
@@ -140,22 +158,22 @@ static void check_spiffs_files(spiffs *fs, const char *base_path, char* cur_path
             char *spiffs_path = path + strlen(base_path);
             spiffs_res = SPIFFS_open(fs, spiffs_path, SPIFFS_RDONLY, 0);
 
-            REQUIRE(spiffs_res > SPIFFS_OK);
+            TEST_ASSERT_TRUE(spiffs_res > SPIFFS_OK);
 
             spiffs_file fd = spiffs_res;
 
             spiffs_stat stat;
             spiffs_res = SPIFFS_stat(fs, spiffs_path, &stat);
 
-            char *spiffs_f_contents = (char*) malloc(stat.size);
+            char *spiffs_f_contents = (char *) malloc(stat.size);
             spiffs_res = SPIFFS_read(fs, fd, spiffs_f_contents, stat.size);
-            REQUIRE(spiffs_res == stat.size);
+            TEST_ASSERT_TRUE(spiffs_res == stat.size);
 
             // Compare the contents
-            REQUIRE(sz == stat.size);
+            TEST_ASSERT_TRUE(sz == stat.size);
 
             bool same = memcmp(f_contents, spiffs_f_contents, sz) == 0;
-            REQUIRE(same);
+            TEST_ASSERT_TRUE(same);
 
             free(f_contents);
             free(spiffs_f_contents);
@@ -164,10 +182,8 @@ static void check_spiffs_files(spiffs *fs, const char *base_path, char* cur_path
     closedir(dir);
 }
 
-TEST_CASE("format disk, open file, write and read file", "[spiffs]")
+TEST(spiffs, format_disk_open_file_write_and_read_file)
 {
-    _spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin");
-
     spiffs fs;
     s32_t spiffs_res;
 
@@ -175,40 +191,39 @@ TEST_CASE("format disk, open file, write and read file", "[spiffs]")
 
     // Open test file
     spiffs_res = SPIFFS_open(&fs, "test.txt", SPIFFS_O_CREAT | SPIFFS_O_RDWR, 0);
-    REQUIRE(spiffs_res >= SPIFFS_OK);
+    TEST_ASSERT_TRUE(spiffs_res >= SPIFFS_OK);
 
     // Generate data
     spiffs_file file = spiffs_res;
 
     uint32_t data_size = 100000;
 
-    char *data = (char*) malloc(data_size);
-    char *read = (char*) malloc(data_size);
+    char *data = (char *) malloc(data_size);
+    char *read = (char *) malloc(data_size);
 
-    for(uint32_t i = 0; i < data_size; i += sizeof(i))
-    {
-        *((uint32_t*)(data + i)) = i;
+    for (uint32_t i = 0; i < data_size; i += sizeof(i)) {
+        *((uint32_t *)(data + i)) = i;
     }
 
     // Write data to file
-    spiffs_res = SPIFFS_write(&fs, file, (void*)data, data_size);
-    REQUIRE(spiffs_res >= SPIFFS_OK);
-    REQUIRE(spiffs_res == data_size);
+    spiffs_res = SPIFFS_write(&fs, file, (void *)data, data_size);
+    TEST_ASSERT_TRUE(spiffs_res >= SPIFFS_OK);
+    TEST_ASSERT_TRUE(spiffs_res == data_size);
 
     // Set the file object pointer to the beginning
     spiffs_res = SPIFFS_lseek(&fs, file, 0, SPIFFS_SEEK_SET);
-    REQUIRE(spiffs_res >= SPIFFS_OK);
+    TEST_ASSERT_TRUE(spiffs_res >= SPIFFS_OK);
 
     // Read the file
-    spiffs_res = SPIFFS_read(&fs, file, (void*)read, data_size);
-    REQUIRE(spiffs_res >= SPIFFS_OK);
-    REQUIRE(spiffs_res == data_size);
+    spiffs_res = SPIFFS_read(&fs, file, (void *)read, data_size);
+    TEST_ASSERT_TRUE(spiffs_res >= SPIFFS_OK);
+    TEST_ASSERT_TRUE(spiffs_res == data_size);
 
     // Close the test file
     spiffs_res = SPIFFS_close(&fs, file);
-    REQUIRE(spiffs_res >= SPIFFS_OK);
+    TEST_ASSERT_TRUE(spiffs_res >= SPIFFS_OK);
 
-    REQUIRE(memcmp(data, read, data_size) == 0);
+    TEST_ASSERT_TRUE(memcmp(data, read, data_size) == 0);
 
     deinit_spiffs(&fs);
 
@@ -216,28 +231,26 @@ TEST_CASE("format disk, open file, write and read file", "[spiffs]")
     free(data);
 }
 
-TEST_CASE("can read spiffs image", "[spiffs]")
+TEST(spiffs, can_read_spiffs_image)
 {
-    _spi_flash_init(CONFIG_ESPTOOLPY_FLASHSIZE, CONFIG_WL_SECTOR_SIZE * 16, CONFIG_WL_SECTOR_SIZE, CONFIG_WL_SECTOR_SIZE, "partition_table.bin");
-
     spiffs fs;
     s32_t spiffs_res;
 
     const esp_partition_t *partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_SPIFFS, "storage");
 
     // Write the contents of the image file to partition
-    FILE* img_file = fopen("image.bin", "r");
-    REQUIRE(img_file);
+    FILE *img_file = fopen("image.bin", "r");
+    TEST_ASSERT_NOT_NULL(img_file);
 
     fseek(img_file, 0, SEEK_END);
     long img_size = ftell(img_file);
     fseek(img_file, 0, SEEK_SET);
 
-    char *img = (char*) malloc(img_size);
+    char *img = (char *) malloc(img_size);
     fread(img, 1, img_size, img_file);
     fclose(img_file);
 
-    REQUIRE(partition->size == img_size);
+    TEST_ASSERT_TRUE(partition->size == img_size);
 
     esp_partition_erase_range(partition, 0, partition->size);
     esp_partition_write(partition, 0, img, img_size);
@@ -250,7 +263,7 @@ TEST_CASE("can read spiffs image", "[spiffs]")
 
     // Check spiffs consistency
     spiffs_res = SPIFFS_check(&fs);
-    REQUIRE(spiffs_res == SPIFFS_OK);
+    TEST_ASSERT_TRUE(spiffs_res == SPIFFS_OK);
 
     char path_buf[PATH_MAX];
 
@@ -260,3 +273,20 @@ TEST_CASE("can read spiffs image", "[spiffs]")
 
     deinit_spiffs(&fs);
 }
+
+TEST_GROUP_RUNNER(spiffs)
+{
+    RUN_TEST_CASE(spiffs, format_disk_open_file_write_and_read_file);
+    RUN_TEST_CASE(spiffs, can_read_spiffs_image);
+}
+
+static void run_all_tests(void)
+{
+    RUN_TEST_GROUP(spiffs);
+}
+
+int main(int argc, char **argv)
+{
+    UNITY_MAIN_FUNC(run_all_tests);
+    return 0;
+}

+ 0 - 0
components/spiffs/test_spiffs_host/partition_table.csv → components/spiffs/host_test/partition_table.csv


+ 8 - 0
components/spiffs/host_test/sdkconfig.defaults

@@ -0,0 +1,8 @@
+CONFIG_IDF_TARGET="linux"
+CONFIG_COMPILER_CXX_EXCEPTIONS=y
+CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=n
+CONFIG_UNITY_ENABLE_FIXTURE=y
+CONFIG_PARTITION_TABLE_CUSTOM=y
+CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partition_table.csv"
+CONFIG_ESPTOOLPY_FLASHSIZE="4MB"
+CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y

+ 0 - 1
components/spiffs/spiffs_api.c

@@ -8,7 +8,6 @@
 #include "esp_log.h"
 #include "esp_partition.h"
 #include "esp_spiffs.h"
-#include "esp_vfs.h"
 #include "spiffs_api.h"
 
 static const char* TAG = "SPIFFS";

+ 3 - 2
components/spiffs/spiffs_api.h

@@ -12,13 +12,14 @@
 #include "freertos/task.h"
 #include "freertos/semphr.h"
 #include "spiffs.h"
-#include "esp_vfs.h"
 #include "esp_compiler.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
+#define ESP_SPIFFS_PATH_MAX 15
+
 /**
  * @brief SPIFFS definition structure
  */
@@ -26,7 +27,7 @@ typedef struct {
     spiffs *fs;                             /*!< Handle to the underlying SPIFFS */
     SemaphoreHandle_t lock;                 /*!< FS lock */
     const esp_partition_t* partition;       /*!< The partition on which SPIFFS is located */
-    char base_path[ESP_VFS_PATH_MAX+1];     /*!< Mount point */
+    char base_path[ESP_SPIFFS_PATH_MAX+1];  /*!< Mount point */
     bool by_label;                          /*!< Partition was mounted by label */
     spiffs_config cfg;                      /*!< SPIFFS Mount configuration */
     uint8_t *work;                          /*!< Work Buffer */

+ 0 - 105
components/spiffs/test_spiffs_host/Makefile

@@ -1,105 +0,0 @@
-ifndef COMPONENT
-COMPONENT := spiffs
-endif
-
-COMPONENT_LIB := lib$(COMPONENT).a
-TEST_PROGRAM := test_$(COMPONENT)
-
-STUBS_LIB_DIR := ../../../components/spi_flash/sim/stubs
-STUBS_LIB_BUILD_DIR := $(STUBS_LIB_DIR)/build
-STUBS_LIB := libstubs.a
-
-SPI_FLASH_SIM_DIR := ../../../components/spi_flash/sim
-SPI_FLASH_SIM_BUILD_DIR := $(SPI_FLASH_SIM_DIR)/build
-SPI_FLASH_SIM_LIB := libspi_flash.a
-
-include Makefile.files
-
-all: test
-
-ifndef SDKCONFIG
-SDKCONFIG_DIR := $(dir $(realpath sdkconfig/sdkconfig.h))
-SDKCONFIG := $(SDKCONFIG_DIR)sdkconfig.h
-else
-SDKCONFIG_DIR := $(dir $(realpath $(SDKCONFIG)))
-endif
-
-INCLUDE_FLAGS := $(addprefix -I, $(INCLUDE_DIRS) $(SDKCONFIG_DIR) ../../../tools/catch)
-
-CPPFLAGS += $(INCLUDE_FLAGS) -g -m32
-CXXFLAGS += $(INCLUDE_FLAGS) -std=c++11 -g -m32
-
-# Build libraries that this component is dependent on
-$(STUBS_LIB_BUILD_DIR)/$(STUBS_LIB): force
-	$(MAKE) -C $(STUBS_LIB_DIR) lib SDKCONFIG=$(SDKCONFIG)
-
-$(SPI_FLASH_SIM_BUILD_DIR)/$(SPI_FLASH_SIM_LIB): force
-	$(MAKE) -C $(SPI_FLASH_SIM_DIR) lib SDKCONFIG=$(SDKCONFIG)
-
-# Create target for building this component as a library
-CFILES := $(filter %.c, $(SOURCE_FILES))
-CPPFILES := $(filter %.cpp, $(SOURCE_FILES))
-
-CTARGET = ${2}/$(patsubst %.c,%.o,$(notdir ${1}))
-CPPTARGET = ${2}/$(patsubst %.cpp,%.o,$(notdir ${1}))
-
-ifndef BUILD_DIR
-BUILD_DIR := build
-endif
-
-OBJ_FILES := $(addprefix $(BUILD_DIR)/, $(filter %.o, $(notdir $(SOURCE_FILES:.cpp=.o) $(SOURCE_FILES:.c=.o))))
-
-define COMPILE_C
-$(call CTARGET, ${1}, $(BUILD_DIR)) : ${1} $(SDKCONFIG)
-	mkdir -p $(BUILD_DIR)
-	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $(call CTARGET, ${1}, $(BUILD_DIR)) ${1}
-endef
-
-define COMPILE_CPP
-$(call CPPTARGET, ${1}, $(BUILD_DIR)) : ${1} $(SDKCONFIG)
-	mkdir -p $(BUILD_DIR)
-	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $(call CPPTARGET, ${1}, $(BUILD_DIR)) ${1}
-endef
-
-$(BUILD_DIR)/$(COMPONENT_LIB): $(OBJ_FILES) $(SDKCONFIG)
-	mkdir -p $(BUILD_DIR)
-	$(AR) rcs $@ $^
-
-clean:
-	$(MAKE) -C $(STUBS_LIB_DIR) clean
-	$(MAKE) -C $(SPI_FLASH_SIM_DIR) clean
-	rm -f $(OBJ_FILES) $(TEST_OBJ_FILES) $(TEST_PROGRAM) $(COMPONENT_LIB) partition_table.bin image.bin
-
-lib: $(BUILD_DIR)/$(COMPONENT_LIB)
-
-$(foreach cfile, $(CFILES), $(eval $(call COMPILE_C, $(cfile))))
-$(foreach cxxfile, $(CPPFILES), $(eval $(call COMPILE_CPP, $(cxxfile))))
-
-# Create target for building this component as a test
-TEST_SOURCE_FILES = \
-	test_spiffs.cpp \
-	main.cpp \
-
-TEST_OBJ_FILES = $(filter %.o, $(TEST_SOURCE_FILES:.cpp=.o) $(TEST_SOURCE_FILES:.c=.o))
-
-$(TEST_PROGRAM): lib $(TEST_OBJ_FILES) $(SPI_FLASH_SIM_BUILD_DIR)/$(SPI_FLASH_SIM_LIB) $(STUBS_LIB_BUILD_DIR)/$(STUBS_LIB) partition_table.bin $(SDKCONFIG)
-	g++ $(LDFLAGS) $(CXXFLAGS) -o $@  $(TEST_OBJ_FILES) -L$(BUILD_DIR) -l:$(COMPONENT_LIB) -L$(SPI_FLASH_SIM_BUILD_DIR) -l:$(SPI_FLASH_SIM_LIB) -L$(STUBS_LIB_BUILD_DIR) -l:$(STUBS_LIB)
-
-# Use spiffs source directory as the test image
-spiffs_image: ../spiffs $(shell find ../spiffs -type d) $(shell find ../spiffs -type -f -name '*')
-	# Creation of test symlinks unfortunately causes rerun of spiffsgen.py every make invoke
-	rm -f ../spiffs/include ../spiffs/CMakeLists.txt
-	ln -s ../include ../spiffs/include
-	ln -s ../CMakeLists.txt ../spiffs/CMakeLists.txt
-	../spiffsgen.py --follow-symlinks 2097152 ../spiffs image.bin
-
-test: $(TEST_PROGRAM) spiffs_image
-	./$(TEST_PROGRAM)
-
-# Create other necessary targets
-partition_table.bin: partition_table.csv
-	python ../../../components/partition_table/gen_esp32part.py --verify $< $@
-
-force:
-
-.PHONY: all lib test clean force

+ 0 - 43
components/spiffs/test_spiffs_host/Makefile.files

@@ -1,43 +0,0 @@
-SOURCE_FILES := \
-	../spiffs_api.c \
-	$(addprefix ../spiffs/src/, \
-	spiffs_cache.c \
-	spiffs_check.c \
-	spiffs_gc.c \
-	spiffs_hydrogen.c \
-	spiffs_nucleus.c \
-	)
-
-INCLUDE_DIRS := \
-	. \
-	.. \
-	../spiffs/src \
-	../include \
-	$(addprefix ../../spi_flash/sim/stubs/, \
-	app_update/include \
-	driver/include \
-	freertos/include \
-	newlib/include \
-	sdmmc/include \
-	vfs/include \
-	) \
-	$(addprefix ../../../components/, \
-	esp_rom/include \
-	esp_common/include \
-	esp_hw_support/include \
-	esp_hw_support/include/soc \
-	esp_system/include \
-	log/include \
-	xtensa/include \
-	xtensa/esp32/include \
-	soc/esp32/include \
-      	heap/include \
-	soc/include \
-	esp32/include \
-	bootloader_support/include \
-	bootloader_support/bootloader_flash/include \
-	app_update/include \
-	spi_flash/include \
-	hal/include \
-	wear_levelling/include \
-	)

+ 0 - 17
components/spiffs/test_spiffs_host/component.mk

@@ -1,17 +0,0 @@
-include $(COMPONENT_PATH)/Makefile.files
-
-COMPONENT_OWNBUILDTARGET := 1
-COMPONENT_OWNCLEANTARGET := 1
-
-COMPONENT_ADD_INCLUDEDIRS := $(INCLUDE_DIRS)
-
-.PHONY: build
-build: $(SDKCONFIG_HEADER)
-	$(MAKE) -C $(COMPONENT_PATH) lib SDKCONFIG=$(SDKCONFIG_HEADER) BUILD_DIR=$(COMPONENT_BUILD_DIR) COMPONENT=$(COMPONENT_NAME)
-
-CLEAN_FILES := component_project_vars.mk
-.PHONY: clean
-clean:
-	$(summary) RM $(CLEAN_FILES)
-	rm -f $(CLEAN_FILES)
-	$(MAKE) -C $(COMPONENT_PATH) clean SDKCONFIG=$(SDKCONFIG_HEADER) BUILD_DIR=$(COMPONENT_BUILD_DIR) COMPONENT=$(COMPONENT_NAME)

+ 0 - 7
components/spiffs/test_spiffs_host/main.cpp

@@ -1,7 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-#define CATCH_CONFIG_MAIN
-#include "catch.hpp"

+ 0 - 35
components/spiffs/test_spiffs_host/sdkconfig/sdkconfig.h

@@ -1,35 +0,0 @@
-/*
- * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
- *
- * SPDX-License-Identifier: Apache-2.0
- */
-#pragma once
-#define CONFIG_IDF_TARGET_ESP32 1
-#define CONFIG_SPIFFS_USE_MAGIC_LENGTH 1
-#define CONFIG_SPIFFS_MAX_PARTITIONS 3
-#define CONFIG_SPIFFS_OBJ_NAME_LEN 32
-#define CONFIG_SPIFFS_PAGE_SIZE 256
-#define CONFIG_SPIFFS_GC_MAX_RUNS 10
-#define CONFIG_SPIFFS_CACHE_WR 1
-#define CONFIG_SPIFFS_CACHE 1
-#define CONFIG_SPIFFS_META_LENGTH 4
-#define CONFIG_SPIFFS_USE_MAGIC 1
-#define CONFIG_SPIFFS_PAGE_CHECK 1
-#define CONFIG_SPIFFS_USE_MTIME 1
-
-#define CONFIG_WL_SECTOR_SIZE 4096
-
-// for log component with linux target
-#define CONFIG_LOG_DEFAULT_LEVEL 3
-#define CONFIG_LOG_MAXIMUM_LEVEL 3
-#define CONFIG_LOG_TIMESTAMP_SOURCE_RTOS 1
-
-#define CONFIG_PARTITION_TABLE_OFFSET 0x8000
-
-#define CONFIG_ESPTOOLPY_FLASHSIZE "8MB"
-//currently use the legacy implementation, since the stubs for new HAL are not done yet
-#define CONFIG_SPI_FLASH_USE_LEGACY_IMPL 1
-#define CONFIG_MMU_PAGE_SIZE 0X10000 // 64KB
-
-#undef _Static_assert
-#define _Static_assert(cond, message)

+ 13 - 8
components/vfs/CMakeLists.txt

@@ -1,11 +1,16 @@
-idf_component_register(SRCS "vfs.c"
-                            "vfs_eventfd.c"
-                            "vfs_uart.c"
-                            "vfs_semihost.c"
-                            "vfs_console.c"
-                    INCLUDE_DIRS include
-                    PRIV_INCLUDE_DIRS private_include
-                    PRIV_REQUIRES driver esp_timer)
+list(APPEND sources "vfs.c"
+                    "vfs_eventfd.c"
+                    "vfs_uart.c"
+                    "vfs_semihost.c"
+                    "vfs_console.c")
+
+list(APPEND pr driver
+               esp_timer)
+
+idf_component_register(SRCS ${sources}
+                       INCLUDE_DIRS include
+                       PRIV_INCLUDE_DIRS private_include
+                       PRIV_REQUIRES ${pr})
 
 if(CONFIG_ESP_CONSOLE_USB_CDC)
     target_sources(${COMPONENT_LIB} PRIVATE "vfs_cdcacm.c")