2016-11-17 03:36:10 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "freertos/semphr.h"
|
|
|
|
#include "freertos/queue.h"
|
|
|
|
#include "freertos/event_groups.h"
|
|
|
|
#include "unity.h"
|
|
|
|
|
|
|
|
static void task_delete_self(void *param)
|
|
|
|
{
|
|
|
|
printf("Task %p running on core %d. Deleting shortly...\n", xTaskGetCurrentTaskHandle(), xPortGetCoreID());
|
2017-02-27 23:31:40 -05:00
|
|
|
vTaskDelay(5);
|
2016-11-17 03:36:10 -05:00
|
|
|
vTaskDelete(NULL);
|
|
|
|
}
|
|
|
|
|
2017-02-27 23:31:40 -05:00
|
|
|
TEST_CASE("FreeRTOS Delete Tasks", "[freertos]")
|
2016-11-17 03:36:10 -05:00
|
|
|
{
|
2017-02-27 23:31:40 -05:00
|
|
|
uint32_t before_count = uxTaskGetNumberOfTasks();
|
|
|
|
|
2016-11-17 03:36:10 -05:00
|
|
|
xTaskCreatePinnedToCore(task_delete_self, "tsk_self_a", 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);
|
|
|
|
xTaskCreatePinnedToCore(task_delete_self, "tsk_self_a", 4096, NULL, configMAX_PRIORITIES - 1, NULL, 0);
|
2017-02-27 23:31:40 -05:00
|
|
|
TEST_ASSERT_EQUAL(before_count + 2, uxTaskGetNumberOfTasks());
|
2016-11-17 03:36:10 -05:00
|
|
|
vTaskDelay(200 / portTICK_PERIOD_MS);
|
2017-02-27 23:31:40 -05:00
|
|
|
TEST_ASSERT_EQUAL(before_count, uxTaskGetNumberOfTasks());
|
2016-11-17 03:36:10 -05:00
|
|
|
}
|