1 #include "freertos/FreeRTOS.h" 2 #include "freertos/task.h" 3 #include "freertos/semphr.h" 4 #include "unity.h" 5 #include "test_utils.h" 6 7 /* If assertions aren't set to fail this code still crashes, but not with an abort... */ 8 #if CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER && CONFIG_FREERTOS_ASSERT_FAIL_ABORT 9 mutex_release_task(void * arg)10static void mutex_release_task(void* arg) 11 { 12 SemaphoreHandle_t mutex = (SemaphoreHandle_t) arg; 13 xSemaphoreGive(mutex); 14 TEST_FAIL_MESSAGE("should not be reached"); 15 } 16 17 TEST_CASE("mutex released not by owner causes an assert", "[freertos][reset=assert,SW_CPU_RESET]") 18 { 19 SemaphoreHandle_t mutex = xSemaphoreCreateMutex(); 20 xSemaphoreTake(mutex, portMAX_DELAY); 21 xTaskCreate(&mutex_release_task, "mutex_release", 2048, mutex, UNITY_FREERTOS_PRIORITY + 1, NULL); 22 vTaskDelay(1); 23 } 24 25 #endif 26