Skip to content

Commit c0142c7

Browse files
authored
utest/utest: intergare testcases into utest framework (#10665)
* utest: move testcases of Utest from example to Utest folder Create unit-test-cases for the Utest framework subsystem according to "How to add utest cases into RT-Thread for your module." [1] Link: https://rt-thread.github.io/rt-thread/page_component_utest.html#autotoc_md804 [1] The original `components/utilities/utest` directory already has unit testcases, which are more comprehensive than the testcases in `examples/utest/testcases/utest/`. Therefore, simply deleted the test cases in `examples` and used the existing testcases in the utest framework. Signed-off-by: Chen Wang <[email protected]> * utest/utest: rename name and add license text Signed-off-by: Chen Wang <[email protected]> --------- Signed-off-by: Chen Wang <[email protected]>
1 parent c1e9403 commit c0142c7

File tree

8 files changed

+31
-68
lines changed

8 files changed

+31
-68
lines changed

Kconfig.utestcases

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ config RT_USING_UTESTCASES
77

88
if RT_USING_UTESTCASES
99

10-
rsource "examples/utest/testcases/utest/Kconfig"
10+
rsource "components/utilities/utest/utest/Kconfig"
1111
rsource "examples/utest/testcases/kernel/Kconfig"
1212
rsource "examples/utest/testcases/cpp11/Kconfig"
1313
rsource "examples/utest/testcases/drivers/serial_v2/Kconfig"

components/utilities/utest/SConscript

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,9 @@ src = Glob('*.c')
55
CPPPATH = [cwd]
66
group = DefineGroup('UTest', src, depend = ['RT_USING_UTEST'], CPPPATH = CPPPATH)
77

8+
list = os.listdir(cwd)
9+
for item in list:
10+
if os.path.isfile(os.path.join(cwd, item, 'SConscript')):
11+
group = group + SConscript(os.path.join(item, 'SConscript'))
12+
813
Return('group')
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
menu "Utest Self Testcase"
2+
3+
config UTEST_SELF_PASS_TC
4+
bool "UTEST Self-test"
5+
select RT_USING_UTEST
6+
default n
7+
8+
endmenu
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from building import *
2+
3+
src = []
4+
5+
if GetDepend('RT_UTEST_USING_ALL_CASES') or GetDepend('UTEST_SELF_PASS_TC'):
6+
src += Glob('TC_*.c')
7+
8+
group = DefineGroup('utc_UTest', src, depend = [''])
9+
10+
Return('group')

components/utilities/utest/TC_uassert.c renamed to components/utilities/utest/utest/TC_uassert.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/*
2+
* Copyright (c) 2006-2025, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
17
#include <rtthread.h>
28
#include "utest.h"
39

@@ -80,4 +86,4 @@ static void utest_do_tc(void)
8086
UTEST_UNIT_RUN(TC_uassert_in_range);
8187
}
8288

83-
UTEST_TC_EXPORT(utest_do_tc, "utest.uassert", RT_NULL, RT_NULL, 10);
89+
UTEST_TC_EXPORT(utest_do_tc, "utest", RT_NULL, RT_NULL, 10);

examples/utest/testcases/utest/Kconfig

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/utest/testcases/utest/SConscript

Lines changed: 0 additions & 13 deletions
This file was deleted.

examples/utest/testcases/utest/pass_tc.c

Lines changed: 0 additions & 46 deletions
This file was deleted.

0 commit comments

Comments
 (0)