testing/libc/arch_libc: Add tests for all string/memory functions.

The arch_libc test only covered strcpy, so the architecture optimized
implementations of the remaining string and memory routines were never
exercised by the test suite.

Extend the test to also cover memcpy, memmove, memset, memcmp, memchr,
strlen, strcmp, strchr, strncmp, strnlen, strncpy, stpcpy, strcat and
strrchr:

* Every function gets a correctness test that sweeps the buffer
  alignment and the transfer size and compares the result against the
  expected value.
* Every function gets a speed test that reports the average cycle count
  measured with perf_gettime().
* Every individual test is selected by its own
  CONFIG_TESTING_ARCH_LIBC_<FUNC> option (default y), so a target can
  drop the ones it does not need.

Impact: test only.  Nothing is built unless CONFIG_TESTING_ARCH_LIBC
(default n) is selected, so no existing board configuration changes.

Testing: built and ran sim:nsh on Linux x86_64 (Ubuntu 24.04,
gcc 13.3.0) with CONFIG_TESTING_ARCH_LIBC=y.  All 15 enabled functions
report PASSED and "arch_libc_test Passed".

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2026-03-13 16:33:37 +08:00 committed by Alan C. Assis
parent cc8a6c8b85
commit ed56c56d7b
2 changed files with 1056 additions and 144 deletions

View file

@ -12,10 +12,66 @@ config TESTING_ARCH_LIBC
if TESTING_ARCH_LIBC
config TESTING_ARCH_LIBC_MEMCHR
bool "test memchr"
default y
config TESTING_ARCH_LIBC_MEMCMP
bool "test memcmp"
default y
config TESTING_ARCH_LIBC_MEMCPY
bool "test memcpy"
default y
config TESTING_ARCH_LIBC_MEMMOVE
bool "test memmove"
default y
config TESTING_ARCH_LIBC_MEMSET
bool "test memset"
default y
config TESTING_ARCH_LIBC_STRCHR
bool "test strchr"
default y
config TESTING_ARCH_LIBC_STRCMP
bool "test strcmp"
default y
config TESTING_ARCH_LIBC_STRCPY
bool "test strcpy"
default y
config TESTING_ARCH_LIBC_STRLEN
bool "test strlen"
default y
config TESTING_ARCH_LIBC_STRNCMP
bool "test strncmp"
default y
config TESTING_ARCH_LIBC_STRNLEN
bool "test strnlen"
default y
config TESTING_ARCH_LIBC_STRNCPY
bool "test strncpy"
default y
config TESTING_ARCH_LIBC_STPCPY
bool "test stpcpy"
default y
config TESTING_ARCH_LIBC_STRCAT
bool "test strcat"
default y
config TESTING_ARCH_LIBC_STRRCHR
bool "test strrchr"
default y
config TESTING_ARCH_LIBC_PROGNAME
string "Program name"
default "arch_libctest"

File diff suppressed because it is too large Load diff