File: test_suite_platform_threading.function

package info (click to toggle)
mbedtls 3.6.5-0.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,488 kB
  • sloc: ansic: 164,842; sh: 25,443; python: 15,512; makefile: 3,131; perl: 1,043; tcl: 4
file content (32 lines) | stat: -rw-r--r-- 612 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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 */