Skip to content

Commit

Permalink
Merge branch 'feature/vfs_test_app' into 'master'
Browse files Browse the repository at this point in the history
VFS: move tests from unit-test-app to a component test app

See merge request espressif/esp-idf!23145
  • Loading branch information
pacucha42 committed Apr 26, 2023
2 parents f73bd61 + d83c681 commit 668521d
Show file tree
Hide file tree
Showing 47 changed files with 154 additions and 58 deletions.
3 changes: 0 additions & 3 deletions components/vfs/test/CMakeLists.txt

This file was deleted.

12 changes: 12 additions & 0 deletions components/vfs/test_apps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions components/vfs/test_apps/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |

12 changes: 12 additions & 0 deletions components/vfs/test_apps/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
34 changes: 34 additions & 0 deletions components/vfs/test_apps/main/test_app_main.c
Original file line number Diff line number Diff line change
@@ -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();
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "esp_vfs_dev.h"
#include "esp_vfs_fat.h"
#include "wear_levelling.h"
#include "test_utils.h"
#include "sdkconfig.h"

static wl_handle_t test_wl_handle;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "esp_vfs_fat.h"
#include "esp_spiffs.h"
#include "wear_levelling.h"
#include "test_utils.h"

#define TEST_PARTITION_LABEL "flash_test"

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
// Copyright 2021 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.
// 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.
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

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

#include <stdbool.h>
#include <stdio.h>
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions components/vfs/test_apps/partitions.csv
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions components/vfs/test_apps/pytest_vfs.py
Original file line number Diff line number Diff line change
@@ -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()
1 change: 1 addition & 0 deletions components/vfs/test_apps/sdkconfig.ci.ccomp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
Empty file.
3 changes: 3 additions & 0 deletions components/vfs/test_apps/sdkconfig.ci.psram
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
9 changes: 9 additions & 0 deletions components/vfs/test_apps/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions components/vfs/test_apps/sdkconfig.defaults.esp32
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_2_c3
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded
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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_2_s2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2"
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash vfs
TEST_EXCLUDE_COMPONENTS=bt driver soc spi_flash
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_2_s3
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_32_2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# continue from default
CONFIG_IDF_TARGET="esp32"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_3_c2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_3_c3
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c3"
TEST_COMPONENTS=spi_flash vfs lwip
TEST_COMPONENTS=spi_flash lwip
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_3_c6
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_3_h2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
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
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_c2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c2"
TEST_COMPONENTS= soc spi_flash vfs
TEST_COMPONENTS= soc spi_flash
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_c6
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32c6"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_h2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32h2"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_s2_2
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/default_s3
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This config is split between targets since different component needs to be included
CONFIG_IDF_TARGET="esp32s3"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32"
TEST_COMPONENTS=driver soc spi_flash vfs
TEST_COMPONENTS=driver soc spi_flash
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2)
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_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_2_s2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be excluded (esp32, 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_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_c2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32c2"
TEST_COMPONENTS=spi_flash vfs sdmmc
TEST_COMPONENTS=spi_flash sdmmc
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_c3_2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32c3"
TEST_COMPONENTS=spi_flash vfs sdmmc
TEST_COMPONENTS=spi_flash sdmmc
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_c6
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_h2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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_ASSERTIONS_SILENT=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_s2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32s2"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/release_s3
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CONFIG_IDF_TARGET="esp32s3"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/single_core
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This config is split between targets since different component needs to be included (esp32, esp32s2)
CONFIG_IDF_TARGET="esp32"
TEST_COMPONENTS=spi_flash vfs
TEST_COMPONENTS=spi_flash
CONFIG_FREERTOS_UNICORE=y
CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY=y
CONFIG_ESP32_RTCDATA_IN_FAST_MEM=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/single_core_2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This config is split between targets since different component needs to be excluded (esp32, esp32s2)
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_ESP32_RTCDATA_IN_FAST_MEM=y
2 changes: 1 addition & 1 deletion tools/unit-test-app/configs/single_core_2_s2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This config is split between targets since different component needs to be excluded (esp32, 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_ESP32S2_RTCDATA_IN_FAST_MEM=y

0 comments on commit 668521d

Please sign in to comment.