From ede30f0a8734bc5be93a5683fdb2a8175be1aa05 Mon Sep 17 00:00:00 2001 From: CYFS <2805686936@qq.com> Date: Thu, 11 Jun 2026 14:40:29 +0800 Subject: [PATCH 1/5] utest: move mm testcases to components/mm Signed-off-by: CYFS <2805686936@qq.com> --- Kconfig.utestcases | 2 +- components/mm/SConscript | 2 ++ {examples/utest/testcases/mm => components/mm/utest}/Kconfig | 0 {examples/utest/testcases/mm => components/mm/utest}/SConscript | 0 .../testcases/mm => components/mm/utest}/aspace_map_expand.c | 0 .../mm/utest}/aspace_unmap_range_invalid_param.c | 0 .../mm => components/mm/utest}/aspace_unmap_range_shrink.c | 0 .../mm => components/mm/utest}/aspace_unmap_range_split.c | 0 {examples/utest/testcases/mm => components/mm/utest}/common.h | 0 .../testcases/mm => components/mm/utest}/lwp_mmap_expand.c | 0 .../utest/testcases/mm => components/mm/utest}/lwp_mmap_fd.c | 0 .../mm => components/mm/utest}/lwp_mmap_fd_map_fixed_merge.c | 0 .../mm => components/mm/utest}/lwp_mmap_fd_map_fixed_split.c | 0 .../testcases/mm => components/mm/utest}/lwp_mmap_fix_private.c | 0 .../testcases/mm => components/mm/utest}/lwp_mmap_map_fixed.c | 0 .../utest/testcases/mm => components/mm/utest}/mm_api_tc.c | 0 .../utest/testcases/mm => components/mm/utest}/mm_libcpu_tc.c | 0 .../utest/testcases/mm => components/mm/utest}/mm_lwp_tc.c | 0 .../utest/testcases/mm => components/mm/utest}/mm_memblock_tc.c | 0 .../utest/testcases/mm => components/mm/utest}/rt_ioremap.c | 0 .../utest/testcases/mm => components/mm/utest}/semaphore.h | 0 .../testcases/mm => components/mm/utest}/test_aspace_api.h | 0 .../mm => components/mm/utest}/test_aspace_api_internal.h | 0 .../utest/testcases/mm => components/mm/utest}/test_bst_adpt.h | 0 .../testcases/mm => components/mm/utest}/test_cache_aarch64.h | 0 .../testcases/mm => components/mm/utest}/test_cache_rv64.h | 0 .../testcases/mm => components/mm/utest}/test_synchronization.h | 0 27 files changed, 3 insertions(+), 1 deletion(-) rename {examples/utest/testcases/mm => components/mm/utest}/Kconfig (100%) rename {examples/utest/testcases/mm => components/mm/utest}/SConscript (100%) rename {examples/utest/testcases/mm => components/mm/utest}/aspace_map_expand.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/aspace_unmap_range_invalid_param.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/aspace_unmap_range_shrink.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/aspace_unmap_range_split.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/common.h (100%) rename {examples/utest/testcases/mm => components/mm/utest}/lwp_mmap_expand.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/lwp_mmap_fd.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/lwp_mmap_fd_map_fixed_merge.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/lwp_mmap_fd_map_fixed_split.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/lwp_mmap_fix_private.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/lwp_mmap_map_fixed.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/mm_api_tc.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/mm_libcpu_tc.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/mm_lwp_tc.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/mm_memblock_tc.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/rt_ioremap.c (100%) rename {examples/utest/testcases/mm => components/mm/utest}/semaphore.h (100%) rename {examples/utest/testcases/mm => components/mm/utest}/test_aspace_api.h (100%) rename {examples/utest/testcases/mm => components/mm/utest}/test_aspace_api_internal.h (100%) rename {examples/utest/testcases/mm => components/mm/utest}/test_bst_adpt.h (100%) rename {examples/utest/testcases/mm => components/mm/utest}/test_cache_aarch64.h (100%) rename {examples/utest/testcases/mm => components/mm/utest}/test_cache_rv64.h (100%) rename {examples/utest/testcases/mm => components/mm/utest}/test_synchronization.h (100%) diff --git a/Kconfig.utestcases b/Kconfig.utestcases index 69a8a43885a..64162324b6a 100644 --- a/Kconfig.utestcases +++ b/Kconfig.utestcases @@ -22,12 +22,12 @@ menu "RT-Thread Utestcases" rsource "components/dfs/utest/Kconfig" rsource "components/libc/cplusplus/utest/Kconfig" + rsource "components/mm/utest/Kconfig" rsource "components/net/utest/Kconfig" rsource "components/utilities/utest/utest/Kconfig" endmenu - rsource "examples/utest/testcases/mm/Kconfig" rsource "examples/utest/testcases/tmpfs/Kconfig" endif diff --git a/components/mm/SConscript b/components/mm/SConscript index 39e4f6bbcfa..5b259fee107 100644 --- a/components/mm/SConscript +++ b/components/mm/SConscript @@ -13,4 +13,6 @@ if GetDepend('ARCH_ARM_CORTEX_A') or GetDepend('ARCH_ARMV8') or GetDepend('ARCH_ group = DefineGroup('Memm', src, depend = ['ARCH_MM_MMU'], CPPPATH = CPPPATH) +group = group + SConscript(os.path.join('utest', 'SConscript')) + Return('group') diff --git a/examples/utest/testcases/mm/Kconfig b/components/mm/utest/Kconfig similarity index 100% rename from examples/utest/testcases/mm/Kconfig rename to components/mm/utest/Kconfig diff --git a/examples/utest/testcases/mm/SConscript b/components/mm/utest/SConscript similarity index 100% rename from examples/utest/testcases/mm/SConscript rename to components/mm/utest/SConscript diff --git a/examples/utest/testcases/mm/aspace_map_expand.c b/components/mm/utest/aspace_map_expand.c similarity index 100% rename from examples/utest/testcases/mm/aspace_map_expand.c rename to components/mm/utest/aspace_map_expand.c diff --git a/examples/utest/testcases/mm/aspace_unmap_range_invalid_param.c b/components/mm/utest/aspace_unmap_range_invalid_param.c similarity index 100% rename from examples/utest/testcases/mm/aspace_unmap_range_invalid_param.c rename to components/mm/utest/aspace_unmap_range_invalid_param.c diff --git a/examples/utest/testcases/mm/aspace_unmap_range_shrink.c b/components/mm/utest/aspace_unmap_range_shrink.c similarity index 100% rename from examples/utest/testcases/mm/aspace_unmap_range_shrink.c rename to components/mm/utest/aspace_unmap_range_shrink.c diff --git a/examples/utest/testcases/mm/aspace_unmap_range_split.c b/components/mm/utest/aspace_unmap_range_split.c similarity index 100% rename from examples/utest/testcases/mm/aspace_unmap_range_split.c rename to components/mm/utest/aspace_unmap_range_split.c diff --git a/examples/utest/testcases/mm/common.h b/components/mm/utest/common.h similarity index 100% rename from examples/utest/testcases/mm/common.h rename to components/mm/utest/common.h diff --git a/examples/utest/testcases/mm/lwp_mmap_expand.c b/components/mm/utest/lwp_mmap_expand.c similarity index 100% rename from examples/utest/testcases/mm/lwp_mmap_expand.c rename to components/mm/utest/lwp_mmap_expand.c diff --git a/examples/utest/testcases/mm/lwp_mmap_fd.c b/components/mm/utest/lwp_mmap_fd.c similarity index 100% rename from examples/utest/testcases/mm/lwp_mmap_fd.c rename to components/mm/utest/lwp_mmap_fd.c diff --git a/examples/utest/testcases/mm/lwp_mmap_fd_map_fixed_merge.c b/components/mm/utest/lwp_mmap_fd_map_fixed_merge.c similarity index 100% rename from examples/utest/testcases/mm/lwp_mmap_fd_map_fixed_merge.c rename to components/mm/utest/lwp_mmap_fd_map_fixed_merge.c diff --git a/examples/utest/testcases/mm/lwp_mmap_fd_map_fixed_split.c b/components/mm/utest/lwp_mmap_fd_map_fixed_split.c similarity index 100% rename from examples/utest/testcases/mm/lwp_mmap_fd_map_fixed_split.c rename to components/mm/utest/lwp_mmap_fd_map_fixed_split.c diff --git a/examples/utest/testcases/mm/lwp_mmap_fix_private.c b/components/mm/utest/lwp_mmap_fix_private.c similarity index 100% rename from examples/utest/testcases/mm/lwp_mmap_fix_private.c rename to components/mm/utest/lwp_mmap_fix_private.c diff --git a/examples/utest/testcases/mm/lwp_mmap_map_fixed.c b/components/mm/utest/lwp_mmap_map_fixed.c similarity index 100% rename from examples/utest/testcases/mm/lwp_mmap_map_fixed.c rename to components/mm/utest/lwp_mmap_map_fixed.c diff --git a/examples/utest/testcases/mm/mm_api_tc.c b/components/mm/utest/mm_api_tc.c similarity index 100% rename from examples/utest/testcases/mm/mm_api_tc.c rename to components/mm/utest/mm_api_tc.c diff --git a/examples/utest/testcases/mm/mm_libcpu_tc.c b/components/mm/utest/mm_libcpu_tc.c similarity index 100% rename from examples/utest/testcases/mm/mm_libcpu_tc.c rename to components/mm/utest/mm_libcpu_tc.c diff --git a/examples/utest/testcases/mm/mm_lwp_tc.c b/components/mm/utest/mm_lwp_tc.c similarity index 100% rename from examples/utest/testcases/mm/mm_lwp_tc.c rename to components/mm/utest/mm_lwp_tc.c diff --git a/examples/utest/testcases/mm/mm_memblock_tc.c b/components/mm/utest/mm_memblock_tc.c similarity index 100% rename from examples/utest/testcases/mm/mm_memblock_tc.c rename to components/mm/utest/mm_memblock_tc.c diff --git a/examples/utest/testcases/mm/rt_ioremap.c b/components/mm/utest/rt_ioremap.c similarity index 100% rename from examples/utest/testcases/mm/rt_ioremap.c rename to components/mm/utest/rt_ioremap.c diff --git a/examples/utest/testcases/mm/semaphore.h b/components/mm/utest/semaphore.h similarity index 100% rename from examples/utest/testcases/mm/semaphore.h rename to components/mm/utest/semaphore.h diff --git a/examples/utest/testcases/mm/test_aspace_api.h b/components/mm/utest/test_aspace_api.h similarity index 100% rename from examples/utest/testcases/mm/test_aspace_api.h rename to components/mm/utest/test_aspace_api.h diff --git a/examples/utest/testcases/mm/test_aspace_api_internal.h b/components/mm/utest/test_aspace_api_internal.h similarity index 100% rename from examples/utest/testcases/mm/test_aspace_api_internal.h rename to components/mm/utest/test_aspace_api_internal.h diff --git a/examples/utest/testcases/mm/test_bst_adpt.h b/components/mm/utest/test_bst_adpt.h similarity index 100% rename from examples/utest/testcases/mm/test_bst_adpt.h rename to components/mm/utest/test_bst_adpt.h diff --git a/examples/utest/testcases/mm/test_cache_aarch64.h b/components/mm/utest/test_cache_aarch64.h similarity index 100% rename from examples/utest/testcases/mm/test_cache_aarch64.h rename to components/mm/utest/test_cache_aarch64.h diff --git a/examples/utest/testcases/mm/test_cache_rv64.h b/components/mm/utest/test_cache_rv64.h similarity index 100% rename from examples/utest/testcases/mm/test_cache_rv64.h rename to components/mm/utest/test_cache_rv64.h diff --git a/examples/utest/testcases/mm/test_synchronization.h b/components/mm/utest/test_synchronization.h similarity index 100% rename from examples/utest/testcases/mm/test_synchronization.h rename to components/mm/utest/test_synchronization.h From cad4eb38c36fd59203ff6cc81da9fb65f393f0a8 Mon Sep 17 00:00:00 2001 From: CYFS <2805686936@qq.com> Date: Thu, 11 Jun 2026 14:40:55 +0800 Subject: [PATCH 2/5] utest: move tmpfs testcases to components/dfs Signed-off-by: CYFS <2805686936@qq.com> --- Kconfig.utestcases | 2 +- components/dfs/dfs_v2/filesystems/tmpfs/SConscript | 3 +++ .../dfs/dfs_v2/filesystems/tmpfs/utest}/Kconfig | 0 .../dfs/dfs_v2/filesystems/tmpfs/utest}/SConscript | 0 .../dfs/dfs_v2/filesystems/tmpfs/utest}/tmpfs.c | 0 5 files changed, 4 insertions(+), 1 deletion(-) rename {examples/utest/testcases/tmpfs => components/dfs/dfs_v2/filesystems/tmpfs/utest}/Kconfig (100%) rename {examples/utest/testcases/tmpfs => components/dfs/dfs_v2/filesystems/tmpfs/utest}/SConscript (100%) rename {examples/utest/testcases/tmpfs => components/dfs/dfs_v2/filesystems/tmpfs/utest}/tmpfs.c (100%) diff --git a/Kconfig.utestcases b/Kconfig.utestcases index 64162324b6a..909487dea0c 100644 --- a/Kconfig.utestcases +++ b/Kconfig.utestcases @@ -21,6 +21,7 @@ menu "RT-Thread Utestcases" endmenu rsource "components/dfs/utest/Kconfig" + rsource "components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig" rsource "components/libc/cplusplus/utest/Kconfig" rsource "components/mm/utest/Kconfig" rsource "components/net/utest/Kconfig" @@ -28,7 +29,6 @@ menu "RT-Thread Utestcases" endmenu - rsource "examples/utest/testcases/tmpfs/Kconfig" endif diff --git a/components/dfs/dfs_v2/filesystems/tmpfs/SConscript b/components/dfs/dfs_v2/filesystems/tmpfs/SConscript index c94a9bcff06..a120db0364d 100644 --- a/components/dfs/dfs_v2/filesystems/tmpfs/SConscript +++ b/components/dfs/dfs_v2/filesystems/tmpfs/SConscript @@ -1,4 +1,5 @@ from building import * +import os cwd = GetCurrentDir() src = Glob('*.c') @@ -6,4 +7,6 @@ CPPPATH = [cwd] group = DefineGroup('Filesystem', src, depend = ['RT_USING_DFS', 'RT_USING_DFS_TMPFS'], CPPPATH = CPPPATH) +group = group + SConscript(os.path.join('utest', 'SConscript')) + Return('group') diff --git a/examples/utest/testcases/tmpfs/Kconfig b/components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig similarity index 100% rename from examples/utest/testcases/tmpfs/Kconfig rename to components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig diff --git a/examples/utest/testcases/tmpfs/SConscript b/components/dfs/dfs_v2/filesystems/tmpfs/utest/SConscript similarity index 100% rename from examples/utest/testcases/tmpfs/SConscript rename to components/dfs/dfs_v2/filesystems/tmpfs/utest/SConscript diff --git a/examples/utest/testcases/tmpfs/tmpfs.c b/components/dfs/dfs_v2/filesystems/tmpfs/utest/tmpfs.c similarity index 100% rename from examples/utest/testcases/tmpfs/tmpfs.c rename to components/dfs/dfs_v2/filesystems/tmpfs/utest/tmpfs.c From dfa8d9d09183009cd2e7b25ca0f2a101e4ccc9e9 Mon Sep 17 00:00:00 2001 From: CYFS <2805686936@qq.com> Date: Thu, 11 Jun 2026 14:41:40 +0800 Subject: [PATCH 3/5] utest: move lwp testcases to components/lwp Signed-off-by: CYFS <2805686936@qq.com> --- Kconfig.utestcases | 2 +- components/lwp/SConscript | 1 + components/lwp/utest/Kconfig | 8 ++++++++ .../lwp => components/lwp/utest}/SConscript | 2 +- .../lwp/utest}/condvar_broadcast_tc.c | 0 .../lwp/utest}/condvar_signal_tc.c | 0 .../lwp/utest}/condvar_timedwait_tc.c | 0 examples/utest/README.md | 3 +-- examples/utest/testcases/SConscript | 15 --------------- tools/building.py | 6 ------ 10 files changed, 12 insertions(+), 25 deletions(-) create mode 100644 components/lwp/utest/Kconfig rename {examples/utest/testcases/lwp => components/lwp/utest}/SConscript (85%) rename {examples/utest/testcases/lwp => components/lwp/utest}/condvar_broadcast_tc.c (100%) rename {examples/utest/testcases/lwp => components/lwp/utest}/condvar_signal_tc.c (100%) rename {examples/utest/testcases/lwp => components/lwp/utest}/condvar_timedwait_tc.c (100%) delete mode 100644 examples/utest/testcases/SConscript diff --git a/Kconfig.utestcases b/Kconfig.utestcases index 909487dea0c..de283e5e810 100644 --- a/Kconfig.utestcases +++ b/Kconfig.utestcases @@ -23,13 +23,13 @@ menu "RT-Thread Utestcases" rsource "components/dfs/utest/Kconfig" rsource "components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig" rsource "components/libc/cplusplus/utest/Kconfig" + rsource "components/lwp/utest/Kconfig" rsource "components/mm/utest/Kconfig" rsource "components/net/utest/Kconfig" rsource "components/utilities/utest/utest/Kconfig" endmenu - endif endmenu diff --git a/components/lwp/SConscript b/components/lwp/SConscript index 56279cb9980..1c97444e514 100644 --- a/components/lwp/SConscript +++ b/components/lwp/SConscript @@ -57,4 +57,5 @@ if not GetDepend(['LWP_USING_RUNTIME']): group = DefineGroup('lwProcess', src, depend = ['RT_USING_SMART'], CPPPATH = CPPPATH) group = group + SConscript(os.path.join('vdso', 'SConscript')) +group = group + SConscript(os.path.join('utest', 'SConscript')) Return('group') diff --git a/components/lwp/utest/Kconfig b/components/lwp/utest/Kconfig new file mode 100644 index 00000000000..ac2900d93a8 --- /dev/null +++ b/components/lwp/utest/Kconfig @@ -0,0 +1,8 @@ +menu "LWP Testcase" + +config RT_UTEST_LWP + bool "Enable LWP condvar test" + depends on RT_USING_SMART + default n + +endmenu diff --git a/examples/utest/testcases/lwp/SConscript b/components/lwp/utest/SConscript similarity index 85% rename from examples/utest/testcases/lwp/SConscript rename to components/lwp/utest/SConscript index 68fe5bea41a..c7890d6be78 100644 --- a/examples/utest/testcases/lwp/SConscript +++ b/components/lwp/utest/SConscript @@ -5,7 +5,7 @@ cwd = GetCurrentDir() src = [] CPPPATH = [cwd] -if GetDepend(['UTEST_LWP_TC', 'RT_USING_SMART']): +if GetDepend(['RT_UTEST_LWP', 'RT_USING_SMART']): src += ['condvar_timedwait_tc.c', 'condvar_broadcast_tc.c', 'condvar_signal_tc.c'] group = DefineGroup('utestcases', src, depend = ['RT_USING_UTESTCASES'], CPPPATH = CPPPATH) diff --git a/examples/utest/testcases/lwp/condvar_broadcast_tc.c b/components/lwp/utest/condvar_broadcast_tc.c similarity index 100% rename from examples/utest/testcases/lwp/condvar_broadcast_tc.c rename to components/lwp/utest/condvar_broadcast_tc.c diff --git a/examples/utest/testcases/lwp/condvar_signal_tc.c b/components/lwp/utest/condvar_signal_tc.c similarity index 100% rename from examples/utest/testcases/lwp/condvar_signal_tc.c rename to components/lwp/utest/condvar_signal_tc.c diff --git a/examples/utest/testcases/lwp/condvar_timedwait_tc.c b/components/lwp/utest/condvar_timedwait_tc.c similarity index 100% rename from examples/utest/testcases/lwp/condvar_timedwait_tc.c rename to components/lwp/utest/condvar_timedwait_tc.c diff --git a/examples/utest/README.md b/examples/utest/README.md index 04c3f910f17..f21884b5b76 100644 --- a/examples/utest/README.md +++ b/examples/utest/README.md @@ -9,13 +9,12 @@ | 目录 | 用途 | | --------- | ------------------------------------------------------------ | | configs | 配置文件集合(每一个目录代表一种功能集合,如:kernel,net等) | -| testcases | 测试用例源代码 | ## 如何贡献 ### 1. 编写测试用例 -参考已有的测试用例在 [examples\utest\testcases](./testcases) 目录下添加自己的测试用例。测试用例的编写方法参考文档中心[《utest 测试框架》章节](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/utest/utest)。 +参考已有的测试用例,在对应模块目录下添加 `utest` 目录并维护自己的测试用例,例如串口测试用例位于 `components/drivers/serial/utest`。测试用例的编写方法参考文档中心[《utest 测试框架》章节](https://www.rt-thread.org/document/site/#/rt-thread-version/rt-thread-standard/programming-manual/utest/utest)。 ### 2. 本地测试 diff --git a/examples/utest/testcases/SConscript b/examples/utest/testcases/SConscript deleted file mode 100644 index 4c815c49b83..00000000000 --- a/examples/utest/testcases/SConscript +++ /dev/null @@ -1,15 +0,0 @@ -# RT-Thread building script for bridge - -import os -from building import * - -cwd = GetCurrentDir() -objs = [] -list = os.listdir(cwd) - -for d in list: - path = os.path.join(cwd, d) - if os.path.isfile(os.path.join(path, 'SConscript')): - objs = objs + SConscript(os.path.join(d, 'SConscript')) - -Return('objs') diff --git a/tools/building.py b/tools/building.py index 801db1aa4d3..6f0eb78775e 100644 --- a/tools/building.py +++ b/tools/building.py @@ -386,12 +386,6 @@ def PrepareBuilding(env, root_directory, has_libcpu=False, remove_components = [ variant_dir=kernel_vdir + '/components', duplicate=0, exports='remove_components')) - # include testcases - if os.path.isfile(os.path.join(Rtt_Root, 'examples/utest/testcases/SConscript')): - objs.extend(SConscript(Rtt_Root + '/examples/utest/testcases/SConscript', - variant_dir=kernel_vdir + '/examples/utest/testcases', - duplicate=0)) - return objs def PrepareModuleBuilding(env, root_directory, bsp_directory): From e95513db8e357594514728bfbe07f9e290113eed Mon Sep 17 00:00:00 2001 From: CYFS <2805686936@qq.com> Date: Thu, 11 Jun 2026 15:51:46 +0800 Subject: [PATCH 4/5] utest: move utestcases Kconfig to utest component Signed-off-by: CYFS <2805686936@qq.com> --- Kconfig | 2 +- Kconfig.utestcases | 35 ------------------- components/utilities/utest/Kconfig | 35 +++++++++++++++++++ .../utilities}/utest/README.md | 14 ++++---- documentation/6.components/utest/utest.md | 4 +-- tools/env_utility.py | 6 ++-- tools/mkdist.py | 9 +++-- 7 files changed, 55 insertions(+), 50 deletions(-) delete mode 100644 Kconfig.utestcases create mode 100644 components/utilities/utest/Kconfig rename {examples => components/utilities}/utest/README.md (74%) diff --git a/Kconfig b/Kconfig index a7a7758f671..ac6a1d6310f 100644 --- a/Kconfig +++ b/Kconfig @@ -1,4 +1,4 @@ rsource "src/Kconfig" rsource "libcpu/Kconfig" rsource "components/Kconfig" -rsource "Kconfig.utestcases" +rsource "components/utilities/utest/Kconfig" diff --git a/Kconfig.utestcases b/Kconfig.utestcases deleted file mode 100644 index de283e5e810..00000000000 --- a/Kconfig.utestcases +++ /dev/null @@ -1,35 +0,0 @@ -menu "RT-Thread Utestcases" - - config RT_USING_UTESTCASES - bool "RT-Thread Utestcases" - default n - select RT_USING_UTEST - select RT_USING_DEBUG if !RT_USING_ULOG - - if RT_USING_UTESTCASES - - rsource "src/utest/Kconfig" - - menu "Kernel Components" - - menu "Drivers" - rsource "components/drivers/core/utest/Kconfig" - rsource "components/drivers/audio/utest/Kconfig" - rsource "components/drivers/ipc/utest/Kconfig" - rsource "components/drivers/serial/utest/Kconfig" - rsource "components/drivers/smp_call/utest/Kconfig" - endmenu - - rsource "components/dfs/utest/Kconfig" - rsource "components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig" - rsource "components/libc/cplusplus/utest/Kconfig" - rsource "components/lwp/utest/Kconfig" - rsource "components/mm/utest/Kconfig" - rsource "components/net/utest/Kconfig" - rsource "components/utilities/utest/utest/Kconfig" - - endmenu - -endif - -endmenu diff --git a/components/utilities/utest/Kconfig b/components/utilities/utest/Kconfig new file mode 100644 index 00000000000..2b7bf55a54f --- /dev/null +++ b/components/utilities/utest/Kconfig @@ -0,0 +1,35 @@ +menu "RT-Thread Utestcases" + + config RT_USING_UTESTCASES + bool "RT-Thread Utestcases" + default n + select RT_USING_UTEST + select RT_USING_DEBUG if !RT_USING_ULOG + + if RT_USING_UTESTCASES + + rsource "../../../src/utest/Kconfig" + + menu "Kernel Components" + + menu "Drivers" + rsource "../../../components/drivers/core/utest/Kconfig" + rsource "../../../components/drivers/audio/utest/Kconfig" + rsource "../../../components/drivers/ipc/utest/Kconfig" + rsource "../../../components/drivers/serial/utest/Kconfig" + rsource "../../../components/drivers/smp_call/utest/Kconfig" + endmenu + + rsource "../../../components/dfs/utest/Kconfig" + rsource "../../../components/dfs/dfs_v2/filesystems/tmpfs/utest/Kconfig" + rsource "../../../components/libc/cplusplus/utest/Kconfig" + rsource "../../../components/lwp/utest/Kconfig" + rsource "../../../components/mm/utest/Kconfig" + rsource "../../../components/net/utest/Kconfig" + rsource "../../../components/utilities/utest/utest/Kconfig" + + endmenu + +endif + +endmenu diff --git a/examples/utest/README.md b/components/utilities/utest/README.md similarity index 74% rename from examples/utest/README.md rename to components/utilities/utest/README.md index f21884b5b76..3d3dd7c8e80 100644 --- a/examples/utest/README.md +++ b/components/utilities/utest/README.md @@ -4,11 +4,9 @@ 为了保证某一部分代码的质量,通常可以通过编写测试用例的方式,验证此代码的功能。为了保证 RT-Thread 相关仓库的代码质量,我们基于 utest 框架搭建了一套简易的自动化测试环境。有兴趣,有精力的小伙伴可以利用这套机制完善自己的代码检查。如果有意愿让社区上更多的小伙伴受益,也可以在提交代码的时候,把对应的测试用例也提交上来。 -## 目录结构 +## 相关配置 -| 目录 | 用途 | -| --------- | ------------------------------------------------------------ | -| configs | 配置文件集合(每一个目录代表一种功能集合,如:kernel,net等) | +自动化测试使用的配置文件维护在 [examples/utest/configs](../../../examples/utest/configs),每一个目录代表一种功能集合,如:kernel, net 等。 ## 如何贡献 @@ -53,7 +51,7 @@ msh />utest_run ### 3. 提交 -1. 如果是对已有测试集合的完善,需要把添加的测试用例的配置项,以及对应的依赖项添加到对应测试集合的配置文件里,如:[examples\utest\configs\kernel\mem.conf](./configs/kernel/mem.conf)。 +1. 如果是对已有测试集合的完善,需要把添加的测试用例的配置项,以及对应的依赖项添加到对应测试集合的配置文件里,如:[examples/utest/configs/kernel/mem.cfg](../../../examples/utest/configs/kernel/mem.cfg)。 ``` CONFIG_RT_UTEST_MEMHEAP=y @@ -62,11 +60,11 @@ CONFIG_RT_UTEST_MEMHEAP=y CONFIG_RT_USING_MEMHEAP=y ``` -2. 如果要添加新的测试集合,需要参考已有的测试集合,在 [examples\utest\configs](./configs) 目录下添加新的测试集合配置项。并更新 [.github\workflows\action_utest.yml](../../.github/workflows/action_utest.yml) 内的测试集合。 +2. 如果要添加新的测试集合,需要参考已有的测试集合,在 [examples/utest/configs](../../../examples/utest/configs) 目录下添加新的测试集合配置项。并更新 [.github/workflows/utest_auto_run.yml](../../../.github/workflows/utest_auto_run.yml) 内的测试集合。 ``` -- {UTEST: "kernel/mem", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", CONFIG_FILE: "kernel/mem.conf", SD_FILE: "sd.bin"} -- {UTEST: "components/utest", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", CONFIG_FILE: "utest_self/self.conf", SD_FILE: "sd.bin"} +- platform: { UTEST: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", SMP_RUN: "" } + config_file: "kernel/mem.cfg" ``` 3. 向 RT-Thread 主仓库提交合并请求。 diff --git a/documentation/6.components/utest/utest.md b/documentation/6.components/utest/utest.md index aa70ee96df8..aae598523c5 100644 --- a/documentation/6.components/utest/utest.md +++ b/documentation/6.components/utest/utest.md @@ -308,7 +308,7 @@ The utest_run tool now supports dynamic auto-completion for test case names. Aft # How-to add utest cases into RT-Thread for your module -The source code of utest cases is recommended to be placed in each module for maintenance, but the entry of Kconfig should all be placed(rsourced) in `Kconfig.utestcases` for unified maintenance. In this way, when executing menuconfig, people can enter and configure from one place, avoiding searching for utest configuration switches scattering in the menuconfig interface. +The source code of utest cases is recommended to be placed in each module for maintenance, but the entry of Kconfig should all be placed(rsourced) in `components/utilities/utest/Kconfig` for unified maintenance. In this way, when executing menuconfig, people can enter and configure from one place, avoiding searching for utest configuration switches scattering in the menuconfig interface. For each module, you can maintain unit testcases in a unified manner in the following way: @@ -322,7 +322,7 @@ For each module, you can maintain unit testcases in a unified manner in the foll - `SConscript` file, when adding src files, you need to rely on `RT_UTEST_XXXX`. -After completing the above steps, rsource the path of the Kconfig file of utest of this module to the file `Kconfig.utestcases`. +After completing the above steps, rsource the path of the Kconfig file of utest of this module to the file `components/utilities/utest/Kconfig`. You can find a good example in "klibc". diff --git a/tools/env_utility.py b/tools/env_utility.py index d7904ff0052..639ab530b72 100644 --- a/tools/env_utility.py +++ b/tools/env_utility.py @@ -327,7 +327,9 @@ def get_file_md5(file): # Exclude utestcases def exclude_utestcases(RTT_ROOT): - if os.path.isfile(os.path.join(RTT_ROOT, 'Kconfig.utestcases')): + utestcases_kconfig = os.path.join(RTT_ROOT, 'components', 'utilities', 'utest', 'Kconfig') + + if os.path.isfile(utestcases_kconfig): return if not os.path.isfile(os.path.join(RTT_ROOT, 'Kconfig')): @@ -337,7 +339,7 @@ def exclude_utestcases(RTT_ROOT): data = f.readlines() with open(os.path.join(RTT_ROOT, 'Kconfig'), 'w') as f: for line in data: - if line.find('Kconfig.utestcases') == -1: + if line.find('components/utilities/utest/Kconfig') == -1: f.write(line) diff --git a/tools/mkdist.py b/tools/mkdist.py index 838ae15ad5b..ddbbc3dc510 100644 --- a/tools/mkdist.py +++ b/tools/mkdist.py @@ -110,6 +110,11 @@ def bsp_update_sconstruct(dist_dir): f.write(line) def bsp_update_kconfig_testcases(dist_dir): + utestcases_kconfig = os.path.join(dist_dir, 'rt-thread/components/utilities/utest/Kconfig') + + if os.path.isfile(utestcases_kconfig): + return + # delete testcases in rt-thread/Kconfig if not os.path.isfile(os.path.join(dist_dir, 'rt-thread/Kconfig')): return @@ -118,7 +123,7 @@ def bsp_update_kconfig_testcases(dist_dir): data = f.readlines() with open(os.path.join(dist_dir, 'rt-thread/Kconfig'), 'w') as f: for line in data: - if line.find('Kconfig.utestcases') == -1: + if line.find('components/utilities/utest/Kconfig') == -1: f.write(line) def bsp_update_kconfig(dist_dir): @@ -336,4 +341,4 @@ def MkDist_Strip(program, BSP_ROOT, RTT_ROOT, env, project_name, project_path=No if project_path is None: zip_dist(dist_dir, project_name) print("Distribution package created: {}.zip".format(dist_dir)) - print('=> Distribution stripped successfully') \ No newline at end of file + print('=> Distribution stripped successfully') From c1d1047c09fdcc63321c7e503ea52c02102c2963 Mon Sep 17 00:00:00 2001 From: CYFS <2805686936@qq.com> Date: Thu, 11 Jun 2026 15:53:08 +0800 Subject: [PATCH 5/5] utest: move ci configs to github directory Signed-off-by: CYFS <2805686936@qq.com> --- .../utest/configs/components/dfs.cfg | 0 .../utest/configs/components/lwip.cfg | 0 .../utest/configs/components/netdev.cfg | 0 .../utest/configs/components/sal.cfg | 0 .../utest/configs/cpp11/cpp11.cfg | 0 {examples => .github}/utest/configs/default.cfg | 0 .../utest/configs/kernel/atomic_c11.cfg | 0 .../utest/configs/kernel/ipc.cfg | 0 .../utest/configs/kernel/kernel_basic.cfg | 0 .../utest/configs/kernel/mem.cfg | 0 .../utest/configs/rtsmart/rtsmart.cfg | 0 {examples => .github}/utest/configs/smp/smp.cfg | 0 .github/workflows/utest_auto_run.yml | 15 +++++++++------ components/utilities/utest/README.md | 6 +++--- 14 files changed, 12 insertions(+), 9 deletions(-) rename {examples => .github}/utest/configs/components/dfs.cfg (100%) rename {examples => .github}/utest/configs/components/lwip.cfg (100%) rename {examples => .github}/utest/configs/components/netdev.cfg (100%) rename {examples => .github}/utest/configs/components/sal.cfg (100%) rename {examples => .github}/utest/configs/cpp11/cpp11.cfg (100%) rename {examples => .github}/utest/configs/default.cfg (100%) rename {examples => .github}/utest/configs/kernel/atomic_c11.cfg (100%) rename {examples => .github}/utest/configs/kernel/ipc.cfg (100%) rename {examples => .github}/utest/configs/kernel/kernel_basic.cfg (100%) rename {examples => .github}/utest/configs/kernel/mem.cfg (100%) rename {examples => .github}/utest/configs/rtsmart/rtsmart.cfg (100%) rename {examples => .github}/utest/configs/smp/smp.cfg (100%) diff --git a/examples/utest/configs/components/dfs.cfg b/.github/utest/configs/components/dfs.cfg similarity index 100% rename from examples/utest/configs/components/dfs.cfg rename to .github/utest/configs/components/dfs.cfg diff --git a/examples/utest/configs/components/lwip.cfg b/.github/utest/configs/components/lwip.cfg similarity index 100% rename from examples/utest/configs/components/lwip.cfg rename to .github/utest/configs/components/lwip.cfg diff --git a/examples/utest/configs/components/netdev.cfg b/.github/utest/configs/components/netdev.cfg similarity index 100% rename from examples/utest/configs/components/netdev.cfg rename to .github/utest/configs/components/netdev.cfg diff --git a/examples/utest/configs/components/sal.cfg b/.github/utest/configs/components/sal.cfg similarity index 100% rename from examples/utest/configs/components/sal.cfg rename to .github/utest/configs/components/sal.cfg diff --git a/examples/utest/configs/cpp11/cpp11.cfg b/.github/utest/configs/cpp11/cpp11.cfg similarity index 100% rename from examples/utest/configs/cpp11/cpp11.cfg rename to .github/utest/configs/cpp11/cpp11.cfg diff --git a/examples/utest/configs/default.cfg b/.github/utest/configs/default.cfg similarity index 100% rename from examples/utest/configs/default.cfg rename to .github/utest/configs/default.cfg diff --git a/examples/utest/configs/kernel/atomic_c11.cfg b/.github/utest/configs/kernel/atomic_c11.cfg similarity index 100% rename from examples/utest/configs/kernel/atomic_c11.cfg rename to .github/utest/configs/kernel/atomic_c11.cfg diff --git a/examples/utest/configs/kernel/ipc.cfg b/.github/utest/configs/kernel/ipc.cfg similarity index 100% rename from examples/utest/configs/kernel/ipc.cfg rename to .github/utest/configs/kernel/ipc.cfg diff --git a/examples/utest/configs/kernel/kernel_basic.cfg b/.github/utest/configs/kernel/kernel_basic.cfg similarity index 100% rename from examples/utest/configs/kernel/kernel_basic.cfg rename to .github/utest/configs/kernel/kernel_basic.cfg diff --git a/examples/utest/configs/kernel/mem.cfg b/.github/utest/configs/kernel/mem.cfg similarity index 100% rename from examples/utest/configs/kernel/mem.cfg rename to .github/utest/configs/kernel/mem.cfg diff --git a/examples/utest/configs/rtsmart/rtsmart.cfg b/.github/utest/configs/rtsmart/rtsmart.cfg similarity index 100% rename from examples/utest/configs/rtsmart/rtsmart.cfg rename to .github/utest/configs/rtsmart/rtsmart.cfg diff --git a/examples/utest/configs/smp/smp.cfg b/.github/utest/configs/smp/smp.cfg similarity index 100% rename from examples/utest/configs/smp/smp.cfg rename to .github/utest/configs/smp/smp.cfg diff --git a/.github/workflows/utest_auto_run.yml b/.github/workflows/utest_auto_run.yml index 4dfdcd6092f..b8eb99c8343 100644 --- a/.github/workflows/utest_auto_run.yml +++ b/.github/workflows/utest_auto_run.yml @@ -1,5 +1,5 @@ # Automation utest run script for the QEMU platform -# Generate the corresponding config configuration for CI based on the configuration file under examples/utest/configs. +# Generate the corresponding config configuration for CI based on the configuration file under .github/utest/configs. name: utest_auto_run @@ -9,8 +9,9 @@ on: - master paths: - '.github/workflows/utest_auto_run.yml' + - '.github/utest/configs/**' - 'Kconfig' - - 'Kconfig.utestcases' + - 'components/utilities/utest/Kconfig' - 'bsp/qemu-vexpress-a9/**' - 'bsp/qemu-virt64-aarch64/**' - 'bsp/qemu-virt64-riscv/**' @@ -28,8 +29,9 @@ on: - master paths: - '.github/workflows/utest_auto_run.yml' + - '.github/utest/configs/**' - 'Kconfig' - - 'Kconfig.utestcases' + - 'components/utilities/utest/Kconfig' - 'bsp/qemu-vexpress-a9/**' - 'bsp/qemu-virt64-aarch64/**' - 'bsp/qemu-virt64-riscv/**' @@ -155,6 +157,7 @@ jobs: TEST_BSP_ROOT: ${{ matrix.platform.RTT_BSP }} TEST_CONFIG_FILE: ${{ matrix.config_file }} TEST_SD_FILE: ${{ matrix.platform.SD_FILE }} + UTEST_CONFIG_ROOT: .github/utest/configs steps: - uses: actions/checkout@main @@ -266,16 +269,16 @@ jobs: run: | # Whether plan to run SMP? if [[ "${{ matrix.platform.SMP_RUN }}" == "smp" ]]; then - cat examples/utest/configs/smp/smp.cfg >> $TEST_BSP_ROOT/.config + cat $UTEST_CONFIG_ROOT/smp/smp.cfg >> $TEST_BSP_ROOT/.config fi # Is the kernel rtsmart? if [[ "${{ matrix.platform.KERNEL }}" == "rtsmart" ]]; then - cat examples/utest/configs/rtsmart/rtsmart.cfg >> $TEST_BSP_ROOT/.config + cat $UTEST_CONFIG_ROOT/rtsmart/rtsmart.cfg >> $TEST_BSP_ROOT/.config fi echo CONFIG_RT_USING_UTESTCASES=y >> $TEST_BSP_ROOT/.config - cat examples/utest/configs/$TEST_CONFIG_FILE >> $TEST_BSP_ROOT/.config + cat $UTEST_CONFIG_ROOT/$TEST_CONFIG_FILE >> $TEST_BSP_ROOT/.config scons --pyconfig-silent -C $TEST_BSP_ROOT scons -j$(nproc) --strict -C $TEST_BSP_ROOT diff --git a/components/utilities/utest/README.md b/components/utilities/utest/README.md index 3d3dd7c8e80..dffebc45dc0 100644 --- a/components/utilities/utest/README.md +++ b/components/utilities/utest/README.md @@ -6,7 +6,7 @@ ## 相关配置 -自动化测试使用的配置文件维护在 [examples/utest/configs](../../../examples/utest/configs),每一个目录代表一种功能集合,如:kernel, net 等。 +自动化测试使用的配置文件维护在 [.github/utest/configs](../../../.github/utest/configs),每一个目录代表一种功能集合,如:kernel, net 等。 ## 如何贡献 @@ -51,7 +51,7 @@ msh />utest_run ### 3. 提交 -1. 如果是对已有测试集合的完善,需要把添加的测试用例的配置项,以及对应的依赖项添加到对应测试集合的配置文件里,如:[examples/utest/configs/kernel/mem.cfg](../../../examples/utest/configs/kernel/mem.cfg)。 +1. 如果是对已有测试集合的完善,需要把添加的测试用例的配置项,以及对应的依赖项添加到对应测试集合的配置文件里,如:[.github/utest/configs/kernel/mem.cfg](../../../.github/utest/configs/kernel/mem.cfg)。 ``` CONFIG_RT_UTEST_MEMHEAP=y @@ -60,7 +60,7 @@ CONFIG_RT_UTEST_MEMHEAP=y CONFIG_RT_USING_MEMHEAP=y ``` -2. 如果要添加新的测试集合,需要参考已有的测试集合,在 [examples/utest/configs](../../../examples/utest/configs) 目录下添加新的测试集合配置项。并更新 [.github/workflows/utest_auto_run.yml](../../../.github/workflows/utest_auto_run.yml) 内的测试集合。 +2. 如果要添加新的测试集合,需要参考已有的测试集合,在 [.github/utest/configs](../../../.github/utest/configs) 目录下添加新的测试集合配置项。并更新 [.github/workflows/utest_auto_run.yml](../../../.github/workflows/utest_auto_run.yml) 内的测试集合。 ``` - platform: { UTEST: "A9", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "arm", QEMU_MACHINE: "vexpress-a9", SD_FILE: "sd.bin", KERNEL: "standard", SMP_RUN: "" }