Skip to content

Commit c056b64

Browse files
Merge pull request #10378 from gilles-peskine-arm/threading-1.0-condition-3.6
Smoke tests for threading
2 parents e0ef179 + 4c40f08 commit c056b64

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Mutex usage: init, free
2+
mutex_usage_nominal:0
3+
4+
Mutex usage: lock 1
5+
mutex_usage_nominal:1
6+
7+
Mutex usage: lock 2
8+
mutex_usage_nominal:2
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* BEGIN_HEADER */
2+
/* Basic tests for the threading interface.
3+
*/
4+
5+
#include "mbedtls/threading.h"
6+
7+
#include "test/threading_helpers.h"
8+
9+
/* END_HEADER */
10+
11+
/* BEGIN_DEPENDENCIES
12+
* depends_on:MBEDTLS_THREADING_C
13+
* END_DEPENDENCIES
14+
*/
15+
16+
/* BEGIN_CASE */
17+
void mutex_usage_nominal(int lock_cycles)
18+
{
19+
mbedtls_threading_mutex_t mutex;
20+
21+
mbedtls_mutex_init(&mutex);
22+
23+
for (int i = 0; i < lock_cycles; i++) {
24+
mbedtls_test_set_step(i);
25+
TEST_EQUAL(mbedtls_mutex_lock(&mutex), 0);
26+
TEST_EQUAL(mbedtls_mutex_unlock(&mutex), 0);
27+
}
28+
29+
exit:
30+
mbedtls_mutex_free(&mutex);
31+
}
32+
/* END_CASE */

0 commit comments

Comments
 (0)