From cae004a815216c69419242dbd8131b4d94b5e882 Mon Sep 17 00:00:00 2001 From: Harshit Malpani Date: Tue, 9 Aug 2022 15:03:50 +0530 Subject: [PATCH] ci: Migrate esp_http_server unit tests from unit-test-app to component-test-app --- components/esp_http_server/test/CMakeLists.txt | 4 ---- components/esp_http_server/test_apps/CMakeLists.txt | 7 +++++++ components/esp_http_server/test_apps/README.md | 2 ++ .../esp_http_server/test_apps/main/CMakeLists.txt | 3 +++ .../{test => test_apps/main}/test_http_server.c | 5 +++++ .../test_apps/pytest_esp_http_server_ut.py | 13 +++++++++++++ .../esp_http_server/test_apps/sdkconfig.defaults | 9 +++++++++ 7 files changed, 39 insertions(+), 4 deletions(-) delete mode 100644 components/esp_http_server/test/CMakeLists.txt create mode 100644 components/esp_http_server/test_apps/CMakeLists.txt create mode 100644 components/esp_http_server/test_apps/README.md create mode 100644 components/esp_http_server/test_apps/main/CMakeLists.txt rename components/esp_http_server/{test => test_apps/main}/test_http_server.c (99%) create mode 100644 components/esp_http_server/test_apps/pytest_esp_http_server_ut.py create mode 100644 components/esp_http_server/test_apps/sdkconfig.defaults diff --git a/components/esp_http_server/test/CMakeLists.txt b/components/esp_http_server/test/CMakeLists.txt deleted file mode 100644 index 616c9a94fe..0000000000 --- a/components/esp_http_server/test/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -idf_component_register(SRC_DIRS "." - PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils esp_http_server) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/esp_http_server/test_apps/CMakeLists.txt b/components/esp_http_server/test_apps/CMakeLists.txt new file mode 100644 index 0000000000..3d62a12c41 --- /dev/null +++ b/components/esp_http_server/test_apps/CMakeLists.txt @@ -0,0 +1,7 @@ +#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") + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(esp_http_server_test) diff --git a/components/esp_http_server/test_apps/README.md b/components/esp_http_server/test_apps/README.md new file mode 100644 index 0000000000..b5be4985c5 --- /dev/null +++ b/components/esp_http_server/test_apps/README.md @@ -0,0 +1,2 @@ +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | diff --git a/components/esp_http_server/test_apps/main/CMakeLists.txt b/components/esp_http_server/test_apps/main/CMakeLists.txt new file mode 100644 index 0000000000..eb7ca6e23c --- /dev/null +++ b/components/esp_http_server/test_apps/main/CMakeLists.txt @@ -0,0 +1,3 @@ +idf_component_register(SRC_DIRS "." + PRIV_INCLUDE_DIRS "." + PRIV_REQUIRES esp_http_server test_utils unity) diff --git a/components/esp_http_server/test/test_http_server.c b/components/esp_http_server/test_apps/main/test_http_server.c similarity index 99% rename from components/esp_http_server/test/test_http_server.c rename to components/esp_http_server/test_apps/main/test_http_server.c index 9a1e49f571..0acb8c9ed4 100644 --- a/components/esp_http_server/test/test_http_server.c +++ b/components/esp_http_server/test_apps/main/test_http_server.c @@ -243,3 +243,8 @@ TEST_CASE("Max Allowed Sockets Test", "[HTTP SERVER]") config.max_open_sockets += 1; TEST_ASSERT(httpd_start(&hd, &config) != ESP_OK); } + +void app_main(void) +{ + unity_run_menu(); +} diff --git a/components/esp_http_server/test_apps/pytest_esp_http_server_ut.py b/components/esp_http_server/test_apps/pytest_esp_http_server_ut.py new file mode 100644 index 0000000000..fa02ded114 --- /dev/null +++ b/components/esp_http_server/test_apps/pytest_esp_http_server_ut.py @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 + +import pytest +from pytest_embedded import Dut + + +@pytest.mark.supported_targets +@pytest.mark.generic +def test_esp_http_server(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('*') + dut.expect_unity_test_output() diff --git a/components/esp_http_server/test_apps/sdkconfig.defaults b/components/esp_http_server/test_apps/sdkconfig.defaults new file mode 100644 index 0000000000..ec826a5a16 --- /dev/null +++ b/components/esp_http_server/test_apps/sdkconfig.defaults @@ -0,0 +1,9 @@ +# General options for additional checks +CONFIG_HEAP_POISONING_COMPREHENSIVE=y +CONFIG_COMPILER_WARN_WRITE_STRINGS=y +CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y +CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y +CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y +CONFIG_COMPILER_STACK_CHECK=y + +CONFIG_ESP_TASK_WDT=n