From c6e447ae620b01d8d4068457e0eb7a5149e392ee Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 21 Dec 2024 00:20:26 -0500 Subject: [PATCH] add demo of new utest cases --- src/Kconfig | 2 ++ src/klibc/utest/SConscript | 10 ++++++++++ src/klibc/utest/tc_kstdlib.c | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/klibc/utest/SConscript create mode 100644 src/klibc/utest/tc_kstdlib.c diff --git a/src/Kconfig b/src/Kconfig index e7f2a5108b6..d4cad60d953 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -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. diff --git a/src/klibc/utest/SConscript b/src/klibc/utest/SConscript new file mode 100644 index 00000000000..1ea03cc14c8 --- /dev/null +++ b/src/klibc/utest/SConscript @@ -0,0 +1,10 @@ +from building import * + +src = [] + +if GetDepend('RT_USING_CI_ACTION'): + 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 00000000000..207ff43ac2f --- /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 +#include + +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);