From 79b72300cfe578c1dec0c32308e7d883093b80c5 Mon Sep 17 00:00:00 2001 From: h0bbl3s Date: Sun, 16 Nov 2025 22:33:55 -0500 Subject: [PATCH 1/8] adding utest documentation --- src/utest/atomic_tc.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/utest/atomic_tc.c b/src/utest/atomic_tc.c index 7322da82337..866fa8b3b64 100644 --- a/src/utest/atomic_tc.c +++ b/src/utest/atomic_tc.c @@ -8,6 +8,34 @@ * 2022-07-27 flybreak the first version * 2023-03-21 WangShun add atomic test * 2023-09-15 xqyjlj change stack size in cpu64 + * 2025-11-16 h0bbl3s Add standardized utest documentation block + */ + +/** + * Test Case Name: Kernel Core Atomic Operations Test + * + * Test Objectives: + * - Validate the functional correctness of the following RT-Thread core atomic operations: + * - rt_atomic_add, rt_atomic_sub, rt_atomic_or, rt_atomic_xor, rt_atomic_and, rt_atomic_exchange, + * - rt_atomic_flag_test_and_set, rt_atomic_flag_clear, rt_atomic_load, rt_atomic_store, + * - rt_atomic_compare_exchange_strong + * - Verify the thread-safety of rt_atomic_add under multi-threaded contention + * + * Test Scenarios: + * - test_atomic_api: A single-thread functional test checking all core atomic operations + * - test_atomic_add: Three concurrent threads, each incrementing a shared counter using rt_atomic_add + * + * Verification Metrics: + * - All assertions in test_atomic_api must pass + * - The final shared counter value in test_atomic_add must be correct + * + * Dependencies: + * - Enable Atomic Test (RT-Thread Utestcases -> Kernel Core -> Atomic Test) + * - Test on any RT-Thread supported platform + * + * Expected Results + * - After executing this test in msh, the expected output should be: + * "[ PASSED ] [ result ] testcase (core.atomic)" */ #include From 11b001e18f0fb0615d8e43532192aef98075431d Mon Sep 17 00:00:00 2001 From: h0bbl3s Date: Sun, 16 Nov 2025 22:51:31 -0500 Subject: [PATCH 2/8] adding utest documentation --- src/utest/atomic_tc.c | 2 +- src/utest/mtsafe_kprint_tc.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/utest/atomic_tc.c b/src/utest/atomic_tc.c index 866fa8b3b64..4cc77edad1c 100644 --- a/src/utest/atomic_tc.c +++ b/src/utest/atomic_tc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006-2021, RT-Thread Development Team + * Copyright (c) 2006-2025, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * diff --git a/src/utest/mtsafe_kprint_tc.c b/src/utest/mtsafe_kprint_tc.c index 5cc22723aff..580cb5c3aa1 100644 --- a/src/utest/mtsafe_kprint_tc.c +++ b/src/utest/mtsafe_kprint_tc.c @@ -1,12 +1,43 @@ /* - * Copyright (c) 2006-2023, RT-Thread Development Team + * Copyright (c) 2006-2025, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2023-12-25 Shell the first version + * 2025-11-16 h0bbl3s Add standardized utest documentation block */ + +/** + * Test Case Name: Kernel Core MT-Safe Kprint Test + * + * Test Objectives: + * - Validate the thread-safety of the rt_kprintf function + * + * Test Scenarios: + * - mtsafe_kprint_tc: Creates 16 concurrent threads, each calling rt_kprintf in a loop to stress test for + * - race conditions and corruptions + * + * Verification Metrics: + * - All 16 threads run to completion (verified by semaphore) + * - The system does not crash or deadlock + * - Console output is not garbled or corrupted + * + * Dependencies: + * - Enable Thread-Safe kprint Test (RT-Thread Utestcases -> Kernel Core -> MT-Safe Kprint Test) + * - RT_USING_THREADSAFE_PRINTF must be enabled (RT-Thread Kernel -> Enable thread safe kernel print service) + * - Note: This test (and thread-safe kprintf) increases scheduler load. The idle thread stack + * - size (RT-Thread Kernel -> The stack size of idle thread) may need to be increased for this test + * - Test on any RT-Thread supported platform + * + * Expected Results: + * - After executing this test in msh each thread prints its id on a single line each loop until it is finished + * - There should be no mixed or overlapping console outputs + * - When complete you should see the output: + * "[ PASSED ] [ result ] testcase (core.mtsafe_kprint)" + */ + #include #include "utest.h" From a46fb1c3775bb99c3948f1bae7ed69c88ebfdea4 Mon Sep 17 00:00:00 2001 From: h0bbl3s Date: Sun, 16 Nov 2025 22:57:23 -0500 Subject: [PATCH 3/8] adding utest documentation --- src/utest/mtsafe_kprint_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utest/mtsafe_kprint_tc.c b/src/utest/mtsafe_kprint_tc.c index 580cb5c3aa1..cf4ccf65e51 100644 --- a/src/utest/mtsafe_kprint_tc.c +++ b/src/utest/mtsafe_kprint_tc.c @@ -25,7 +25,7 @@ * - Console output is not garbled or corrupted * * Dependencies: - * - Enable Thread-Safe kprint Test (RT-Thread Utestcases -> Kernel Core -> MT-Safe Kprint Test) + * - Enable MT-Safe kprint Test (RT-Thread Utestcases -> Kernel Core -> MT-Safe Kprint Test) * - RT_USING_THREADSAFE_PRINTF must be enabled (RT-Thread Kernel -> Enable thread safe kernel print service) * - Note: This test (and thread-safe kprintf) increases scheduler load. The idle thread stack * - size (RT-Thread Kernel -> The stack size of idle thread) may need to be increased for this test From dd05c1429064cec802c7a308a8bd511777b2e846 Mon Sep 17 00:00:00 2001 From: h0bbl3s Date: Sun, 16 Nov 2025 23:00:53 -0500 Subject: [PATCH 4/8] adding utest documentation --- src/utest/mtsafe_kprint_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utest/mtsafe_kprint_tc.c b/src/utest/mtsafe_kprint_tc.c index cf4ccf65e51..4f469447e50 100644 --- a/src/utest/mtsafe_kprint_tc.c +++ b/src/utest/mtsafe_kprint_tc.c @@ -27,7 +27,7 @@ * Dependencies: * - Enable MT-Safe kprint Test (RT-Thread Utestcases -> Kernel Core -> MT-Safe Kprint Test) * - RT_USING_THREADSAFE_PRINTF must be enabled (RT-Thread Kernel -> Enable thread safe kernel print service) - * - Note: This test (and thread-safe kprintf) increases scheduler load. The idle thread stack + * - Note: This test (and MT-safe kprint) increases scheduler load. The idle thread stack * - size (RT-Thread Kernel -> The stack size of idle thread) may need to be increased for this test * - Test on any RT-Thread supported platform * From 0c8e5c7c300d61bd29ec9e30a3f47aa9f3234d67 Mon Sep 17 00:00:00 2001 From: David Frisbee <8747335+h0bbl3s@users.noreply.github.com> Date: Mon, 17 Nov 2025 21:15:30 -0500 Subject: [PATCH 5/8] Update src/utest/atomic_tc.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/utest/atomic_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utest/atomic_tc.c b/src/utest/atomic_tc.c index 4cc77edad1c..6452136eff4 100644 --- a/src/utest/atomic_tc.c +++ b/src/utest/atomic_tc.c @@ -33,7 +33,7 @@ * - Enable Atomic Test (RT-Thread Utestcases -> Kernel Core -> Atomic Test) * - Test on any RT-Thread supported platform * - * Expected Results + * Expected Results: * - After executing this test in msh, the expected output should be: * "[ PASSED ] [ result ] testcase (core.atomic)" */ From 630fa9859f3952525713893568b57a54455e3962 Mon Sep 17 00:00:00 2001 From: David Frisbee <8747335+h0bbl3s@users.noreply.github.com> Date: Mon, 17 Nov 2025 21:31:33 -0500 Subject: [PATCH 6/8] Update src/utest/mtsafe_kprint_tc.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/utest/mtsafe_kprint_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utest/mtsafe_kprint_tc.c b/src/utest/mtsafe_kprint_tc.c index 4f469447e50..d70b08b632f 100644 --- a/src/utest/mtsafe_kprint_tc.c +++ b/src/utest/mtsafe_kprint_tc.c @@ -28,7 +28,7 @@ * - Enable MT-Safe kprint Test (RT-Thread Utestcases -> Kernel Core -> MT-Safe Kprint Test) * - RT_USING_THREADSAFE_PRINTF must be enabled (RT-Thread Kernel -> Enable thread safe kernel print service) * - Note: This test (and MT-safe kprint) increases scheduler load. The idle thread stack - * - size (RT-Thread Kernel -> The stack size of idle thread) may need to be increased for this test + * size (RT-Thread Kernel -> The stack size of idle thread) may need to be increased for this test * - Test on any RT-Thread supported platform * * Expected Results: From 0056fc89387677f0f91c5ba30e3112bfe6463353 Mon Sep 17 00:00:00 2001 From: David Frisbee <8747335+h0bbl3s@users.noreply.github.com> Date: Mon, 17 Nov 2025 21:42:46 -0500 Subject: [PATCH 7/8] Update src/utest/mtsafe_kprint_tc.c --- src/utest/mtsafe_kprint_tc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utest/mtsafe_kprint_tc.c b/src/utest/mtsafe_kprint_tc.c index d70b08b632f..e64fcdfd422 100644 --- a/src/utest/mtsafe_kprint_tc.c +++ b/src/utest/mtsafe_kprint_tc.c @@ -17,7 +17,7 @@ * * Test Scenarios: * - mtsafe_kprint_tc: Creates 16 concurrent threads, each calling rt_kprintf in a loop to stress test for - * - race conditions and corruptions + * race conditions and corruptions * * Verification Metrics: * - All 16 threads run to completion (verified by semaphore) From 34a842fda707f9b741ab71b1b87fcf861f72f958 Mon Sep 17 00:00:00 2001 From: David Frisbee <8747335+h0bbl3s@users.noreply.github.com> Date: Mon, 17 Nov 2025 21:45:29 -0500 Subject: [PATCH 8/8] Update src/utest/atomic_tc.c --- src/utest/atomic_tc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utest/atomic_tc.c b/src/utest/atomic_tc.c index 6452136eff4..ebf050fe0da 100644 --- a/src/utest/atomic_tc.c +++ b/src/utest/atomic_tc.c @@ -16,9 +16,9 @@ * * Test Objectives: * - Validate the functional correctness of the following RT-Thread core atomic operations: - * - rt_atomic_add, rt_atomic_sub, rt_atomic_or, rt_atomic_xor, rt_atomic_and, rt_atomic_exchange, - * - rt_atomic_flag_test_and_set, rt_atomic_flag_clear, rt_atomic_load, rt_atomic_store, - * - rt_atomic_compare_exchange_strong + * rt_atomic_add, rt_atomic_sub, rt_atomic_or, rt_atomic_xor, rt_atomic_and, rt_atomic_exchange, + * rt_atomic_flag_test_and_set, rt_atomic_flag_clear, rt_atomic_load, rt_atomic_store, + * rt_atomic_compare_exchange_strong * - Verify the thread-safety of rt_atomic_add under multi-threaded contention * * Test Scenarios: