[utest][klibc] add rt_sprintf family functions test cases

This commit is contained in:
Meco Man 2024-12-22 22:27:50 -05:00
parent f31a87926e
commit c9ed784131
6 changed files with 1093 additions and 7 deletions

View File

@ -40,6 +40,12 @@ SECTIONS
KEEP(*(VSymTab))
__vsymtab_end = .;
/* section information for utest */
. = ALIGN(4);
__rt_utest_tc_tab_start = .;
KEEP(*(UtestTcTab))
__rt_utest_tc_tab_end = .;
/* section information for initial. */
. = ALIGN(4);
__rt_init_start = .;

View File

@ -1,7 +1,7 @@
menu "klibc options"
menu "rt_vsnprintf options"
config RT_KLIBC_USING_LIBC_VSNPRINTF
bool "Enable rt_vsnprintf to use libc vsscanf"
bool "Enable rt_vsnprintf to use libc vsnprintf"
default n
config RT_KLIBC_USING_VSNPRINTF_LONGLONG

View File

@ -448,7 +448,7 @@ int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args)
s = va_arg(args, char *);
if (!s)
{
s = "(NULL)";
s = "(null)";
}
for (len = 0; (len != field_width) && (s[len] != '\0'); len++);

View File

@ -3,7 +3,7 @@ from building import *
src = []
if GetDepend('RT_USING_CI_ACTION') or GetDepend('RT_UTEST_TC_USING_KLIBC'):
src += Glob('tc_*.c')
src += Glob('TC_*.c')
group = DefineGroup('utestcases', src, depend = [''])

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2019, RT-Thread Development Team
* Copyright (c) 2006-2024, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -7,6 +7,7 @@
* Date Author Notes
* 2024-12-21 Meco Man the first version
*/
#include <rtklibc.h>
#include <utest.h>
@ -20,17 +21,17 @@ static rt_err_t utest_tc_cleanup(void)
return RT_EOK;
}
static void tc_rt_memcpy_1(void)
static void TC_rt_memcpy_1(void)
{
const char src[] = "Hello, memcpy!";
char dest[20];
char dest[20] = {0};
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_UNIT_RUN(TC_rt_memcpy_1);
}
UTEST_TC_EXPORT(utest_do_tc, "klibc.kstdlibc", utest_tc_init, utest_tc_cleanup, 1000);

File diff suppressed because it is too large Load Diff