Repository navigation
testing/mm: more iob test cases and GCC-only kasantest flags - #4136
Conversation
|
@huojianchaoyy please fix the conflict |
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>
037f006 to
da6cbd3
Compare
|
Thanks for the extra IOB coverage and the regression test for apache/nuttx 69c67a584. I checked everything against current nuttx master. Some changes are needed before merge. testing/mm/kasantest: guard GCC-only warning flags
Excluding the clang-based toolchains is safer than requiring GCC: ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG)$(CONFIG_ARCH_TOOLCHAIN_ARMCLANG),)
CFLAGS += -Wno-use-after-free -Wno-stringop-overflow
endifif(NOT CONFIG_ARCH_TOOLCHAIN_CLANG AND NOT CONFIG_ARCH_TOOLCHAIN_ARMCLANG)
list(APPEND CFLAGS -Wno-use-after-free -Wno-stringop-overflow)
endif()(Making the RISC-V GNU choices also select Wording nits, checked with gcc 13 and clang 18:
testing/mm/iobCommit structure. Test 10 makes the suite fail on the default config. Test 12 doesn't detect the bug the way its comment says. I traced the pre-69c67a584
The only check that catches the bug is
69c67a584 fixed DEBUGASSERT used as a test check. Tests 1, 3, 4, 5, 7, 8 and parts of 12 check their results only with Tests that check nothing. Test 9 (tailroom) and most of Test 6 (pack/contig/reserve) only print values. For example, check Smaller things:
|
Note: Please adhere to Contributing Guidelines.
Summary
IOB test cases and a kasantest build fix from Xiaomi Vela.
io_flink.iob_add_queue()andiob_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.iob_copyin()after it was enqueued, then another chain enqueued behind it; covers 69c67a58493.-Wno-use-after-freeand-Wno-stringop-overfloware passed only with a GCC toolchain, clang warns about these unknown-Wno-options. The other half of the original change, printingtv_secasintmax_t, is in master already (f9f59bd); the-fno-builtinof master stays.One follow-up commit, right after the commit it fixes: testing/mm/iob: fix the nxstyle and codespell errors, one-line
ifstatements and a comment that codespell reads as a misspelling.Impact
testing/mm/ioband the build flags oftesting/mm/kasantest.CONFIG_IOB_NBUFFERS>= 9. With fewer IOBs (sim:nshhas 8) that case fails to allocate its last chain and the test stops there.sim:citesthas 128.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..HEADpasses.Every commit builds without warnings (CMake, incremental) for
sim:nshwithMM_IOB,TESTING_IOB,IOB_NBUFFERS=64,MM_KASANandTESTING_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:nshas above,iob:With the 8 IOBs of
sim:nshthe 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.