2019-11-15 08:07:57 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "unity.h"
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "freertos/semphr.h"
|
|
|
|
#include "sdkconfig.h"
|
|
|
|
#include "test_utils.h"
|
|
|
|
#include "esp_expression_with_stack.h"
|
|
|
|
|
|
|
|
//makes sure this is not the task stack...
|
2019-12-04 14:25:02 +00:00
|
|
|
void another_external_stack_function(void)
|
2019-11-15 08:07:57 +00:00
|
|
|
{
|
2019-12-04 14:25:02 +00:00
|
|
|
//We can even use Freertos resources inside of this context.
|
|
|
|
vTaskDelay(100);
|
|
|
|
printf("Executing this another printf inside a function with external stack");
|
2019-11-15 08:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_CASE("test printf using shared buffer stack", "[newlib]")
|
|
|
|
{
|
2019-11-15 08:45:18 +00:00
|
|
|
portSTACK_TYPE *shared_stack = malloc(8192 * sizeof(portSTACK_TYPE));
|
|
|
|
|
|
|
|
TEST_ASSERT(shared_stack != NULL);
|
|
|
|
|
2019-11-15 08:07:57 +00:00
|
|
|
SemaphoreHandle_t printf_lock = xSemaphoreCreateMutex();
|
2019-12-20 16:27:30 +00:00
|
|
|
TEST_ASSERT_NOT_NULL(printf_lock);
|
|
|
|
|
2019-12-04 14:25:02 +00:00
|
|
|
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,printf("Executing this printf from external stack! \n"));
|
|
|
|
ESP_EXECUTE_EXPRESSION_WITH_STACK(printf_lock, shared_stack,8192,another_external_stack_function());
|
|
|
|
vSemaphoreDelete(printf_lock);
|
2019-11-15 08:45:18 +00:00
|
|
|
free(shared_stack);
|
2019-11-15 08:07:57 +00:00
|
|
|
}
|