Skip to content

Commit 910fd87

Browse files
committed
[utest] add rt_memcpy utest case
1 parent 0447053 commit 910fd87

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-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/Kconfig

+6
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,10 @@ menu "klibc options"
249249
bool "Enable rt_strnlen to use user-defined version"
250250
default n
251251
endmenu # rt_strnlen options
252+
253+
config RT_UTEST_TC_USING_KLIBC
254+
bool "Enable klibc utest cases"
255+
select RT_USING_UTEST
256+
default n
257+
252258
endmenu

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') or GetDepend('RT_UTEST_TC_USING_KLIBC'):
6+
src += Glob('tc_*.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)