Skip to content

testing/testsuites: Add sendfile() cases with a nonblocking pipe. - #4074

Merged
xiaoxiang781216 merged 2 commits into
apache:masterfrom
casaroli:fb-sendfile-count-test-up
Nov 18, 2026
Merged

xiaoxiang781216 merged 2 commits into
apache:masterfrom
casaroli:fb-sendfile-count-test-up

Conversation

@casaroli

@casaroli casaroli commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add two cmocka cases to the kernel fs testsuite: test_nuttx_fs_sendfile03 (with an offset) and test_nuttx_fs_sendfile04 (without an offset). Each case sends a file of 8 KiB to a nonblocking pipe that fills up. A call that sends n bytes must move the offset (or the file position) by n. The call on a full pipe must fail with EAGAIN and must not move it. The pipe must get each byte of the file once, in order.

The cases check the fix in apache/nuttx#21944 ("fs/vfs: Return the count of a partial sendfile()."). Without that fix, the first call puts 1024 bytes into the pipe, returns -1 with EAGAIN, and moves the offset by 1536. Merge this PR after apache/nuttx#21944.

The first commit only adds the two blank lines after declarations that nxstyle asks for in test_nuttx_fs_sendfile01() and test_nuttx_fs_sendfile02(), because CI checks the whole file.

Impact

Only cmocka_fs_test changes. The new cases are built only with CONFIG_PIPES and a CONFIG_DEV_PIPE_SIZE larger than 0, the condition of pipe2(); CM_FS_TEST itself depends only on FS_LINKS. Each case closes its descriptors before it asserts, so the next cases still run. No other case changes.

CI runs the cmocka fs cases one by one from apache/nuttx-ntfc-testing (fs/fs/test_fs_integration.py). A follow-up there adds the two new cases.

Testing

The whole cmocka_fs_test run with CONFIG_TESTS_TESTSUITES, CONFIG_CM_FS_TEST and CONFIG_TESTS_TESTSUITES_MOUNT_DIR="/tmp" (tmpfs):

Configuration nuttx master 61ff9b8b308 with apache/nuttx#21944
qemu-armv8a:nsh (flat, arm64, QEMU HVF) 46 of 48 pass: sendfile03 and sendfile04 fail, "sendfile sent 0 but the offset moved 1536" 48 of 48 pass
rv-virt:nsh (flat, rv32, QEMU TCG) 46 of 48 pass: the same two fail 48 of 48 pass
sim:nsh (flat, x86_64 Linux, the NuttX CI image) 41 of 43 pass: the same two fail 43 of 43 pass

All other cases give the same result before and after. Not run: kernel builds, where cmocka_fs_test does not build on master (fs_file_get_test.c calls the kernel function file_get()).

tools/checkpatch.sh -c -u -m -g passes.

…_test.c.

nxstyle reports "Missing blank line after declarations" in
test_nuttx_fs_sendfile01() and test_nuttx_fs_sendfile02().  Add the two
blank lines.  No functional change.

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
test_nuttx_fs_sendfile03 and test_nuttx_fs_sendfile04 send a file of
8 KiB to a nonblocking pipe that fills up, with and without an offset.
Each call that sends n bytes must move the offset (or the file position)
by n.  The call on a full pipe must fail with EAGAIN and must not move
it.  The pipe must get each byte of the file once, in order.

The cases need a pipe: they are built only with CONFIG_PIPES and a
CONFIG_DEV_PIPE_SIZE larger than 0, as pipe2().

Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
@casaroli
casaroli marked this pull request as ready for review November 17, 2026 23:35
@casaroli
casaroli marked this pull request as draft November 18, 2026 00:38
@casaroli
casaroli marked this pull request as ready for review November 18, 2026 00:38
@github-actions

Copy link
Copy Markdown

🔗 Cross-repo PR dependencies

The read-only Build run reported the following dependent PR(s) and fetched head SHA(s):

CI run: https://github.com/apache/nuttx-apps/actions/runs/44209546106

@xiaoxiang781216
xiaoxiang781216 merged commit a009793 into apache:master Nov 18, 2026
63 of 88 checks passed
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.

3 participants