test: move sdio unit-test to test_apps

pull/10224/head
wanlei 2022-11-14 11:34:21 +08:00
rodzic 7758c0c65b
commit ee4f4ac3e0
13 zmienionych plików z 122 dodań i 65 usunięć

Wyświetl plik

@ -134,9 +134,8 @@ build:integration_test:
- - bt # example_test_005
- wifi # example_test_002, example_test*wifi*
- ethernet # example_test*ethernet*
- sdio # UT_044, UT_045
- sdio # component_ut_pytest_esp32_sdio
- usb # USB Device & Host tests
- spi_multi # UT_C2_SPI_DUAL
- adc # component_ut_pytest_esp32x_adc
- i154
patterns:

Wyświetl plik

@ -229,9 +229,9 @@
- "components/esp_netif/**/*"
- "components/lwip/**/*"
# for jobs: UT_044, UT_045
# for jobs: component_ut_pytest_esp32_sdio
.patterns-unit_test-sdio: &patterns-unit_test-sdio
- "components/esp_serial_slave_link/**/*"
- "components/hal/**/*"
- "components/driver/**/*"
- "components/sdmmc/**/*"
@ -243,13 +243,6 @@
- "examples/peripherals/usb/host/**/**/**/*"
- "examples/peripherals/usb/device/**/**/*"
# for job: unit_test-spi_multi which has only one runner
.patterns-unit_test-spi_multi: &patterns-unit_test-spi_multi
- "components/esp_serial_slave_link/**/*"
- "components/driver/**/*"
- "components/hal/**/*"
- "examples/peripherals/spi_slave*/**/*"
# for jobs: component_ut_pytest_esp32x_adc:
.patterns-component_ut-adc: &patterns-component_ut-adc
- "components/esp_adc/**/*"
@ -1285,8 +1278,6 @@
changes: *patterns-unit_test
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:build:unit_test:
rules:
@ -1318,8 +1309,6 @@
changes: *patterns-unit_test
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:build:unit_test-esp32:
rules:
@ -1345,8 +1334,6 @@
changes: *patterns-unit_test
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:build:unit_test-esp32c2:
rules:
@ -1369,8 +1356,6 @@
changes: *patterns-target_test-wifi
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:build:unit_test-esp32c3:
rules:
@ -1395,8 +1380,6 @@
changes: *patterns-unit_test
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:build:unit_test-esp32c6:
rules:
@ -1421,8 +1404,6 @@
changes: *patterns-unit_test
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:build:unit_test-esp32s2:
rules:
@ -1447,8 +1428,6 @@
changes: *patterns-unit_test
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:build:unit_test-esp32s3:
rules:
@ -1473,8 +1452,6 @@
changes: *patterns-unit_test
- <<: *if-dev-push
changes: *patterns-unit_test-sdio
- <<: *if-dev-push
changes: *patterns-unit_test-spi_multi
.rules:labels-protected:lan8720:
rules:

Wyświetl plik

@ -322,6 +322,14 @@ component_ut_pytest_esp32_adc:
- build_pytest_components_esp32
tags: [ esp32, adc ]
component_ut_pytest_esp32_sdio:
extends:
- .pytest_components_dir_template
- .rules:test:unit_test-esp32-sdio
needs:
- build_pytest_components_esp32
tags: [ esp32, sdio_master_slave ]
component_ut_pytest_esp32_ip101:
extends:
- .pytest_components_dir_template
@ -1061,23 +1069,6 @@ UT_043:
- UT_T1_32kXTAL
- psram
UT_044:
extends:
- .unit_test_esp32_template
- .rules:test:unit_test-esp32-sdio
tags:
- ESP32_IDF
- UT_SDIO
UT_045:
extends:
- .unit_test_esp32_template
- .rules:test:unit_test-esp32-sdio
tags:
- ESP32_IDF
- UT_SDIO
- psram
UT_S2_SDSPI:
extends: .unit_test_esp32s2_template
tags:

Wyświetl plik

@ -63,6 +63,12 @@ components/driver/test_apps/rs485:
temporary: true
reason: lack of runners
components/driver/test_apps/sdio:
disable:
- if: SOC_SDIO_SLAVE_SUPPORTED != 1
temporary: true
reason: Not supported.
components/driver/test_apps/sdm:
disable:
- if: SOC_SDM_SUPPORTED != 1

Wyświetl plik

@ -0,0 +1,10 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)
set(EXTRA_COMPONENT_DIRS
"$ENV{IDF_PATH}/tools/unit-test-app/components"
"$ENV{IDF_PATH}/components/driver/test_apps/components"
)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(sdio_test)

Wyświetl plik

@ -0,0 +1,2 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |

Wyświetl plik

@ -0,0 +1,13 @@
set(srcs
"test_app_main.c"
"test_sdio.c"
"test_sdmmc_sdspi_init.cpp"
)
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(
SRCS ${srcs}
PRIV_REQUIRES test_utils test_driver_utils driver esp_timer sdmmc esp_serial_slave_link
WHOLE_ARCHIVE
)

Wyświetl plik

@ -0,0 +1,48 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "unity.h"
#include "unity_test_utils.h"
#include "esp_heap_caps.h"
#define TEST_MEMORY_LEAK_THRESHOLD (200)
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)
{
esp_reent_cleanup(); //clean up some of the newlib's lazy allocations
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);
printf("\n");
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)
{
// _____ _ _ _
// |_ _|__ ___| |_ ___ __| (_) ___
// | |/ _ \/ __| __| / __|/ _` | |/ _ `.
// | | __/\__ \ |_ \__ \ (_| | | (_) |
// |_|\___||___/\__| |___/\__,_|_|\___/
printf(" _____ _ _ _ \n");
printf(" |_ _|__ ___| |_ ___ __| (_) ___ \n");
printf(" | |/ _ \\/ __| __| / __|/ _` | |/ _ \\ \n");
printf(" | | __/\\__ \\ |_ \\__ \\ (_| | | (_) |\n");
printf(" |_|\\___||___/\\__| |___/\\__,_|_|\\___/ \n");
unity_run_menu();
}

Wyświetl plik

@ -7,17 +7,14 @@
#include "unity.h"
#include "test_utils.h"
#include "test_spi_utils.h"
#include "esp_serial_slave_link/essl_sdio.h"
#include "esp_log.h"
#include "sdmmc_cmd.h"
#include "esp_timer.h"
#include "soc/soc_caps.h"
#include "ccomp_timer.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "driver/spi_common.h"
#include "driver/sdspi_host.h"
#include "esp_serial_slave_link/essl_sdio.h"
#include "sdmmc_cmd.h"
#include "soc/soc_caps.h"
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S3)
@ -351,13 +348,13 @@ static void log_performance_tohost(uint32_t speed, const sdio_test_config_t* con
if (!config->check_data) {
switch (config->sdio_mode) {
case SDIO_4BIT:
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_TOHOST_4BIT, "%d", speed);
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_TOHOST_4BIT, "%" PRIu32, speed);
break;
case SDIO_1BIT:
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_TOHOST_1BIT, "%d", speed);
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_TOHOST_1BIT, "%" PRIu32, speed);
break;
case SDIO_SPI:
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_TOHOST_SPI, "%d", speed);
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_TOHOST_SPI, "%" PRIu32, speed);
break;
}
}
@ -422,7 +419,7 @@ static void test_tp_tohost_master(essl_handle_t handle, const sdio_test_config_t
int64_t end_us = esp_timer_get_time();
uint32_t total_time_ms = (end_us - pre_us)/1000;
ESP_LOGI(MASTER_TAG, "test done, total time: %d ms (%d ms compensated), bytes transferred: %d", total_time_ms, (int)c_time_ms, expected_length);
ESP_LOGI(MASTER_TAG, "test done, total time: %" PRIu32 " ms (%d ms compensated), bytes transferred: %d", total_time_ms, (int)c_time_ms, expected_length);
uint32_t throughput_byte_per_ms = expected_length / c_time_ms;
ESP_LOGI(MASTER_TAG, "Throughput: compensated %.2lf MB/s, typical %.2lf MB/s",
@ -437,13 +434,13 @@ static void log_performance_frhost(uint32_t speed, const sdio_test_config_t* con
if (!config->check_data) {
switch (config->sdio_mode) {
case SDIO_4BIT:
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_FRHOST_4BIT, "%d", speed);
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_FRHOST_4BIT, "%" PRIu32, speed);
break;
case SDIO_1BIT:
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_FRHOST_1BIT, "%d", speed);
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_FRHOST_1BIT, "%" PRIu32, speed);
break;
case SDIO_SPI:
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_FRHOST_SPI, "%d", speed);
TEST_PERFORMANCE_CCOMP_GREATER_THAN(SDIO_THROUGHPUT_KBSEC_FRHOST_SPI, "%" PRIu32, speed);
break;
}
}
@ -482,7 +479,7 @@ static void test_tp_frhost_master(essl_handle_t handle, const sdio_test_config_t
int64_t end_us = esp_timer_get_time();
uint32_t total_time_ms = (end_us - pre_us)/1000;
ESP_LOGI(MASTER_TAG, "test done, total time: %d ms (%d ms compensated), bytes transferred: %d", total_time_ms, (int)c_time_ms, expected_length);
ESP_LOGI(MASTER_TAG, "test done, total time: %" PRIu32 " ms (%d ms compensated), bytes transferred: %d", total_time_ms, (int)c_time_ms, expected_length);
uint32_t throughput_byte_per_ms = expected_length / c_time_ms;
ESP_LOGI(MASTER_TAG, "Throughput: compensated %.2lf MB/s, typical %.2lf MB/s",
@ -734,15 +731,15 @@ void test_sdio_reset_slave(void)
}
TEST_CASE_MULTIPLE_DEVICES("sdio interrupt", "[sdio][test_env=UT_SDIO]", test_sdio_interrupt_master, test_sdio_interrupt_slave);
TEST_CASE_MULTIPLE_DEVICES("sdio interrupt", "[sdio][test_env=sdio_master_slave]", test_sdio_interrupt_master, test_sdio_interrupt_slave);
TEST_CASE_MULTIPLE_DEVICES("sdio register", "[sdio][test_env=UT_SDIO]", test_sdio_reg_master, test_sdio_interrupt_slave);
TEST_CASE_MULTIPLE_DEVICES("sdio register", "[sdio][test_env=sdio_master_slave]", test_sdio_reg_master, test_sdio_interrupt_slave);
#if !CONFIG_FREERTOS_UNICORE
TEST_CASE_MULTIPLE_DEVICES("sdio reset", "[sdio][test_env=UT_SDIO]", test_sdio_reset_master, test_sdio_reset_slave);
TEST_CASE_MULTIPLE_DEVICES("sdio reset", "[sdio][test_env=sdio_master_slave]", test_sdio_reset_master, test_sdio_reset_slave);
#else
//Currently there is weird issue on the runner, when tested with single core config, seems to relate to receiving
TEST_CASE_MULTIPLE_DEVICES("sdio reset", "[sdio][test_env=UT_SDIO][ignore]", test_sdio_reset_master, test_sdio_reset_slave);
TEST_CASE_MULTIPLE_DEVICES("sdio reset", "[sdio][test_env=sdio_master_slave][ignore]", test_sdio_reset_master, test_sdio_reset_slave);
#endif
@ -792,10 +789,10 @@ ptest_func_t frhost_slave = {
PARAM_GROUP_DECLARE_TYPE(IO_MODE, sdio_test_config_t, test_cfg_array);
#if !CONFIG_FREERTOS_UNICORE
TEST_MASTER_SLAVE(SDIO_FRHOST, test_cfg_array, "[sdio][timeout=180][test_env=UT_SDIO]", &frhost_master, &frhost_slave);
TEST_MASTER_SLAVE(SDIO_FRHOST, test_cfg_array, "[sdio][timeout=180][test_env=sdio_master_slave]", &frhost_master, &frhost_slave);
#else
//Currently there is weird issue on the runner, when tested with single core config, seems to relate to receiving
TEST_MASTER_SLAVE(SDIO_FRHOST, test_cfg_array, "[sdio][timeout=180][test_env=UT_SDIO][ignore]", &frhost_master, &frhost_slave);
TEST_MASTER_SLAVE(SDIO_FRHOST, test_cfg_array, "[sdio][timeout=180][test_env=sdio_master_slave][ignore]", &frhost_master, &frhost_slave);
#endif
ptest_func_t tohost_master = {
@ -810,7 +807,7 @@ ptest_func_t tohost_slave = {
.post_test = null_post,
};
TEST_MASTER_SLAVE(SDIO_TOHOST, test_cfg_array, "[sdio][timeout=180][test_env=UT_SDIO]", &tohost_master, &tohost_slave);
TEST_MASTER_SLAVE(SDIO_TOHOST, test_cfg_array, "[sdio][timeout=180][test_env=sdio_master_slave]", &tohost_master, &tohost_slave);
#endif //SOC_SDMMC_HOST_SUPPORTED && SOC_SDIO_SLAVE_SUPPORTED

Wyświetl plik

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
@pytest.mark.esp32
@pytest.mark.sdio_master_slave
@pytest.mark.parametrize('count', [2,], indirect=True)
def test_sdio_multi_dev(case_tester) -> None: # type: ignore
case_tester.run_all_multi_dev_cases(reset=True)

Wyświetl plik

@ -0,0 +1,2 @@
CONFIG_FREERTOS_HZ=1000
CONFIG_ESP_TASK_WDT=n

Wyświetl plik

@ -75,6 +75,7 @@ markers =
wifi_two_dut: tests should be run on runners which has two wifi duts connected.
generic_multi_device: generic multiple devices whose corresponding gpio pins are connected to each other.
twai_network: multiple runners form a TWAI network.
sdio_master_slave: Test sdio multi board.
# host_test markers
host_test: tests which shouldn not be built at the build stage, and instead built in host_test stage.