Skip to content

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.

remove test_state of fs test cases

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

Signed-off-by: wangxingxing <wangxingxing@xiaomi.com>
char buffd[5] = "hello";
char bufnewfd[8] = "littleFS";
char readbuf[20] = "";
struct fs_testsuites_state_s *test_state;
Copy link
Contributor

@cederom cederom Jan 23, 2026

Choose a reason for hiding this comment

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

Thank you @victor-suisui in the git commit message some short explanation for anyone reading the git log why this is removed would be welcome.. what it fixes, updates, maybe it was unused, is it safe to remove? :-)

Description from the PR is perfect, can you please copy-paste it into the git message?

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

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 :-)

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