-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
freertos: check that mutex is released by owner task
Mutex type semaphores should be acquired and released by the same task. Add a check to xQueueGenericSend for this condition.
- Loading branch information
1 parent
fc4823c
commit 13523c9
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "freertos/semphr.h" | ||
#include "unity.h" | ||
#include "esp_ipc.h" | ||
#include "test_utils.h" | ||
|
||
static void mutex_release_task(void* arg) | ||
{ | ||
SemaphoreHandle_t mutex = (SemaphoreHandle_t) arg; | ||
xSemaphoreGive(mutex); | ||
TEST_FAIL_MESSAGE("should not be reached"); | ||
} | ||
|
||
TEST_CASE("mutex released not by owner causes an assert", "[freertos][reset=abort,SW_CPU_RESET]") | ||
{ | ||
SemaphoreHandle_t mutex = xSemaphoreCreateMutex(); | ||
xSemaphoreTake(mutex, portMAX_DELAY); | ||
xTaskCreate(&mutex_release_task, "mutex_release", 2048, mutex, UNITY_FREERTOS_PRIORITY + 1, NULL); | ||
vTaskDelay(1); | ||
} |