From 554f022cbff8ad61b89136bcc42fc8dc34bceb93 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Wed, 18 Sep 2024 08:55:36 +0200 Subject: [PATCH] fix(modem): Update target test builds to use external Catch2 Switched from the deprecated Catch framework (IDF/tools) to Catch2, as Catch will be removed in v6.0. Note that Catch2 has higher memory requirements, necessitating an increase in stack size and partition table. Additionally, Catch2 increases compilation time due to its larger footprint. --- .../esp_modem/test/target/main/CMakeLists.txt | 2 +- .../test/target/main/idf_component.yml | 4 ++ .../esp_modem/test/target/main/pppd_test.cpp | 43 +++++++++++++------ .../test/target/sdkconfig.ci.pppd_chap_auth | 3 +- .../esp_modem/test/target/sdkconfig.defaults | 3 +- 5 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 components/esp_modem/test/target/main/idf_component.yml diff --git a/components/esp_modem/test/target/main/CMakeLists.txt b/components/esp_modem/test/target/main/CMakeLists.txt index 01e8a7f1d1..c7b4db4614 100644 --- a/components/esp_modem/test/target/main/CMakeLists.txt +++ b/components/esp_modem/test/target/main/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRCS "pppd_test.cpp" "NetworkDCE.cpp" - REQUIRES esp_modem) + REQUIRES esp_modem catch2) set_target_properties(${COMPONENT_LIB} PROPERTIES CXX_STANDARD 17 diff --git a/components/esp_modem/test/target/main/idf_component.yml b/components/esp_modem/test/target/main/idf_component.yml new file mode 100644 index 0000000000..eed6d8a02d --- /dev/null +++ b/components/esp_modem/test/target/main/idf_component.yml @@ -0,0 +1,4 @@ +dependencies: + espressif/catch2: "*" + idf: + version: ">=4.4" diff --git a/components/esp_modem/test/target/main/pppd_test.cpp b/components/esp_modem/test/target/main/pppd_test.cpp index 86b383fae2..cd9bfb8bd9 100644 --- a/components/esp_modem/test/target/main/pppd_test.cpp +++ b/components/esp_modem/test/target/main/pppd_test.cpp @@ -17,6 +17,10 @@ #include "freertos/FreeRTOS.h" #include "freertos/event_groups.h" +#define CATCH_CONFIG_MAIN +#include "catch2/catch_test_macros.hpp" +#include "catch2/catch_session.hpp" + static const char *TAG = "pppd_test"; static EventGroupHandle_t event_group = NULL; @@ -73,9 +77,6 @@ esp_err_t modem_init_network(esp_netif_t *netif); void modem_start_network(); void modem_stop_network(); -bool test_connect(); -bool test_disconnect(); - extern "C" void app_main(void) { @@ -99,27 +100,41 @@ extern "C" void app_main(void) #endif modem_start_network(); - - bool t1 = test_connect(); - bool t2 = test_disconnect(); - - if (t1 && t2) { - ESP_LOGI(TAG, "All tests passed"); - } else { + Catch::Session session; + int numFailed = session.run(); + if (numFailed > 0) { ESP_LOGE(TAG, "Test FAILED!"); + } else { + ESP_LOGI(TAG, "Test passed!"); } } -bool test_connect() //("Connect test", "[esp_modem]") +TEST_CASE("Connect test", "[esp_modem]") { EventBits_t b = xEventGroupWaitBits(event_group, 1, pdTRUE, pdFALSE, pdMS_TO_TICKS(15000)); - return b == 1; + CHECK(b == 1); } -bool test_disconnect() //("Disconnection test", "[esp_modem]") +TEST_CASE("Disconnection test", "[esp_modem]") { modem_stop_network(); EventBits_t b = xEventGroupWaitBits(event_group, 2, pdTRUE, pdFALSE, pdMS_TO_TICKS(15000)); - return b == 2; + CHECK(b == 2); +} + + +extern "C" { + + static void handle(int nr) + { + ESP_LOGE(TAG, "Signal handler %d", nr); + } + + _sig_func_ptr signal (int nr, _sig_func_ptr) + { + return handle; + } + + } diff --git a/components/esp_modem/test/target/sdkconfig.ci.pppd_chap_auth b/components/esp_modem/test/target/sdkconfig.ci.pppd_chap_auth index 23b587e9ce..7777069b19 100644 --- a/components/esp_modem/test/target/sdkconfig.ci.pppd_chap_auth +++ b/components/esp_modem/test/target/sdkconfig.ci.pppd_chap_auth @@ -1,4 +1,5 @@ CONFIG_COMPILER_CXX_EXCEPTIONS=y -CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 CONFIG_LWIP_PPP_SUPPORT=y +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y CONFIG_TEST_APP_AUTH=y diff --git a/components/esp_modem/test/target/sdkconfig.defaults b/components/esp_modem/test/target/sdkconfig.defaults index 28ae669b93..8bdcab28ad 100644 --- a/components/esp_modem/test/target/sdkconfig.defaults +++ b/components/esp_modem/test/target/sdkconfig.defaults @@ -1,3 +1,4 @@ CONFIG_COMPILER_CXX_EXCEPTIONS=y -CONFIG_ESP_MAIN_TASK_STACK_SIZE=4096 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=8192 CONFIG_LWIP_PPP_SUPPORT=y +CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y