test: provide unit test for memory functions
PATCH 1/1 test: provide unit test for memory functions
Memory functions may have architecture specific implementations. These should be tested.
Provide unit tests for memset(), memcpy(), memmove().
Provide a 'ut lib' sub-command to execute the tests.
---
v2
vary alignment and length of copied or set memory region
--- include/test/lib.h | 14 +++ include/test/suites.h | 1 + test/Kconfig | 8 ++ test/cmd_ut.c | 6 ++ test/lib/Makefile | 2 + test/lib/cmd_ut_lib.c | 20 +++++ test/lib/string.c | 194 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 245 insertions(+) create mode 100644 include/test/lib.h create mode 100644 test/lib/cmd_ut_lib.c create mode 100644 test/lib/string.c
include/test/lib.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2019 Heinrich Schuchardt <[email protected]> +*/ + +#ifndef __TEST_LIB_H__ +#define __TEST_LIB_H__ + +#include <test/test.h> + +/* Declare a new library function test */ +#define LIB_TEST (_name, _flags) UNIT_TEST(_name, _flags, lib_test) + +#endif /* __TEST_LIB_H__ */
include/test/suites.h +1 -0
@@ -27,6 +27,7 @@ int do_ut_bloblist(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]);int do_ut_compression (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]);int do_ut_dm (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]);int do_ut_env (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]); +int do_ut_lib (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]);int do_ut_overlay (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]);int do_ut_time (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]);int do_ut_unicode (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]);
test/Kconfig +8 -0
@@ -6,6 +6,14 @@ menuconfig UNIT_TEST This does not require sandbox to be included, but it is most often used there. +config UT_LIB + bool "Unit tests for library functions" + depends on UNIT_TEST + default y + help + Enables the 'ut lib' command which tests library functions like + memcat(), memcyp(), memmove(). + config UT_TIME bool "Unit tests for time functions" depends on UNIT_TEST
test/cmd_ut.c +6 -0
@@ -46,6 +46,9 @@ static cmd_tbl_t cmd_ut_sub[] = {#ifdef CONFIG_UT_OVERLAY U_BOOT_CMD_MKENT(overlay, CONFIG_SYS_MAXARGS, 1, do_ut_overlay, "", ""),#endif +#ifdef CONFIG_UT_LIB + U_BOOT_CMD_MKENT(lib, CONFIG_SYS_MAXARGS, 1, do_ut_lib, "", ""), +#endif #ifdef CONFIG_UT_TIME U_BOOT_CMD_MKENT(time, CONFIG_SYS_MAXARGS, 1, do_ut_time, "", ""),#endif
@@ -108,6 +111,9 @@ static char ut_help_text[] =#ifdef CONFIG_UT_ENV "ut env [test-name]\n"#endif +#ifdef CONFIG_UT_LIB + "ut lib [test-name] - test library functions\n" +#endif #ifdef CONFIG_UT_OVERLAY "ut overlay [test-name]\n"#endif
test/lib/Makefile +2 -0
@@ -2,5 +2,7 @@ # # (C) Copyright 2018 # Mario Six, Guntermann & Drunck GmbH, mario.six at gdsys.cc +obj-y += cmd_ut_lib.o obj-y += hexdump.o obj-y += lmb.o +obj-y += string.o
test/lib/cmd_ut_lib.c new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2019 Heinrich Schuchardt <[email protected]> +* +* Unit tests for library functions +*/ + +#include <common.h> +#include <command.h> +#include <test/lib.h> +#include <test/suites.h> +#include <test/ut.h> + +int do_ut_lib (cmd_tbl_t *cmdtp,int flag,int argc,char *const argv[]) +{ + struct unit_test *tests = ll_entry_start(struct unit_test, lib_test); + const int n_ents = ll_entry_count(struct unit_test, lib_test); + +return cmd_ut_category ("lib" , tests, n_ents, argc, argv); +}
test/lib/string.c new file +194 -0
194 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 1/1 test: provide unit test for memory functions
Quoted 12 lines · Heinrich Schuchardt
Memory functions may have architecture specific implementations. These should be tested.
Provide unit tests for
memset(),memcpy(),memmove().Provide a 'ut lib' sub-command to execute the tests.
Signed-off-by Heinrich Schuchardt <[email protected]>---
v2
vary alignment and length of copied or set memory region
Quoted 13 lines
--- include/test/lib.h | 14 +++ include/test/suites.h | 1 + test/Kconfig | 8 ++ test/cmd_ut.c | 6 ++ test/lib/Makefile | 2 + test/lib/cmd_ut_lib.c | 20 +++++ test/lib/string.c | 194 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 245 insertions(+) create mode 100644 include/test/lib.h create mode 100644 test/lib/cmd_ut_lib.c create mode 100644 test/lib/string.c
PATCH 1/1 test: provide unit test for memory functions
In reply to Heinrich SchuchardtQuoted 9 lines · Heinrich Schuchardt
Memory functions may have architecture specific implementations. These should be tested.
Provide unit tests for
memset(),memcpy(),memmove().Provide a 'ut lib' sub-command to execute the tests.
Signed-off-by Heinrich Schuchardt <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190210/635b8da4/attachment.sig>