mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-11-09 14:50:17 +08:00
Merge pull request #10378 from gilles-peskine-arm/threading-1.0-condition-3.6
Smoke tests for threading
This commit is contained in:
commit
c056b64042
@ -1 +1 @@
|
||||
Subproject commit ac0724b16121f01c16b29e50afa24f3a9c05846c
|
||||
Subproject commit bf53c3d027c73d96c3e79c8054ead967055df63b
|
||||
8
tests/suites/test_suite_platform_threading.data
Normal file
8
tests/suites/test_suite_platform_threading.data
Normal file
@ -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
|
||||
32
tests/suites/test_suite_platform_threading.function
Normal file
32
tests/suites/test_suite_platform_threading.function
Normal file
@ -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 */
|
||||
Loading…
x
Reference in New Issue
Block a user