1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-10-23 01:52:40 +03:00
Files
mbedtls/tests/suites/test_suite_platform_threading.function
Gilles Peskine 56c4dc12b8 Single-threaded test of nominal mutex usage
No negative tests since all forbidden usage has undefined behavior.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
2025-09-01 00:28:15 +02:00

33 lines
612 B
C

/* BEGIN_HEADER */
/* Basic tests for the threading interface.
*/
#include "mbedtls/threading.h"
#include "test/threading_helpers.h"
/* END_HEADER */
/* BEGIN_DEPENDENCIES
* depends_on:MBEDTLS_THREADING_C
* END_DEPENDENCIES
*/
/* BEGIN_CASE */
void mutex_usage_nominal(int lock_cycles)
{
mbedtls_threading_mutex_t mutex;
mbedtls_mutex_init(&mutex);
for (int i = 0; i < lock_cycles; i++) {
mbedtls_test_set_step(i);
TEST_EQUAL(mbedtls_mutex_lock(&mutex), 0);
TEST_EQUAL(mbedtls_mutex_unlock(&mutex), 0);
}
exit:
mbedtls_mutex_free(&mutex);
}
/* END_CASE */