Skip to content

testing/mm: more iob test cases and GCC-only kasantest flags - #4136

Open
huojianchaoyy wants to merge 5 commits into
apache:masterfrom
huojianchaoyy:ap-mm-iob-tests-v3
Open

huojianchaoyy wants to merge 5 commits into
apache:masterfrom
huojianchaoyy:ap-mm-iob-tests-v3

Conversation

@huojianchaoyy

Copy link
Copy Markdown

Note: Please adhere to Contributing Guidelines.

Summary

IOB test cases and a kasantest build fix from Xiaomi Vela.

  • testing/mm/iob: add iob test for various iob api: besides the throttled/unthrottled copy test, cases for allocation and free, copy in and out, queue operations, chains, clone, pack and contig, packet length update, queue concatenation, tailroom, and the chain-end flag that a queue keeps in the low bits of io_flink.
  • tesitng/mm/iob: fix compile break: iob_add_queue() and iob_concat_queue() cannot fail (the queue allocates nothing, both return 0), so the test no longer checks their return value; the error paths free the queue they filled.
  • testing/mm/iob: add regression test for extended tail chain: a chain extended with iob_copyin() after it was enqueued, then another chain enqueued behind it; covers 69c67a58493.
  • testing/mm/kasantest: guard GCC-only warning flags: -Wno-use-after-free and -Wno-stringop-overflow are passed only with a GCC toolchain, clang warns about these unknown -Wno- options. The other half of the original change, printing tv_sec as intmax_t, is in master already (f9f59bd); the -fno-builtin of master stays.

One follow-up commit, right after the commit it fixes: testing/mm/iob: fix the nxstyle and codespell errors, one-line if statements and a comment that codespell reads as a misspelling.

Impact

  • Test code only: testing/mm/iob and the build flags of testing/mm/kasantest.
  • "Test 10: IOB Pointer Low-Bit Flags" builds four chains of 3, 2, 3 and 1 IOBs, so the iob test needs CONFIG_IOB_NBUFFERS >= 9. With fewer IOBs (sim:nsh has 8) that case fails to allocate its last chain and the test stops there. sim:citest has 128.
  • GCC builds of kasantest keep the same flags.

Testing

Host: Ubuntu 22.04 x86_64, GCC 13.4.0 (sim), CMake 3.23 + Ninja 1.10. Base: nuttx-apps master 9cd18a2, nuttx master f284e6d7a75.

./tools/checkpatch.sh -c -u -m -g HEAD~5..HEAD passes.

Every commit builds without warnings (CMake, incremental) for sim:nsh with MM_IOB, TESTING_IOB, IOB_NBUFFERS=64, MM_KASAN and TESTING_KASAN; the head also builds with Make. kasantest.c is compiled with -fno-builtin -Wno-error -Wno-array-bounds -Wno-unused-value -Wno-unused-variable -Wno-free-nonheap-object -O0 -Wno-use-after-free -Wno-stringop-overflow, the flags of master.

sim:nsh as above, iob:

Test 1 PASSED
...
Test 10 PASSED
Original IOB Test PASSED
=== Test 12: IOB Queue Extend Enqueued Tail Chain ===
Test 12 PASSED
==================================================
ALL IOB TESTS PASSED!
==================================================

With the 8 IOBs of sim:nsh the run stops at Test 10 (ERROR: Failed to allocate first IOB in chain), see Impact.

Not tested: a clang build (no clang toolchain on this host), real hardware.

Donny9 and others added 5 commits November 25, 2026 15:19
So far the test only copied data in and out of IOBs from a throttled
and an unthrottled thread.  Add test cases for the rest of the IOB API:
allocation and free, copy in and out, queue operations, chains, clone,
pack and contig, packet length update, queue concatenation, tailroom,
and the chain-end flag that a queue keeps in the low bits of io_flink.

Assisted-by: Kiro:claude-opus-5-5
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Put the statement of the one-line if blocks that free the IOBs after a
failed allocation on its own line in braces ("Statement on same line as
'if'"), and name the function in the comment that codespell reads as a
misspelling of "copying".

Assisted-by: Kiro:claude-opus-5-5
Signed-off-by: huojianchao <huojianchao@xiaomi.com>
iob_add_queue() and iob_concat_queue() cannot fail: the queue links the
IOBs through the low bits of io_flink and allocates nothing, and both
return 0.  Drop the checks of their return value, and free the queue on
the error paths that return after it was filled.

Assisted-by: Kiro:claude-opus-5-5
Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
Enqueue a chain, extend it past one IOB via iob_copyin(), then
enqueue another chain and verify neither is truncated.

Assisted-by: Kiro:claude-opus-5-5
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
-Wuse-after-free and -Wstringop-overflow exist only in GCC, so clang
warns about the -Wno- forms.  Apply them only for GCC toolchains;
-Wno-unknown-warning-option is no fix either, as GCC rejects that flag.

The other part of the original change, printing tv_sec as intmax_t, is
upstream already as f9f59bd.

Assisted-by: Kiro:claude-opus-5-5
Signed-off-by: hujun5 <hujun5@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.

4 participants