2022-09-07 06:53:54 -04:00
|
|
|
/*
|
2023-10-20 02:02:35 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
2022-09-07 06:53:54 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
|
|
*/
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
2022-09-09 05:23:55 -04:00
|
|
|
#include "unity.h"
|
2023-10-20 02:02:35 -04:00
|
|
|
#include "mbedtls/aes.h"
|
2022-09-09 05:23:55 -04:00
|
|
|
#include "memory_checks.h"
|
2023-10-20 02:02:35 -04:00
|
|
|
#include "soc/soc_caps.h"
|
2022-09-09 05:23:55 -04:00
|
|
|
|
|
|
|
/* setUp runs before every test */
|
|
|
|
void setUp(void)
|
|
|
|
{
|
2023-10-20 02:02:35 -04:00
|
|
|
// Execute mbedtls_aes_init operation to allocate AES interrupt
|
|
|
|
// allocation memory which is considered as leak otherwise
|
|
|
|
#if SOC_AES_SUPPORTED
|
|
|
|
mbedtls_aes_context ctx;
|
|
|
|
mbedtls_aes_init(&ctx);
|
|
|
|
#endif // SOC_AES_SUPPORTED
|
|
|
|
|
2022-09-09 05:23:55 -04:00
|
|
|
test_utils_record_free_mem();
|
|
|
|
test_utils_set_leak_level(CONFIG_UNITY_CRITICAL_LEAK_LEVEL_GENERAL, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_GENERAL);
|
|
|
|
test_utils_set_leak_level(CONFIG_UNITY_WARN_LEAK_LEVEL_GENERAL, ESP_LEAK_TYPE_WARNING, ESP_COMP_LEAK_GENERAL);
|
|
|
|
test_utils_set_leak_level(0, ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_LWIP);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* tearDown runs after every test */
|
|
|
|
void tearDown(void)
|
|
|
|
{
|
|
|
|
/* some FreeRTOS stuff is cleaned up by idle task */
|
|
|
|
vTaskDelay(5);
|
|
|
|
|
|
|
|
/* clean up some of the newlib's lazy allocations */
|
|
|
|
esp_reent_cleanup();
|
|
|
|
|
|
|
|
/* check if unit test has caused heap corruption in any heap */
|
|
|
|
TEST_ASSERT_MESSAGE( heap_caps_check_integrity(MALLOC_CAP_INVALID, true), "The test has corrupted the heap");
|
|
|
|
|
|
|
|
test_utils_finish_and_evaluate_leaks(test_utils_get_leak_level(ESP_LEAK_TYPE_WARNING, ESP_COMP_LEAK_ALL),
|
|
|
|
test_utils_get_leak_level(ESP_LEAK_TYPE_CRITICAL, ESP_COMP_LEAK_ALL));
|
|
|
|
|
|
|
|
}
|
2022-09-07 06:53:54 -04:00
|
|
|
|
|
|
|
static void test_task(void *pvParameters)
|
|
|
|
{
|
|
|
|
vTaskDelay(2); /* Delay a bit to let the main task be deleted */
|
|
|
|
unity_run_menu();
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_main(void)
|
|
|
|
{
|
2022-09-09 05:23:55 -04:00
|
|
|
xTaskCreatePinnedToCore(test_task, "testTask", CONFIG_UNITY_FREERTOS_STACK_SIZE, NULL, CONFIG_UNITY_FREERTOS_PRIORITY, NULL, CONFIG_UNITY_FREERTOS_CPU);
|
2022-09-07 06:53:54 -04:00
|
|
|
}
|