Commit graph

19 commits

Author SHA1 Message Date
zhangyuan29
413d2ddbc3 testing/libc/arch_libc: Cover unaligned src/dst copy paths.
test_strcpy(), test_strncpy() and test_stpcpy() applied the same offset
to the source and to the destination, so both pointers always shared the
same word congruence.  Architecture optimized copy routines take a
different code path when the two offsets differ: a byte prologue to
align the destination, then either a byte fallback or a shift-merge loop
that recombines two source words per store.  None of that was reached by
the test.

Vary the source and destination offsets independently over 0..7 in those
three tests, so both the equal congruence (aligned word copy) and the
unequal congruence (shift-merge) paths are covered, and report both
offsets on failure so a regression points at the offending combination.

Also drop the ARCH_TOOLCHAIN_GNU dependency from TESTING_ARCH_LIBC.  The
test only uses standard C string functions and perf_gettime(), with no
GNU specific construct, so it builds with non GNU toolchains such as
TASKING as well.

Impact: test only, selected by CONFIG_TESTING_ARCH_LIBC (default n).
Dropping the ARCH_TOOLCHAIN_GNU dependency only widens the set of
toolchains that may select the test, no existing 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.  strcpy, strncpy and
stpcpy report PASSED for all 64 offset combinations, and
"arch_libc_test Passed".

Assisted-by: Claude:claude-opus-5
Signed-off-by: zhangyuan29 <zhangyuan29@xiaomi.com>
2026-08-10 16:55:36 -03:00
dengwenqi
7043f96fef testing/libc/arch_libc: Fix out-of-bounds write in memmove test.
The adjacent overlap case in test_memmove() placed the source at a fixed
g_buf1 + align + 64 and the destination one size further, so the
destination tail reached align + 64 + 2 * size.  g_buf1 is only
TEST_BUF_SIZE + MAX_ALIGN (528) bytes, so the larger swept sizes ran off
the end: align=0 with size=255 writes up to offset 573, that is 46 bytes
past the object.  AddressSanitizer aborted arch_libctest with a
global-buffer-overflow.

Start the adjacent layout at g_buf1 + align instead.  The tail then
reaches align + 2 * size, which is at most 7 + 2 * 257 = 521 and stays
inside g_buf1 for every alignment and boundary size that is swept, while
still keeping source and destination exactly adjacent.

Impact: test only, selected by CONFIG_TESTING_ARCH_LIBC (default n).

Testing: built and ran sim:nsh on Linux x86_64 (Ubuntu 24.04,
gcc 13.3.0) with CONFIG_TESTING_ARCH_LIBC=y.  memmove reports PASSED
with no sanitizer report, and "arch_libc_test Passed".

Assisted-by: Claude:claude-opus-5
Signed-off-by: dengwenqi <dengwenqi@xiaomi.com>
2026-08-10 16:55:36 -03:00
anjiahao
0b3049b6ca testing/libc/arch_libc: Add strchrnul test and sweep size boundaries.
Add test_strchrnul() and speed_strchrnul(), selected by the new
CONFIG_TESTING_ARCH_LIBC_STRCHRNUL option, covering the hit, miss and
NUL cases.

Sweep alignment 0..7 and the boundary sizes {0, 1, 7, 8, 9, 15, 16, 17,
31, 32, 33, 63, 64, 65, 127, 128, 129, 255, 256, 257} in the scan
function tests (memcmp, memchr, strlen, strcmp, strchr, strncmp,
strnlen, strrchr) and in memmove.  Those sizes sit on the 8 and 16 byte
chunk edges and on the sub-word tails, so vectorized (NEON/MVE) and
word-at-a-time implementations are stressed exactly at their alignment
and size boundaries instead of only at "nice" lengths.  memmove is
additionally exercised across four overlap layouts: forward, backward,
contained and adjacent.

Impact: test only, selected by CONFIG_TESTING_ARCH_LIBC (default n).

Testing: built and ran qemu-armv7a:nsh (Cortex-A7, generic C
implementation) and sim:nsh on Linux x86_64 (Ubuntu 24.04, gcc 13.3.0)
with CONFIG_TESTING_ARCH_LIBC=y.  All 16 enabled functions report
PASSED and "arch_libc_test Passed".  These tests pass against the
generic C routines, which establishes the correctness baseline before
architecture optimized assembly is introduced.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
2026-08-10 16:55:36 -03:00
Xiang Xiao
ed56c56d7b 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>
2026-08-10 16:55:36 -03:00
Michal Lenc
535ecd8640 testing/libc/fopencookie/fopencookie.c: fix spellcheck
succesfull => successful

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-06-29 12:29:42 +02:00
Michal Lenc
e44c4f370f testing/libc: add stdbit test
Adds the testing application used for CI stdc*_ functions tests.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
2026-06-27 19:28:34 +08:00
cuiziwei
97802bd9e0 testing/libc/popen: add popen/dpopen test for shell and no-shell modes
Add tests for popen()/pclose() and dpopen()/dpclose() that work in
both shell (NSH) and no-shell (direct posix_spawnp) modes.  The test
binary doubles as its own target via the --echo sub-command.

Tests:
 1-4: popen  - basic read, multi-arg, pclose, invalid mode
 5-7: dpopen - basic read, multi-arg, dpclose

Signed-off-by: cuiziwei <cuiziwei@xiaomi.com>
2026-06-02 23:35:28 +08:00
Xiang Xiao
ed746548ca !testing/libc/scanftest: drop CONFIG_LIBC_LONG_LONG from help text
CONFIG_LIBC_LONG_LONG has been removed; long long support is now
unconditional.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2026-05-11 17:38:32 +08:00
Piyush Patle
9d849adfab include/debug.h: Use <nuttx/debug.h> in apps
Replace app-side includes of <debug.h> with <nuttx/debug.h> to use the
header from the NuttX tree explicitly after the header move.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
2026-04-11 10:39:27 -03:00
yukangzhi
3c99bad310 crctest: Test the CRC library that the E2E depends on.
Test the CRC Library defined in the AUTOSAR specification

Signed-off-by: yukangzhi <yukangzhi@xiaomi.com>
2026-01-22 19:51:51 +08:00
tengshuangshuang
b6203955f9 syscall: fix listen case bug
Skip UDP listen test when CONFIG_NET_UDP is disabled to prevent
test failures on configurations without UDP support.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
6249f22f97 tests: fix cache_test and arch_lib_test date style error
Correct date formatting in cache_test and arch_lib_test outputs to
ensure consistent date/time display format across test results.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-22 19:48:57 +08:00
tengshuangshuang
40a890626d testing: specify arch format Kconfig
Specify architecture format in Kconfig to ensure proper configuration
handling for different architectures in testing modules.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2026-01-21 14:44:00 -03:00
tengshuangshuang
844b9c657d apps/testing:fix uclibc atomic make.defs error
In the previous changes to the apps/testing folder, I added an extra slash in the make.defs of uclibcxx, atomic.

Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2025-03-03 16:03:13 +01:00
Tiago Medicci
f139e56cd6 testing/libc/wcstombs: Add testing application for wcstombs
This application test the libc's `wcstombs` function for different
len sizes (bigger than the converted string, exactly the size of
it and smaller than it).
2025-02-06 23:41:31 +01:00
Xiang Xiao
d7be1bd672 testing: Move fs/fopencookie to libc
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-01-26 09:53:02 -03:00
Xiang Xiao
b7f05e89ba testing: Move crypto/setest to drivers and open_memstream to libc
follow the dissusion from:
https://github.com/apache/nuttx-apps/pull/2931

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
2025-01-26 07:32:53 +01:00
tengshuangshuang
0406e6734a apps/testing:move atomic,cpuload,getprime,smp and timerjitter folders to the new sched folder
Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2025-01-26 00:23:15 +08:00
tengshuangshuang
57c8a62e1e apps/testing:move arch_libc, fmemopen, scanftest folders to the new lib folder
Signed-off-by: tengshuangshuang <tengshuangshuang@xiaomi.com>
2025-01-22 17:18:30 +08:00