From d5b4108085109056deab34af8ab5c2f6ec7bc961 Mon Sep 17 00:00:00 2001 From: morris Date: Wed, 21 Dec 2022 21:31:03 +0800 Subject: [PATCH] gpio: combine sdm, glitch filter, fast gpio tests into one app --- components/driver/.build-test-rules.yml | 4 -- .../driver/test_apps/gpio/main/CMakeLists.txt | 8 ---- .../driver/test_apps/gpio/pytest_gpio.py | 24 +---------- .../{sdm => gpio_extensions}/CMakeLists.txt | 4 +- .../test_apps/gpio_extensions/README.md | 2 + .../gpio_extensions/main/CMakeLists.txt | 18 ++++++++ .../main/test_app_main.c | 24 +++++------ .../main/test_dedicated_gpio.c | 0 .../main/test_gpio_filter.c | 0 .../{sdm => gpio_extensions}/main/test_sdm.c | 0 .../gpio_extensions/pytest_gpio_extensions.py | 43 +++++++++++++++++++ .../sdkconfig.ci.iram_safe | 2 + .../sdkconfig.ci.release | 0 .../sdkconfig.defaults | 0 components/driver/test_apps/sdm/README.md | 2 - .../driver/test_apps/sdm/main/CMakeLists.txt | 7 --- components/driver/test_apps/sdm/pytest_sdm.py | 25 ----------- 17 files changed, 80 insertions(+), 83 deletions(-) rename components/driver/test_apps/{sdm => gpio_extensions}/CMakeLists.txt (85%) create mode 100644 components/driver/test_apps/gpio_extensions/README.md create mode 100644 components/driver/test_apps/gpio_extensions/main/CMakeLists.txt rename components/driver/test_apps/{sdm => gpio_extensions}/main/test_app_main.c (55%) rename components/driver/test_apps/{gpio => gpio_extensions}/main/test_dedicated_gpio.c (100%) rename components/driver/test_apps/{gpio => gpio_extensions}/main/test_gpio_filter.c (100%) rename components/driver/test_apps/{sdm => gpio_extensions}/main/test_sdm.c (100%) create mode 100644 components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py rename components/driver/test_apps/{sdm => gpio_extensions}/sdkconfig.ci.iram_safe (71%) rename components/driver/test_apps/{sdm => gpio_extensions}/sdkconfig.ci.release (100%) rename components/driver/test_apps/{sdm => gpio_extensions}/sdkconfig.defaults (100%) delete mode 100644 components/driver/test_apps/sdm/README.md delete mode 100644 components/driver/test_apps/sdm/main/CMakeLists.txt delete mode 100644 components/driver/test_apps/sdm/pytest_sdm.py diff --git a/components/driver/.build-test-rules.yml b/components/driver/.build-test-rules.yml index 520cd0a6e9..25fef7f738 100644 --- a/components/driver/.build-test-rules.yml +++ b/components/driver/.build-test-rules.yml @@ -76,10 +76,6 @@ components/driver/test_apps/sdio: temporary: true reason: Not supported. -components/driver/test_apps/sdm: - disable: - - if: SOC_SDM_SUPPORTED != 1 - components/driver/test_apps/temperature_sensor: disable: - if: SOC_TEMP_SENSOR_SUPPORTED != 1 diff --git a/components/driver/test_apps/gpio/main/CMakeLists.txt b/components/driver/test_apps/gpio/main/CMakeLists.txt index 09dabd06a5..ebc552aaf8 100644 --- a/components/driver/test_apps/gpio/main/CMakeLists.txt +++ b/components/driver/test_apps/gpio/main/CMakeLists.txt @@ -1,14 +1,6 @@ set(srcs "test_app_main.c" "test_gpio.c") -if(CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER OR (CONFIG_SOC_GPIO_FLEX_GLITCH_FILTER_NUM GREATER 0)) - list(APPEND srcs "test_gpio_filter.c") -endif() - -if(CONFIG_SOC_DEDICATED_GPIO_SUPPORTED) - list(APPEND srcs "test_dedicated_gpio.c") -endif() - if(CONFIG_SOC_SDM_SUPPORTED) list(APPEND srcs "test_sigma_delta_legacy.c") endif() diff --git a/components/driver/test_apps/gpio/pytest_gpio.py b/components/driver/test_apps/gpio/pytest_gpio.py index b78c80c2a6..0f59bff3f5 100644 --- a/components/driver/test_apps/gpio/pytest_gpio.py +++ b/components/driver/test_apps/gpio/pytest_gpio.py @@ -17,28 +17,6 @@ def test_gpio(dut: IdfDut) -> None: dut.run_all_single_board_cases(group='gpio') -@pytest.mark.esp32c2 -@pytest.mark.esp32c3 -@pytest.mark.esp32c6 -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.generic -@pytest.mark.parametrize('config', CONFIGS, indirect=True) -def test_gpio_filter(dut: IdfDut) -> None: - dut.run_all_single_board_cases(group='gpio_filter') - - -@pytest.mark.esp32c2 -@pytest.mark.esp32c3 -@pytest.mark.esp32c6 -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.generic -@pytest.mark.parametrize('config', CONFIGS, indirect=True) -def test_dedic_gpio(dut: IdfDut) -> None: - dut.run_all_single_board_cases(group='dedic_gpio') - - @pytest.mark.esp32 @pytest.mark.esp32c3 @pytest.mark.esp32c6 @@ -46,7 +24,7 @@ def test_dedic_gpio(dut: IdfDut) -> None: @pytest.mark.esp32s3 @pytest.mark.generic @pytest.mark.parametrize('config', CONFIGS, indirect=True) -def test_sigma_delta(dut: IdfDut) -> None: +def test_legacy_sigma_delta(dut: IdfDut) -> None: dut.run_all_single_board_cases(group='sigma_delta') diff --git a/components/driver/test_apps/sdm/CMakeLists.txt b/components/driver/test_apps/gpio_extensions/CMakeLists.txt similarity index 85% rename from components/driver/test_apps/sdm/CMakeLists.txt rename to components/driver/test_apps/gpio_extensions/CMakeLists.txt index 9830fb8ada..17a9e49590 100644 --- a/components/driver/test_apps/sdm/CMakeLists.txt +++ b/components/driver/test_apps/gpio_extensions/CMakeLists.txt @@ -2,13 +2,13 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(sdm_test) +project(gpio_extension_test) if(CONFIG_COMPILER_DUMP_RTL_FILES) add_custom_target(check_test_app_sections ALL COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py --rtl-dir ${CMAKE_BINARY_DIR}/esp-idf/driver/ - --elf-file ${CMAKE_BINARY_DIR}/sdm_test.elf + --elf-file ${CMAKE_BINARY_DIR}/gpio_extension_test.elf find-refs --from-sections=.iram0.text --to-sections=.flash.text,.flash.rodata diff --git a/components/driver/test_apps/gpio_extensions/README.md b/components/driver/test_apps/gpio_extensions/README.md new file mode 100644 index 0000000000..7e7523ec85 --- /dev/null +++ b/components/driver/test_apps/gpio_extensions/README.md @@ -0,0 +1,2 @@ +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/gpio_extensions/main/CMakeLists.txt b/components/driver/test_apps/gpio_extensions/main/CMakeLists.txt new file mode 100644 index 0000000000..6175f6f23d --- /dev/null +++ b/components/driver/test_apps/gpio_extensions/main/CMakeLists.txt @@ -0,0 +1,18 @@ +set(srcs "test_app_main.c") + +if(CONFIG_SOC_DEDICATED_GPIO_SUPPORTED) + list(APPEND srcs "test_dedicated_gpio.c") +endif() + +if(CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER OR (CONFIG_SOC_GPIO_FLEX_GLITCH_FILTER_NUM GREATER 0)) + list(APPEND srcs "test_gpio_filter.c") +endif() + +if(CONFIG_SOC_SDM_SUPPORTED) + list(APPEND srcs "test_sdm.c") +endif() + +# 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} + WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/sdm/main/test_app_main.c b/components/driver/test_apps/gpio_extensions/main/test_app_main.c similarity index 55% rename from components/driver/test_apps/sdm/main/test_app_main.c rename to components/driver/test_apps/gpio_extensions/main/test_app_main.c index 6394c16e0c..b53eec62b8 100644 --- a/components/driver/test_apps/sdm/main/test_app_main.c +++ b/components/driver/test_apps/gpio_extensions/main/test_app_main.c @@ -8,8 +8,8 @@ #include "unity_test_runner.h" #include "esp_heap_caps.h" -// Some resources are lazy allocated in pulse_cnt driver, the threshold is left for that case -#define TEST_MEMORY_LEAK_THRESHOLD (-200) +// Some resources are lazy allocated in the driver, the threshold is left for that case +#define TEST_MEMORY_LEAK_THRESHOLD (-300) static size_t before_free_8bit; static size_t before_free_32bit; @@ -37,15 +37,15 @@ void tearDown(void) void app_main(void) { - // ____ ____ ___ ___ ____ ____ __ __ - // / ___| _ \_ _/ _ \ / ___|| _ \| \/ | - // | | _| |_) | | | | | \___ \| | | | |\/| | - // | |_| | __/| | |_| | ___) | |_| | | | | - // \____|_| |___\___/ |____/|____/|_| |_| - printf(" ____ ____ ___ ___ ____ ____ __ __\r\n"); - printf(" / ___| _ \\_ _/ _ \\ / ___|| _ \\| \\/ |\r\n"); - printf("| | _| |_) | | | | | \\___ \\| | | | |\\/| |\r\n"); - printf("| |_| | __/| | |_| | ___) | |_| | | | |\r\n"); - printf(" \\____|_| |___\\___/ |____/|____/|_| |_|\r\n"); + // ____ ____ ___ ___ _____ _ _____ _ + // / ___| _ \_ _/ _ \ | ____|_ _| |_ |_ _|__ ___| |_ + // | | _| |_) | | | | | | _| \ \/ / __| | |/ _ \/ __| __| + // | |_| | __/| | |_| | | |___ > <| |_ | | __/\__ \ |_ + // \____|_| |___\___/ |_____/_/\_\\__| |_|\___||___/\__| + printf(" ____ ____ ___ ___ _____ _ _____ _\r\n"); + printf(" / ___| _ \\_ _/ _ \\ | ____|_ _| |_ |_ _|__ ___| |_\r\n"); + printf("| | _| |_) | | | | | | _| \\ \\/ / __| | |/ _ \\/ __| __|\r\n"); + printf("| |_| | __/| | |_| | | |___ > <| |_ | | __/\\__ \\ |_\r\n"); + printf(" \\____|_| |___\\___/ |_____/_/\\_\\\\__| |_|\\___||___/\\__|\r\n"); unity_run_menu(); } diff --git a/components/driver/test_apps/gpio/main/test_dedicated_gpio.c b/components/driver/test_apps/gpio_extensions/main/test_dedicated_gpio.c similarity index 100% rename from components/driver/test_apps/gpio/main/test_dedicated_gpio.c rename to components/driver/test_apps/gpio_extensions/main/test_dedicated_gpio.c diff --git a/components/driver/test_apps/gpio/main/test_gpio_filter.c b/components/driver/test_apps/gpio_extensions/main/test_gpio_filter.c similarity index 100% rename from components/driver/test_apps/gpio/main/test_gpio_filter.c rename to components/driver/test_apps/gpio_extensions/main/test_gpio_filter.c diff --git a/components/driver/test_apps/sdm/main/test_sdm.c b/components/driver/test_apps/gpio_extensions/main/test_sdm.c similarity index 100% rename from components/driver/test_apps/sdm/main/test_sdm.c rename to components/driver/test_apps/gpio_extensions/main/test_sdm.c diff --git a/components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py b/components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py new file mode 100644 index 0000000000..e245bb1993 --- /dev/null +++ b/components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py @@ -0,0 +1,43 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 + +import pytest +from pytest_embedded_idf import IdfDut + +CONFIGS = [ + 'iram_safe', + 'release', +] + + +@pytest.mark.esp32 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_sdm(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='sdm') + + +@pytest.mark.esp32c2 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_gpio_filter(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='gpio_filter') + + +@pytest.mark.esp32c2 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_dedic_gpio(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='dedic_gpio') diff --git a/components/driver/test_apps/sdm/sdkconfig.ci.iram_safe b/components/driver/test_apps/gpio_extensions/sdkconfig.ci.iram_safe similarity index 71% rename from components/driver/test_apps/sdm/sdkconfig.ci.iram_safe rename to components/driver/test_apps/gpio_extensions/sdkconfig.ci.iram_safe index 35876c662b..7e63e6d096 100644 --- a/components/driver/test_apps/sdm/sdkconfig.ci.iram_safe +++ b/components/driver/test_apps/gpio_extensions/sdkconfig.ci.iram_safe @@ -5,3 +5,5 @@ CONFIG_COMPILER_OPTIMIZATION_NONE=y CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y # silent the error check, as the error string are stored in rodata, causing RTL check failure CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y +# GPIO test uses IPC call, the default stack size of IPC task can satisfy the -O0 optimization +CONFIG_ESP_IPC_TASK_STACK_SIZE=2048 diff --git a/components/driver/test_apps/sdm/sdkconfig.ci.release b/components/driver/test_apps/gpio_extensions/sdkconfig.ci.release similarity index 100% rename from components/driver/test_apps/sdm/sdkconfig.ci.release rename to components/driver/test_apps/gpio_extensions/sdkconfig.ci.release diff --git a/components/driver/test_apps/sdm/sdkconfig.defaults b/components/driver/test_apps/gpio_extensions/sdkconfig.defaults similarity index 100% rename from components/driver/test_apps/sdm/sdkconfig.defaults rename to components/driver/test_apps/gpio_extensions/sdkconfig.defaults diff --git a/components/driver/test_apps/sdm/README.md b/components/driver/test_apps/sdm/README.md deleted file mode 100644 index 6f026d8e9e..0000000000 --- a/components/driver/test_apps/sdm/README.md +++ /dev/null @@ -1,2 +0,0 @@ -| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/sdm/main/CMakeLists.txt b/components/driver/test_apps/sdm/main/CMakeLists.txt deleted file mode 100644 index c304c90d3a..0000000000 --- a/components/driver/test_apps/sdm/main/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -set(srcs "test_app_main.c" - "test_sdm.c") - -# 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} - WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/sdm/pytest_sdm.py b/components/driver/test_apps/sdm/pytest_sdm.py deleted file mode 100644 index d40b9ee056..0000000000 --- a/components/driver/test_apps/sdm/pytest_sdm.py +++ /dev/null @@ -1,25 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: CC0-1.0 - -import pytest -from pytest_embedded import Dut - - -@pytest.mark.esp32 -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.esp32c3 -@pytest.mark.esp32c6 -@pytest.mark.generic -@pytest.mark.parametrize( - 'config', - [ - 'iram_safe', - 'release', - ], - indirect=True, -) -def test_sdm(dut: Dut) -> None: - dut.expect_exact('Press ENTER to see the list of tests') - dut.write('*') - dut.expect_unity_test_output()