From 56c4dc12b805183e97adfc3e3120c3a4f4a9b7f1 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Sun, 31 Aug 2025 18:13:23 +0200 Subject: [PATCH 1/2] Single-threaded test of nominal mutex usage No negative tests since all forbidden usage has undefined behavior. Signed-off-by: Gilles Peskine --- .../suites/test_suite_platform_threading.data | 8 +++++ .../test_suite_platform_threading.function | 32 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/suites/test_suite_platform_threading.data create mode 100644 tests/suites/test_suite_platform_threading.function diff --git a/tests/suites/test_suite_platform_threading.data b/tests/suites/test_suite_platform_threading.data new file mode 100644 index 0000000000..d5d92b32cf --- /dev/null +++ b/tests/suites/test_suite_platform_threading.data @@ -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 diff --git a/tests/suites/test_suite_platform_threading.function b/tests/suites/test_suite_platform_threading.function new file mode 100644 index 0000000000..8a712b6720 --- /dev/null +++ b/tests/suites/test_suite_platform_threading.function @@ -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 */ From 4c40f081486713e1b354ff7a63f1ff42bf0888c9 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 1 Sep 2025 00:55:59 +0200 Subject: [PATCH 2/2] Update framework: support threading internal interface 4.0.0.0 3.6 is still using the threading internal interface 3.6.0.0 for now. Signed-off-by: Gilles Peskine --- framework | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework b/framework index ac0724b161..bf53c3d027 160000 --- a/framework +++ b/framework @@ -1 +1 @@ -Subproject commit ac0724b16121f01c16b29e50afa24f3a9c05846c +Subproject commit bf53c3d027c73d96c3e79c8054ead967055df63b