Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/utest/atomic_tc.c
Original file line number Diff line number Diff line change
@@ -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
*
Expand All @@ -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 <rtthread.h>
Expand Down
33 changes: 32 additions & 1 deletion src/utest/mtsafe_kprint_tc.c
Original file line number Diff line number Diff line change
@@ -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 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
* - 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 <rtthread.h>
#include "utest.h"

Expand Down