Merge pull request #10378 from gilles-peskine-arm/threading-1.0-condition-3.6

Smoke tests for threading
This commit is contained in:
Gilles Peskine
2025-09-05 15:52:01 +00:00
committed by GitHub
3 changed files with 41 additions and 1 deletions
@@ -0,0 +1,8 @@
Mutex usage: init, free
mutex_usage_nominal:0
Mutex usage: lock 1
mutex_usage_nominal:1
Mutex usage: lock 2
mutex_usage_nominal:2
@@ -0,0 +1,32 @@
/* 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 */