Restore mutex lock for mbedtls_test_set_step()
This function is called externally from several tests, so still requires
a mutex lock. Add an internal function to reset the step, for use in
functions where the mutex is already held.
Signed-off-by: Paul Elliott <paul.elliott@arm.com>
diff --git a/tests/src/helpers.c b/tests/src/helpers.c
index 936da06..ee87a61 100644
--- a/tests/src/helpers.c
+++ b/tests/src/helpers.c
@@ -144,12 +144,25 @@
return step;
}
-void mbedtls_test_set_step(unsigned long step)
+void mbedtls_test_reset_step(void)
{
/* Internal function only - mbedtls_test_info_mutex should be held prior
* to calling this function. */
+ mbedtls_test_info.step = (unsigned long) (-1);
+}
+
+void mbedtls_test_set_step(unsigned long step)
+{
+#ifdef MBEDTLS_THREADING_C
+ mbedtls_mutex_lock(&mbedtls_test_info_mutex);
+#endif /* MBEDTLS_THREADING_C */
+
mbedtls_test_info.step = step;
+
+#ifdef MBEDTLS_THREADING_C
+ mbedtls_mutex_unlock(&mbedtls_test_info_mutex);
+#endif /* MBEDTLS_THREADING_C */
}
void mbedtls_test_get_line1(char *line)
@@ -366,7 +379,7 @@
#endif /* MBEDTLS_THREADING_C */
mbedtls_test_set_result(MBEDTLS_TEST_RESULT_SUCCESS, 0, 0, 0);
- mbedtls_test_set_step((unsigned long) (-1));
+ mbedtls_test_reset_step();
mbedtls_test_set_line1(NULL);
mbedtls_test_set_line2(NULL);