diff options
| author | Meco Man <[email protected]> | 2024-12-21 00:20:26 -0500 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2024-12-21 14:57:17 -0500 |
| commit | fc1abf46a97d141c84ce9251e29ff6de3181cf4a (patch) | |
| tree | a669301dcbc73590aee0fc177fff2b3f2158fe36 /src/klibc | |
| parent | 7772d4619adb94f760ee86734394ed5a8a61a2c9 (diff) | |
[utest] add rt_memcpy utest case
Diffstat (limited to 'src/klibc')
| -rw-r--r-- | src/klibc/Kconfig | 6 | ||||
| -rw-r--r-- | src/klibc/utest/SConscript | 10 | ||||
| -rw-r--r-- | src/klibc/utest/tc_kstdlib.c | 36 |
3 files changed, 52 insertions, 0 deletions
diff --git a/src/klibc/Kconfig b/src/klibc/Kconfig index 0b00d10b8e..e41e1cf665 100644 --- a/src/klibc/Kconfig +++ b/src/klibc/Kconfig @@ -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 diff --git a/src/klibc/utest/SConscript b/src/klibc/utest/SConscript new file mode 100644 index 0000000000..1b9bb9e18e --- /dev/null +++ b/src/klibc/utest/SConscript @@ -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') diff --git a/src/klibc/utest/tc_kstdlib.c b/src/klibc/utest/tc_kstdlib.c new file mode 100644 index 0000000000..207ff43ac2 --- /dev/null +++ b/src/klibc/utest/tc_kstdlib.c @@ -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); |
