VFS: move tests from unit-test-app to a component test app

This commit is contained in:
Sonika Rathi 2023-04-06 20:32:23 +05:30
parent e2a5c092f7
commit d83c681078
47 changed files with 154 additions and 58 deletions

View File

@ -1,3 +0,0 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS .
PRIV_REQUIRES cmock test_utils vfs fatfs spiffs)

View File

@ -0,0 +1,12 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
list(APPEND SDKCONFIG_DEFAULTS "$ENV{IDF_PATH}/tools/test_apps/configs/sdkconfig.debug_helpers")
list(APPEND SDKCONFIG_DEFAULTS "sdkconfig.defaults")
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(vfs_test)

View File

@ -0,0 +1,3 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |

View File

@ -0,0 +1,12 @@
set(src "test_app_main.c" "test_vfs_access.c"
"test_vfs_append.c" "test_vfs_eventfd.c"
"test_vfs_fd.c" "test_vfs_lwip.c"
"test_vfs_open.c" "test_vfs_paths.c"
"test_vfs_select.c" "test_vfs_uart.c"
)
idf_component_register(SRCS ${src}
PRIV_INCLUDE_DIRS .
PRIV_REQUIRES test_utils vfs fatfs spiffs unity lwip wear_levelling cmock
WHOLE_ARCHIVE
)

View File

@ -0,0 +1,34 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
#include "unity.h"
#include "unity_test_utils.h"
#include "esp_heap_caps.h"
// Some resources are lazy allocated, the threadhold is left for that case
#define TEST_MEMORY_LEAK_THRESHOLD (-100)
static size_t before_free_8bit;
static size_t before_free_32bit;
void setUp(void)
{
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
}
void tearDown(void)
{
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
unity_utils_check_leak(before_free_8bit, after_free_8bit, "8BIT", TEST_MEMORY_LEAK_THRESHOLD);
unity_utils_check_leak(before_free_32bit, after_free_32bit, "32BIT", TEST_MEMORY_LEAK_THRESHOLD);
}
void app_main(void)
{
unity_run_menu();
}

View File

@ -14,7 +14,7 @@
#include "esp_vfs_dev.h" #include "esp_vfs_dev.h"
#include "esp_vfs_fat.h" #include "esp_vfs_fat.h"
#include "wear_levelling.h" #include "wear_levelling.h"
#include "test_utils.h" #include "sdkconfig.h"
static wl_handle_t test_wl_handle; static wl_handle_t test_wl_handle;

View File

@ -13,7 +13,6 @@
#include "esp_vfs_fat.h" #include "esp_vfs_fat.h"
#include "esp_spiffs.h" #include "esp_spiffs.h"
#include "wear_levelling.h" #include "wear_levelling.h"
#include "test_utils.h"
#define TEST_PARTITION_LABEL "flash_test" #define TEST_PARTITION_LABEL "flash_test"

View File

@ -1,16 +1,8 @@
// Copyright 2021 Espressif Systems (Shanghai) CO LTD /*
// * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// 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 <unistd.h> #include <unistd.h>
#include <sys/fcntl.h> #include <sys/fcntl.h>

View File

@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@ -1,16 +1,8 @@
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD /*
// * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
// Licensed under the Apache License, Version 2.0 (the "License"); *
// you may not use this file except in compliance with the License. * SPDX-License-Identifier: Apache-2.0
// 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 <stdbool.h> #include <stdbool.h>
#include <stdio.h> #include <stdio.h>

View File

@ -0,0 +1,5 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, 0x9000, 0x6000,
factory, 0, 0, 0x10000, 1M
flash_test, data, fat, , 528K
1 # Name, Type, SubType, Offset, Size, Flags
2 # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
3 nvs, data, nvs, 0x9000, 0x6000,
4 factory, 0, 0, 0x10000, 1M
5 flash_test, data, fat, , 528K

View File

@ -0,0 +1,36 @@
# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
@pytest.mark.esp32c2
@pytest.mark.esp32c3
@pytest.mark.esp32c6
@pytest.mark.esp32h2
@pytest.mark.generic
@pytest.mark.parametrize('config', [
'default',
], indirect=True)
def test_vfs_default(dut: Dut) -> None:
dut.run_all_single_board_cases()
@pytest.mark.esp32
@pytest.mark.esp32s2
@pytest.mark.generic
@pytest.mark.parametrize('config', [
'ccomp',
], indirect=True)
def test_vfs_ccomp(dut: Dut) -> None:
dut.run_all_single_board_cases()
@pytest.mark.esp32s3
@pytest.mark.quad_psram
@pytest.mark.parametrize('config', [
'psram',
], indirect=True)
def test_vfs_psram(dut: Dut) -> None:
dut.run_all_single_board_cases()

View File

@ -0,0 +1 @@
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y

View File

@ -0,0 +1,3 @@
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y

View File

@ -0,0 +1,9 @@
# Enable Unity fixture support
CONFIG_UNITY_ENABLE_FIXTURE=n
CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y
# Custom partition table for this test app
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_ESP_TASK_WDT_INIT=n

View File

@ -0,0 +1 @@
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2) # This config is split between targets since different component needs to be excluded (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32" CONFIG_IDF_TARGET="esp32"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs test_utils TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash test_utils

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded # This config is split between targets since different component needs to be excluded
CONFIG_IDF_TARGET="esp32c3" CONFIG_IDF_TARGET="esp32c3"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs lwip spiffs perfmon test_utils TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash lwip spiffs perfmon test_utils

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2) # This config is split between targets since different component needs to be excluded (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2" CONFIG_IDF_TARGET="esp32s2"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2) # This config is split between targets since different component needs to be excluded (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s3" CONFIG_IDF_TARGET="esp32s3"
TEST_EXCLUDE_COMPONENTS=bt esp32s3 driver soc spi_flash vfs test_utils TEST_EXCLUDE_COMPONENTS=bt esp32s3 driver soc spi_flash test_utils

View File

@ -1,3 +1,3 @@
# continue from default # continue from default
CONFIG_IDF_TARGET="esp32" CONFIG_IDF_TARGET="esp32"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c2" CONFIG_IDF_TARGET="esp32c2"
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c3" CONFIG_IDF_TARGET="esp32c3"
TEST_COMPONENTS=spi_flash vfs lwip TEST_COMPONENTS=spi_flash lwip

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c6" CONFIG_IDF_TARGET="esp32c6"
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32h2" CONFIG_IDF_TARGET="esp32h2"
TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash vfs TEST_EXCLUDE_COMPONENTS=app_trace esp_eth esp_hid esp_netif esp_phy esp_ringbuf esp_wifi espcoredump hal lwip mdns newlib nvs_flash partition_table sdmmc driver soc spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c2" CONFIG_IDF_TARGET="esp32c2"
TEST_COMPONENTS= soc spi_flash vfs TEST_COMPONENTS= soc spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c6" CONFIG_IDF_TARGET="esp32c6"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32h2" CONFIG_IDF_TARGET="esp32h2"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2) # This config is split between targets since different component needs to be included (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2" CONFIG_IDF_TARGET="esp32s2"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash

View File

@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included # This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32s3" CONFIG_IDF_TARGET="esp32s3"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash

View File

@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32" CONFIG_IDF_TARGET="esp32"
TEST_COMPONENTS=driver soc spi_flash vfs TEST_COMPONENTS=driver soc spi_flash
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y

View File

@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2) # This config is split between targets since different component needs to be included (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32" CONFIG_IDF_TARGET="esp32"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs test_utils TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash test_utils
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y

View File

@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2) # This config is split between targets since different component needs to be excluded (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2" CONFIG_IDF_TARGET="esp32s2"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs test_utils TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash test_utils
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y

View File

@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32c2" CONFIG_IDF_TARGET="esp32c2"
TEST_COMPONENTS=spi_flash vfs sdmmc TEST_COMPONENTS=spi_flash sdmmc
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y

View File

@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32c3" CONFIG_IDF_TARGET="esp32c3"
TEST_COMPONENTS=spi_flash vfs sdmmc TEST_COMPONENTS=spi_flash sdmmc
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y

View File

@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32c6" CONFIG_IDF_TARGET="esp32c6"
TEST_COMPONENTS=esp_ipc spi_flash vfs sdmmc TEST_COMPONENTS=esp_ipc spi_flash sdmmc
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y

View File

@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32h2" CONFIG_IDF_TARGET="esp32h2"
TEST_COMPONENTS=esp_ipc spi_flash vfs sdmmc TEST_COMPONENTS=esp_ipc spi_flash sdmmc
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y

View File

@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2) # This config is split between targets since different component needs to be included (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2" CONFIG_IDF_TARGET="esp32s2"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y

View File

@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32s3" CONFIG_IDF_TARGET="esp32s3"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash
CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y

View File

@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2) # This config is split between targets since different component needs to be included (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32" CONFIG_IDF_TARGET="esp32"
TEST_COMPONENTS=spi_flash vfs TEST_COMPONENTS=spi_flash
CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_UNICORE=y
CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y
CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y

View File

@ -1,5 +1,5 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2) # This config is split between targets since different component needs to be excluded (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32" CONFIG_IDF_TARGET="esp32"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs test_utils TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash test_utils
CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_UNICORE=y
CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y

View File

@ -1,5 +1,5 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2) # This config is split between targets since different component needs to be excluded (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2" CONFIG_IDF_TARGET="esp32s2"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash
CONFIG_FREERTOS_UNICORE=y CONFIG_FREERTOS_UNICORE=y
CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM=y CONFIG_ESP32S2_RTCDATA_IN_FAST_MEM=y