Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 547a4fb

Browse files
committedDec 21, 2024·
add demo of new utest cases
1 parent 6fb3b81 commit 547a4fb

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed
 

‎src/Kconfig

+2
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@ menuconfig RT_USING_DEBUG
242242
endif
243243

244244
config RT_USING_CI_ACTION
245+
bool "Enable CI Action build mode"
246+
select RT_USING_UTEST
245247
default n
246248
help
247249
Identify that the environment is CI Action.

‎src/klibc/utest/SConscript

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from building import *
2+
3+
src = []
4+
5+
if GetDepend('RT_USING_CI_ACTION'):
6+
src += Glob('utest_*.c')
7+
8+
group = DefineGroup('utestcases', src, depend = [''])
9+
10+
Return('group')

‎src/klibc/utest/tc_kstdlib.c

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2006-2019, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2024-12-21 Meco Man the first version
9+
*/
10+
#include <rtklibc.h>
11+
#include <utest.h>
12+
13+
static rt_err_t utest_tc_init(void)
14+
{
15+
return RT_EOK;
16+
}
17+
18+
static rt_err_t utest_tc_cleanup(void)
19+
{
20+
return RT_EOK;
21+
}
22+
23+
static void tc_rt_memcpy_1(void)
24+
{
25+
const char src[] = "Hello, memcpy!";
26+
char dest[20];
27+
rt_memcpy(dest, src, sizeof(src));
28+
uassert_true(rt_strcmp(src, dest) == 0);
29+
}
30+
31+
static void utest_do_tc(void)
32+
{
33+
UTEST_UNIT_RUN(tc_rt_memcpy_1);
34+
}
35+
36+
UTEST_TC_EXPORT(utest_do_tc, "klibc.kstdlibc", utest_tc_init, utest_tc_cleanup, 1000);

0 commit comments

Comments
 (0)
Please sign in to comment.