Skip to content

Commit c9ed784

Browse files
committed
[utest][klibc] add rt_sprintf family functions test cases
1 parent f31a879 commit c9ed784

File tree

6 files changed

+1093
-7
lines changed

6 files changed

+1093
-7
lines changed

bsp/stm32/stm32l475-atk-pandora/board/linker_scripts/link.lds

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ SECTIONS
4040
KEEP(*(VSymTab))
4141
__vsymtab_end = .;
4242

43+
/* section information for utest */
44+
. = ALIGN(4);
45+
__rt_utest_tc_tab_start = .;
46+
KEEP(*(UtestTcTab))
47+
__rt_utest_tc_tab_end = .;
48+
4349
/* section information for initial. */
4450
. = ALIGN(4);
4551
__rt_init_start = .;

src/klibc/Kconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
menu "klibc options"
22
menu "rt_vsnprintf options"
33
config RT_KLIBC_USING_LIBC_VSNPRINTF
4-
bool "Enable rt_vsnprintf to use libc vsscanf"
4+
bool "Enable rt_vsnprintf to use libc vsnprintf"
55
default n
66

77
config RT_KLIBC_USING_VSNPRINTF_LONGLONG

src/klibc/rt_vsnprintf_tiny.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args)
448448
s = va_arg(args, char *);
449449
if (!s)
450450
{
451-
s = "(NULL)";
451+
s = "(null)";
452452
}
453453

454454
for (len = 0; (len != field_width) && (s[len] != '\0'); len++);

src/klibc/utest/SConscript

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ from building import *
33
src = []
44

55
if GetDepend('RT_USING_CI_ACTION') or GetDepend('RT_UTEST_TC_USING_KLIBC'):
6-
src += Glob('tc_*.c')
6+
src += Glob('TC_*.c')
77

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

src/klibc/utest/tc_kstdlib.c src/klibc/utest/TC_kstdlib.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
/*
2-
* Copyright (c) 2006-2019, RT-Thread Development Team
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
66
* Change Logs:
77
* Date Author Notes
88
* 2024-12-21 Meco Man the first version
99
*/
10+
1011
#include <rtklibc.h>
1112
#include <utest.h>
1213

@@ -20,17 +21,17 @@ static rt_err_t utest_tc_cleanup(void)
2021
return RT_EOK;
2122
}
2223

23-
static void tc_rt_memcpy_1(void)
24+
static void TC_rt_memcpy_1(void)
2425
{
2526
const char src[] = "Hello, memcpy!";
26-
char dest[20];
27+
char dest[20] = {0};
2728
rt_memcpy(dest, src, sizeof(src));
2829
uassert_true(rt_strcmp(src, dest) == 0);
2930
}
3031

3132
static void utest_do_tc(void)
3233
{
33-
UTEST_UNIT_RUN(tc_rt_memcpy_1);
34+
UTEST_UNIT_RUN(TC_rt_memcpy_1);
3435
}
3536

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

0 commit comments

Comments
 (0)