Skip to content

testing/libc/ring: add cmocka tests for the lock-free ring - #4075

Open
CV-Bowen wants to merge 1 commit into
apache:masterfrom
CV-Bowen:up/P91-ringtest
Open

CV-Bowen wants to merge 1 commit into
apache:masterfrom
CV-Bowen:up/P91-ringtest

Conversation

@CV-Bowen

Copy link
Copy Markdown
Contributor

Summary

Add a cmocka test suite for the lock-free ring queue in
include/nuttx/ring.h (apache/nuttx#21945), covering all four modes
(SPSC/MPSC/SPMC/MPMC):

  • basic and batch enqueue/dequeue, full and empty boundaries, partial
    batches, index wrap-around, non-power-of-two capacities
  • ring_alloc(), overwrite (discard count), skip
  • init and warm-restart recovery: rewind, corrupted or resized blob,
    interrupted multi-producer commit, SPSC slave init (-EAGAIN/-EINVAL),
    concurrent init where exactly one caller runs the init body
  • pthread producer/consumer stress

Enable CONFIG_TESTING_RING (needs CONFIG_TESTING_CMOCKA) and run
ring_test from nsh.

Depends on apache/nuttx#21945.

Impact

New test application only, off by default.

Testing

Host: Ubuntu 22.04.5 LTS x86_64; sim: gcc 13.1.0; qemu-armv8a: aarch64-none-elf-gcc 12.2.1, QEMU 10.2.1

Same runs as apache/nuttx#21945, with the nuttx PR applied:

configure result
sim:nsh 80/80 PASS, 0 warnings
qemu-armv8a:nsh_smp (CONFIG_SMP_NCPUS=2) 80/80 PASS, 0 warnings
sim:nsh
[==========] g_spsc_local_tests: 36 test(s) run.
[  PASSED  ] 36 test(s).
[==========] g_mpsc_local_tests: 11 test(s) run.
[  PASSED  ] 11 test(s).
[==========] g_spmc_local_tests: 11 test(s) run.
[  PASSED  ] 11 test(s).
[==========] g_mpmc_local_tests: 22 test(s) run.
[  PASSED  ] 22 test(s).

Add a cmocka suite for include/nuttx/ring.h covering all four modes
(SPSC/MPSC/SPMC/MPMC): basic and batch enqueue/dequeue, full and empty
boundaries, partial batches, index wraparound, non-power-of-two
capacities, ring_alloc(), overwrite, skip, init and warm-restart
recovery (rewind, corrupted or resized blob, interrupted MP commit,
SPSC slave, concurrent init), and pthread producer/consumer stress.

Enable CONFIG_TESTING_RING and run "ring_test" from nsh.

Signed-off-by: wangjianyu3 <wangjianyu3@xiaomi.com>
Signed-off-by: Bowen Wang <wangbowen6@xiaomi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant