From 277626cccbcdf44d7c0301396543f25fdb527815 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Thu, 24 Jul 2025 16:47:09 +0800 Subject: [PATCH 1/3] 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 --- Kconfig | 2 +- Kconfig.utestcases | 24 ++++++++++++++++++++++++ examples/utest/testcases/Kconfig | 23 ----------------------- tools/env_utility.py | 4 ++-- tools/mkdist.py | 2 +- 5 files changed, 28 insertions(+), 27 deletions(-) create mode 100644 Kconfig.utestcases delete mode 100644 examples/utest/testcases/Kconfig diff --git a/Kconfig b/Kconfig index c16817583a5..a7a7758f671 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 00000000000..3dcbc9920cc --- /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 eec0e784445..00000000000 --- 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 d950d077334..d7904ff0052 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 89665719d57..838ae15ad5b 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): From ce69de7362a505f69f12da02322b62a088189948 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Thu, 24 Jul 2025 16:52:00 +0800 Subject: [PATCH 2/3] utest: integrate config option for utest of klibc Signed-off-by: Chen Wang --- Kconfig.utestcases | 2 ++ src/klibc/Kconfig | 5 ----- src/klibc/utest/Kconfig | 4 ++++ 3 files changed, 6 insertions(+), 5 deletions(-) create mode 100644 src/klibc/utest/Kconfig diff --git a/Kconfig.utestcases b/Kconfig.utestcases index 3dcbc9920cc..e1d4dbe9e1b 100644 --- a/Kconfig.utestcases +++ b/Kconfig.utestcases @@ -19,6 +19,8 @@ rsource "examples/utest/testcases/tmpfs/Kconfig" rsource "examples/utest/testcases/smp_call/Kconfig" rsource "examples/utest/testcases/perf/Kconfig" +rsource "src/klibc/utest/Kconfig" + endif endmenu diff --git a/src/klibc/Kconfig b/src/klibc/Kconfig index bc90e90e8fa..daeb3dedeee 100644 --- a/src/klibc/Kconfig +++ b/src/klibc/Kconfig @@ -250,9 +250,4 @@ menu "klibc options" default n endmenu # rt_strnlen options - config RT_UTEST_TC_USING_KLIBC - bool "Enable klibc utest cases" - select RT_USING_UTEST - default n - endmenu diff --git a/src/klibc/utest/Kconfig b/src/klibc/utest/Kconfig new file mode 100644 index 00000000000..086a817e073 --- /dev/null +++ b/src/klibc/utest/Kconfig @@ -0,0 +1,4 @@ +config RT_UTEST_TC_USING_KLIBC + bool "Enable klibc utest cases" + select RT_USING_UTEST + default n From 7f724493f311c9696ef7e324af587f18ee915257 Mon Sep 17 00:00:00 2001 From: Chen Wang Date: Thu, 24 Jul 2025 16:53:56 +0800 Subject: [PATCH 3/3] utest: integrate config option for utest of audio driver Signed-off-by: Chen Wang --- Kconfig.utestcases | 2 ++ components/drivers/audio/Kconfig | 3 --- components/drivers/audio/utest/Kconfig | 5 +++++ 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 components/drivers/audio/utest/Kconfig diff --git a/Kconfig.utestcases b/Kconfig.utestcases index e1d4dbe9e1b..e851ad39592 100644 --- a/Kconfig.utestcases +++ b/Kconfig.utestcases @@ -21,6 +21,8 @@ rsource "examples/utest/testcases/perf/Kconfig" rsource "src/klibc/utest/Kconfig" +rsource "components/drivers/audio/utest/Kconfig" + endif endmenu diff --git a/components/drivers/audio/Kconfig b/components/drivers/audio/Kconfig index f6cae1ae6ce..48770ac0f0a 100644 --- a/components/drivers/audio/Kconfig +++ b/components/drivers/audio/Kconfig @@ -15,7 +15,4 @@ config RT_USING_AUDIO int "Record pipe size" default 2048 - config RT_UTEST_USING_AUDIO_DRIVER - bool "Enable rt_audio_api testcase" - default n endif diff --git a/components/drivers/audio/utest/Kconfig b/components/drivers/audio/utest/Kconfig new file mode 100644 index 00000000000..2ee22aef924 --- /dev/null +++ b/components/drivers/audio/utest/Kconfig @@ -0,0 +1,5 @@ +if RT_USING_AUDIO + config RT_UTEST_USING_AUDIO_DRIVER + bool "Enable rt_audio_api testcase" + default n +endif \ No newline at end of file