2018-12-20 23:49:33 -05:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include "freertos/semphr.h"
|
|
|
|
#include "unity.h"
|
|
|
|
#include "test_utils.h"
|
|
|
|
|
2020-10-15 22:58:11 -04:00
|
|
|
/* If assertions aren't set to fail this code still crashes, but not with an abort... */
|
|
|
|
#if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER && CONFIG_FREERTOS_ASSERT_FAIL_ABORT
|
|
|
|
|
2018-12-20 23:49:33 -05:00
|
|
|
static void mutex_release_task(void* arg)
|
|
|
|
{
|
|
|
|
SemaphoreHandle_t mutex = (SemaphoreHandle_t) arg;
|
|
|
|
xSemaphoreGive(mutex);
|
|
|
|
TEST_FAIL_MESSAGE("should not be reached");
|
|
|
|
}
|
|
|
|
|
2021-06-28 08:18:43 -04:00
|
|
|
TEST_CASE("mutex released not by owner causes an assert", "[freertos][reset=assert,SW_CPU_RESET]")
|
2018-12-20 23:49:33 -05:00
|
|
|
{
|
|
|
|
SemaphoreHandle_t mutex = xSemaphoreCreateMutex();
|
|
|
|
xSemaphoreTake(mutex, portMAX_DELAY);
|
|
|
|
xTaskCreate(&mutex_release_task, "mutex_release", 2048, mutex, UNITY_FREERTOS_PRIORITY + 1, NULL);
|
|
|
|
vTaskDelay(1);
|
|
|
|
}
|
2020-10-15 22:58:11 -04:00
|
|
|
|
|
|
|
#endif
|