Lock test mutex before doing mutex usage check

Although this again should only happen post all threads stopping, guard
this just in case things change.

Signed-off-by: Paul Elliott <paul.elliott@arm.com>
This commit is contained in:
Paul Elliott 2024-02-13 15:36:47 +00:00
parent 114ed5ef1e
commit ba536dc1db

View File

@ -317,6 +317,7 @@ void mbedtls_test_mutex_usage_init(void)
void mbedtls_test_mutex_usage_check(void)
{
if (mutex_functions.lock(&mbedtls_test_mutex_mutex) == 0) {
if (live_mutexes != 0) {
/* A positive number (more init than free) means that a mutex resource
* is leaking (on platforms where a mutex consumes more than the
@ -333,6 +334,9 @@ void mbedtls_test_mutex_usage_check(void)
mbedtls_test_fail("Mutex usage error", __LINE__, __FILE__);
}
mbedtls_test_set_mutex_usage_error(NULL);
mutex_functions.unlock(&mbedtls_test_mutex_mutex);
}
}
void mbedtls_test_mutex_usage_end(void)