Skip to content

Commit

Permalink
[utest] add rt_memcpy utest case
Browse files Browse the repository at this point in the history
  • Loading branch information
mysterywolf committed Dec 21, 2024
1 parent 7772d46 commit fc1abf4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ menuconfig RT_USING_DEBUG
endif

config RT_USING_CI_ACTION
bool "Enable CI Action build mode"
select RT_USING_UTEST
default n
help
Identify that the environment is CI Action.
Expand Down
6 changes: 6 additions & 0 deletions src/klibc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,10 @@ menu "klibc options"
bool "Enable rt_strnlen to use user-defined version"
default n
endmenu # rt_strnlen options

config RT_UTEST_TC_USING_KLIBC
bool "Enable klibc utest cases"
select RT_USING_UTEST
default n

endmenu
10 changes: 10 additions & 0 deletions src/klibc/utest/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from building import *

src = []

if GetDepend('RT_USING_CI_ACTION') or GetDepend('RT_UTEST_TC_USING_KLIBC'):
src += Glob('tc_*.c')

group = DefineGroup('utestcases', src, depend = [''])

Return('group')
36 changes: 36 additions & 0 deletions src/klibc/utest/tc_kstdlib.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2006-2019, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2024-12-21 Meco Man the first version
*/
#include <rtklibc.h>
#include <utest.h>

static rt_err_t utest_tc_init(void)
{
return RT_EOK;
}

static rt_err_t utest_tc_cleanup(void)
{
return RT_EOK;
}

static void tc_rt_memcpy_1(void)
{
const char src[] = "Hello, memcpy!";
char dest[20];
rt_memcpy(dest, src, sizeof(src));
uassert_true(rt_strcmp(src, dest) == 0);
}

static void utest_do_tc(void)
{
UTEST_UNIT_RUN(tc_rt_memcpy_1);
}

UTEST_TC_EXPORT(utest_do_tc, "klibc.kstdlibc", utest_tc_init, utest_tc_cleanup, 1000);

0 comments on commit fc1abf4

Please sign in to comment.