Skip to content

Commit 1b03916

Browse files
rgundinashif
authored andcommitted
tests/cmsis_rtos_v1: Test mutex ownership during releasing
Introduce test to check that only the thread which locks the mutex shall be able to release it. Signed-off-by: Rajavardhan Gundi <[email protected]>
1 parent 0aa47a7 commit 1b03916

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tests/cmsis_rtos_v1/src/mutex.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ void tThread_entry_lock_timeout(void const *arg)
101101
status = osMutexWait((osMutexId)arg, TIMEOUT - 100);
102102
zassert_true(status == osErrorTimeoutResource, NULL);
103103

104+
/* At this point, mutex is held by the other thread.
105+
* Trying to release it here should fail.
106+
*/
107+
status = osMutexRelease((osMutexId)arg);
108+
zassert_true(status == osErrorResource, "Mutex unexpectedly released");
109+
104110
/* This delay ensures that the mutex gets released by the other
105111
* thread in the meantime
106112
*/

0 commit comments

Comments
 (0)