Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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 = .;
2 changes: 1 addition & 1 deletion src/klibc/Kconfig
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion src/klibc/rt_vsnprintf_tiny.c
Original file line number Diff line number Diff line change
@@ -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++);
2 changes: 1 addition & 1 deletion src/klibc/utest/SConscript
Original file line number Diff line number Diff line change
@@ -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 = [''])

9 changes: 5 additions & 4 deletions src/klibc/utest/tc_kstdlib.c → src/klibc/utest/TC_kstdlib.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*
* Copyright (c) 2006-2019, RT-Thread Development Team
* Copyright (c) 2006-2024, 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>

@@ -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);
Loading