Skip to content

testing/fs: Fix fd management and formatting issues#3374

Merged
xiaoxiang781216 merged 2 commits intoapache:masterfrom
victor-suisui:20260123
Jan 26, 2026
Merged

testing/fs: Fix fd management and formatting issues#3374
xiaoxiang781216 merged 2 commits intoapache:masterfrom
victor-suisui:20260123

Conversation

@victor-suisui
Copy link

Note: Please adhere to Contributing Guidelines.

Summary

This commit improves the filesystem test suite by addressing both functional and code quality issues:

  1. File Descriptor Management (Commit 1260142)

Removes unnecessary test_state structure usage for tracking file descriptors
Adds missing close(newfd) call in fs_dup_test.c to prevent file descriptor leaks
Simplifies test code by eliminating redundant fd tracking that could lead to incorrect resource management
2. Code Quality and Formatting (Commit 3022918)

Corrects variable naming: writen → written in fs_fsync_test.c
Fixes comment typos: "wirte" → "write", "befor" → "before"
Corrects error message spelling: "descrepancy" → "discrepancy" (7 occurrences)

Impact

Users: No impact on end users; changes are limited to test infrastructure.

Build Process: No changes to build configuration or dependencies.

Testing: Affects 12 filesystem test case files in cases:

Modified for fd management: fs_dup_test.c, fs_file_get_test.c, fs_poll_test.c, fs_readdir_test.c, fs_seek_test.c, fs_truncate_test.c, fs_unlink_test.c, fs_write_test.c
Modified for formatting: fs_fsync_test.c, fs_readdir_test.c, fs_rename_test.c, fs_stream_test.c
Code Quality: Ensures proper file descriptor cleanup, improves readability, and passes static analysis checks.

Testing

cmocka -s cmocka_fs_test -t test_nuttx_fs_dup01
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_dup01
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_dup01
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_file_get01
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_file_get01
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_file_get01
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_poll01
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_poll01
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_poll01
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_readdir01
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_readdir01
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_readdir01
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_seek01
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_seek01
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_seek01
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_seek02
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_seek02
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_seek02
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_truncate01
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_truncate01
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_truncate01
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_unlink01
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_unlink01
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_unlink01
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_write02
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_write02
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_write02
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

cmocka -s cmocka_fs_test -t test_nuttx_fs_write03
[==========] nuttx_fs_test_suites: Running 1 test(s).
[ RUN ] test_nuttx_fs_write03
INFO: lstat /tmp/CM_fs_testdir errno 2
[ OK ] test_nuttx_fs_write03
[==========] nuttx_fs_test_suites: 1 test(s) run.
[ PASSED ] 1 test(s).
Cmocka Test Completed.

Copy link
Contributor

@cederom cederom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @victor-suisui for the fix and perfect PR description including test logs :-)

You can only update git commit message with:

Removes unnecessary test_state structure usage for tracking file descriptors
Adds missing close(newfd) call in fs_dup_test.c to prevent file descriptor leaks
Simplifies test code by eliminating redundant fd tracking that could lead to incorrect resource management

Let us know when the PR is ready so we can launch CI, veryfiy, and merge :-)

remove test_state of fs test cases

Removes unnecessary test_state structure usage for tracking file descriptors
Adds missing close(newfd) call in fs_dup_test.c to prevent file descriptor leaks
Simplifies test code by eliminating redundant fd tracking that could lead to incorrect resource management

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
fix the typo error of fs cases

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
@victor-suisui
Copy link
Author

Thank you @victor-suisui for the fix and perfect PR description including test logs :-)

You can only update git commit message with:

Removes unnecessary test_state structure usage for tracking file descriptors
Adds missing close(newfd) call in fs_dup_test.c to prevent file descriptor leaks
Simplifies test code by eliminating redundant fd tracking that could lead to incorrect resource management

Let us know when the PR is ready so we can launch CI, veryfiy, and merge :-)

Thank you for your comment! I have updated git commit message!

@victor-suisui victor-suisui marked this pull request as ready for review January 26, 2026 06:40
@jerpelea jerpelea changed the title fs/test: Fix fd management and formatting issues testing/fs: Fix fd management and formatting issues Jan 26, 2026
@xiaoxiang781216 xiaoxiang781216 merged commit 9c02294 into apache:master Jan 26, 2026
40 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.

6 participants