summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Wang <[email protected]>2025-07-24 16:47:09 +0800
committerR b b666 <[email protected]>2025-08-26 10:26:47 +0800
commit06c5cc0846980b7d0842d348e3615e8997975249 (patch)
treebbee92c0139dda255f94d0dfed42d87b4f00b22c
parent1892b27a45cf39794fef91dcdc2d3bae08957112 (diff)
utest: move entry from examples to utest
Change the entry of utest's Kconfig from 'examples/utest/testcases/Kconfig' to 'Kconfig.utestcases'. Modified the build scripts where the path name is "examples/utest/testcases/Kconfig" and changed it to 'Kconfig.utestcases', otherwise build operations such 'scons --dist' may fail. In the future, the testcase source code of utest will be placed in each module for maintenance, but the entry of Kconfig will all be placed 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 here and there in the menuconfig interface. For each module, you can maintain unit-test in a unified manner in the following way: - Create a subdirectory named 'utest' in the directory where your module is located. - Store the following files in the utest subdirectory: - Unit test case program source code files for this module. - Kconfig file, add configuration options for the unit test files of this module, the recommended option is named RT_UTEST_TC_USING_XXXX, XXXX is the global unique module name of this module. - SConscript file, note that when adding src files, in addition to relying on RT_UTEST_TC_USING_XXXX, you must also rely on RT_UTEST_USING_ALL_CASES, the two dependencies are in an "or" relationship. The role of RT_UTEST_USING_ALL_CASES is that once this option is turned on, all unit tests will be enabled to avoid selecting one by one. After completing the above steps, add the path of the Kconfig file of utest of this module to the Kconfig.utestcases file. Signed-off-by: Chen Wang <[email protected]>
-rw-r--r--Kconfig2
-rw-r--r--Kconfig.utestcases24
-rw-r--r--examples/utest/testcases/Kconfig23
-rw-r--r--tools/env_utility.py4
-rw-r--r--tools/mkdist.py2
5 files changed, 28 insertions, 27 deletions
diff --git a/Kconfig b/Kconfig
index c16817583a..a7a7758f67 100644
--- a/Kconfig
+++ b/Kconfig
@@ -1,4 +1,4 @@
rsource "src/Kconfig"
rsource "libcpu/Kconfig"
rsource "components/Kconfig"
-rsource "examples/utest/testcases/Kconfig"
+rsource "Kconfig.utestcases"
diff --git a/Kconfig.utestcases b/Kconfig.utestcases
new file mode 100644
index 0000000000..3dcbc9920c
--- /dev/null
+++ b/Kconfig.utestcases
@@ -0,0 +1,24 @@
+menu "RT-Thread Utestcases"
+
+config RT_USING_UTESTCASES
+ bool "RT-Thread Utestcases"
+ default n
+ select RT_USING_UTEST
+
+if RT_USING_UTESTCASES
+
+rsource "examples/utest/testcases/utest/Kconfig"
+rsource "examples/utest/testcases/kernel/Kconfig"
+rsource "examples/utest/testcases/cpp11/Kconfig"
+rsource "examples/utest/testcases/drivers/serial_v2/Kconfig"
+rsource "examples/utest/testcases/drivers/serial_bypass/Kconfig"
+rsource "examples/utest/testcases/drivers/ipc/Kconfig"
+rsource "examples/utest/testcases/posix/Kconfig"
+rsource "examples/utest/testcases/mm/Kconfig"
+rsource "examples/utest/testcases/tmpfs/Kconfig"
+rsource "examples/utest/testcases/smp_call/Kconfig"
+rsource "examples/utest/testcases/perf/Kconfig"
+
+endif
+
+endmenu
diff --git a/examples/utest/testcases/Kconfig b/examples/utest/testcases/Kconfig
deleted file mode 100644
index eec0e78444..0000000000
--- a/examples/utest/testcases/Kconfig
+++ /dev/null
@@ -1,23 +0,0 @@
-menu "RT-Thread Utestcases"
-
-config RT_USING_UTESTCASES
- bool "RT-Thread Utestcases"
- default n
- select RT_USING_UTEST
-
-if RT_USING_UTESTCASES
-
-rsource "utest/Kconfig"
-rsource "kernel/Kconfig"
-rsource "cpp11/Kconfig"
-rsource "drivers/serial_v2/Kconfig"
-rsource "drivers/serial_bypass/Kconfig"
-rsource "drivers/ipc/Kconfig"
-rsource "posix/Kconfig"
-rsource "mm/Kconfig"
-rsource "tmpfs/Kconfig"
-rsource "smp_call/Kconfig"
-rsource "perf/Kconfig"
-endif
-
-endmenu
diff --git a/tools/env_utility.py b/tools/env_utility.py
index d950d07733..d7904ff005 100644
--- a/tools/env_utility.py
+++ b/tools/env_utility.py
@@ -327,7 +327,7 @@ def get_file_md5(file):
# Exclude utestcases
def exclude_utestcases(RTT_ROOT):
- if os.path.isfile(os.path.join(RTT_ROOT, 'examples/utest/testcases/Kconfig')):
+ if os.path.isfile(os.path.join(RTT_ROOT, 'Kconfig.utestcases')):
return
if not os.path.isfile(os.path.join(RTT_ROOT, 'Kconfig')):
@@ -337,7 +337,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('examples/utest/testcases/Kconfig') == -1:
+ if line.find('Kconfig.utestcases') == -1:
f.write(line)
diff --git a/tools/mkdist.py b/tools/mkdist.py
index 89665719d5..838ae15ad5 100644
--- a/tools/mkdist.py
+++ b/tools/mkdist.py
@@ -118,7 +118,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('examples/utest/testcases/Kconfig') == -1:
+ if line.find('Kconfig.utestcases') == -1:
f.write(line)
def bsp_update_kconfig(dist_dir):