From 24c46c38b48e6c90e33e265871a1317fc17ecb1c Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Thu, 28 Dec 2023 21:32:43 +0100 Subject: [PATCH 1/4] fix(unity-test): Run unity tests in dedicated task Avoid running out of heap --- code/test/test_suite_flowcontroll.cpp | 85 ++++++++++++++++++--------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/code/test/test_suite_flowcontroll.cpp b/code/test/test_suite_flowcontroll.cpp index 8c36cc1a7..c5729f2db 100644 --- a/code/test/test_suite_flowcontroll.cpp +++ b/code/test/test_suite_flowcontroll.cpp @@ -1,10 +1,5 @@ #include -#include "components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp" -#include "components/jomjol-flowcontroll/test_flowpostprocessing.cpp" -#include "components/jomjol-flowcontroll/test_flow_pp_negative.cpp" -#include "components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp" -#include "components/jomjol-flowcontroll/test_getReadoutRawString.cpp" // SD-Card //////////////////// #include "nvs_flash.h" #include "esp_vfs_fat.h" @@ -15,6 +10,18 @@ #define __SD_USE_ONE_LINE_MODE__ #include "server_GPIO.h" + +//***************************************************************************** +// Include files with functions to test +//***************************************************************************** +#include "components/jomjol-flowcontroll/test_flow_postrocess_helper.cpp" +#include "components/jomjol-flowcontroll/test_flowpostprocessing.cpp" +#include "components/jomjol-flowcontroll/test_flow_pp_negative.cpp" +#include "components/jomjol-flowcontroll/test_PointerEvalAnalogToDigitNew.cpp" +#include "components/jomjol-flowcontroll/test_getReadoutRawString.cpp" +#include "components/jomjol-flowcontroll/test_cnnflowcontroll.cpp" + + bool Init_NVS_SDCard() { esp_err_t ret = nvs_flash_init(); @@ -81,7 +88,6 @@ bool Init_NVS_SDCard() } - void initGPIO() { gpio_config_t io_conf; @@ -96,31 +102,56 @@ void initGPIO() } - /** * @brief startup the test. Like a test-suite * all test methods must be called here */ +void task_UnityTesting(void *pvParameter) +{ + UNITY_BEGIN(); + RUN_TEST(test_getReadoutRawString); + printf("---------------------------------------------------------------------------\n"); + + RUN_TEST(test_ZeigerEval); + printf("---------------------------------------------------------------------------\n"); + RUN_TEST(test_ZeigerEvalHybrid); + printf("---------------------------------------------------------------------------\n"); + + RUN_TEST(testNegative_Issues); + printf("---------------------------------------------------------------------------\n"); + RUN_TEST(testNegative); + printf("---------------------------------------------------------------------------\n"); + + RUN_TEST(test_analogToDigit_Standard); + printf("---------------------------------------------------------------------------\n"); + RUN_TEST(test_analogToDigit_Transition); + printf("---------------------------------------------------------------------------\n"); + + RUN_TEST(test_doFlowPP); + printf("---------------------------------------------------------------------------\n"); + RUN_TEST(test_doFlowPP1); + printf("---------------------------------------------------------------------------\n"); + RUN_TEST(test_doFlowPP2); + printf("---------------------------------------------------------------------------\n"); + RUN_TEST(test_doFlowPP3); + printf("---------------------------------------------------------------------------\n"); + RUN_TEST(test_doFlowPP4); + UNITY_END(); + + while(1); +} + + +/** + * @brief main task + */ extern "C" void app_main() { - initGPIO(); - Init_NVS_SDCard(); - esp_log_level_set("*", ESP_LOG_DEBUG); // set all components to ERROR level - - UNITY_BEGIN(); - RUN_TEST(testNegative_Issues); - /* RUN_TEST(testNegative); - - RUN_TEST(test_analogToDigit_Standard); - RUN_TEST(test_analogToDigit_Transition); - RUN_TEST(test_doFlowPP); - RUN_TEST(test_doFlowPP1); - RUN_TEST(test_doFlowPP2); - RUN_TEST(test_doFlowPP3); - RUN_TEST(test_doFlowPP4); - - // getReadoutRawString test - RUN_TEST(test_getReadoutRawString); - */ - UNITY_END(); + initGPIO(); + Init_NVS_SDCard(); + esp_log_level_set("*", ESP_LOG_DEBUG); // set all components to DEBUG level + + // Create dedicated testing task (heap size can be configured - large enough to handle a lot of testing cases) + // ******************************************** + xTaskCreate(&task_UnityTesting, "task_UnityTesting", 12 * 1024, NULL, tskIDLE_PRIORITY+2, NULL); } From 006f3aa0639ab080f56ebe1757b9b7a3efc99d96 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Fri, 29 Dec 2023 09:47:37 +0100 Subject: [PATCH 2/4] Add delay --- code/dependencies.lock | 19 ++++++++++++++++--- code/test/test_suite_flowcontroll.cpp | 2 ++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/code/dependencies.lock b/code/dependencies.lock index 6d9f7a29f..ea29fca35 100644 --- a/code/dependencies.lock +++ b/code/dependencies.lock @@ -1,3 +1,16 @@ -manifest_hash: 63f5c6c9f0bcebc7b9ca12d2aa8b26b2c5f5218d377dc4b2375d9b9ca1df7815 -target: esp32 -version: 1.0.0 +dependencies: + espressif/esp-nn: + component_hash: b32869798bdb40dec6bc99caca48cd65d42f8a9f506b9ab9c598a076f891ede9 + source: + pre_release: true + service_url: https://api.components.espressif.com/ + type: service + version: 1.0.2 + idf: + component_hash: null + source: + type: idf + version: 5.0.2 +manifest_hash: a5f7be33336cfab90d6c2eb74757b616296d8c1e61665336749ed18905905567 +target: esp32 +version: 1.0.0 diff --git a/code/test/test_suite_flowcontroll.cpp b/code/test/test_suite_flowcontroll.cpp index c5729f2db..5f88ef6d2 100644 --- a/code/test/test_suite_flowcontroll.cpp +++ b/code/test/test_suite_flowcontroll.cpp @@ -108,6 +108,8 @@ void initGPIO() */ void task_UnityTesting(void *pvParameter) { + vTaskDelay( 5000 / portTICK_PERIOD_MS ); // 5s delay to ensure established serial connection + UNITY_BEGIN(); RUN_TEST(test_getReadoutRawString); printf("---------------------------------------------------------------------------\n"); From dbf1770016c35cd2ce4541fcc9dd48ba6ca20fe5 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Fri, 29 Dec 2023 09:56:47 +0100 Subject: [PATCH 3/4] Update --- code/dependencies.lock | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/code/dependencies.lock b/code/dependencies.lock index ea29fca35..a112678cd 100644 --- a/code/dependencies.lock +++ b/code/dependencies.lock @@ -1,16 +1,3 @@ -dependencies: - espressif/esp-nn: - component_hash: b32869798bdb40dec6bc99caca48cd65d42f8a9f506b9ab9c598a076f891ede9 - source: - pre_release: true - service_url: https://api.components.espressif.com/ - type: service - version: 1.0.2 - idf: - component_hash: null - source: - type: idf - version: 5.0.2 -manifest_hash: a5f7be33336cfab90d6c2eb74757b616296d8c1e61665336749ed18905905567 +manifest_hash: 63f5c6c9f0bcebc7b9ca12d2aa8b26b2c5f5218d377dc4b2375d9b9ca1df7815 target: esp32 -version: 1.0.0 +version: 1.0.0 \ No newline at end of file From f01b4dbd136796349545209deb57728f3e8ac535 Mon Sep 17 00:00:00 2001 From: Slider0007 Date: Fri, 29 Dec 2023 09:57:59 +0100 Subject: [PATCH 4/4] Update --- code/dependencies.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/dependencies.lock b/code/dependencies.lock index a112678cd..24725511d 100644 --- a/code/dependencies.lock +++ b/code/dependencies.lock @@ -1,3 +1,3 @@ manifest_hash: 63f5c6c9f0bcebc7b9ca12d2aa8b26b2c5f5218d377dc4b2375d9b9ca1df7815 target: esp32 -version: 1.0.0 \ No newline at end of file +version: 1.0.0