Skip to content

Conversation

@victor-suisui
Copy link

Summary
This PR contains a series of fixes and improvements to the file system test cases in [fs]

fdcheck: fix fd close in other thread (34d2d3ebd1b)
Fix file descriptor leak issue where fd was stored in test_state for deferred close, but could fail when CONFIG_FDCHECK is enabled because fd cannot be closed in a different thread.
Modified test cases to close fd directly within the same test function instead of relying on teardown function.
Affected files: fs_creat_test.c, fs_dup2_test.c, fs_eventfd_test.c, fs_fcntl_test.c, fs_fstat_test.c, fs_fstatfs_test.c, fs_fsync_test.c, fs_open_test.c, fs_pread_test.c, fs_pwrite_test.c, fs_read_test.c, fs_readlink_test.c, fs_stat_test.c, fs_write_test.c

eventfd_test: avoid the orphan Thread (b4c00e9a57a)
Replace sleep() with pthread_join() to properly wait for the child thread to finish, avoiding orphan threads.
Change sleep(1) to usleep(1000) to reduce test time while maintaining synchronization.
Fix loop iteration count mismatch between reader thread (6 iterations) and writer (5 iterations).

fs/test: remove the usleep of eventfd read to solve the question of sem wait (74dda2d1b88)
Remove unnecessary usleep(1000) in the read thread of eventfd test.
The eventfd read operation will block and wait for data naturally via semaphore, no additional delay is needed.

testing/fs: reduce the test time of fs test (eb1d9a48c94)
Reduce TEST_NUM from 1000 to 100 in fs_opendir_test.c
Reduce loop count from 100 to 30 in fs_stream_test.c
These changes significantly reduce test execution time while still maintaining adequate test coverage.

Impact
Users: No impact on end users. These changes only affect test cases.
Build process: No impact.
Compatibility: Improves compatibility with CONFIG_FDCHECK enabled configurations.
Testing: Tests run faster and more reliably, especially when fdcheck is enabled.

Testing
cmocka -s cmocka_fs_test -t test_nuttx_fs_creat01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_fcntl01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_fstat01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_fstatfs01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_fsync01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_open01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_pread01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_pwrite01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_readlink01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_write01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_eventfd [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_opendir02 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_stream02 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_read01 [PASSED]
cmocka -s cmocka_fs_test -t test_nuttx_fs_stat01 [PASSED]

guohao15 and others added 4 commits January 28, 2026 13:49
Fix file descriptor leak issue where fd was stored in test_state for deferred close, but could fail when CONFIG_FDCHECK is enabled because fd cannot be closed in a different thread.

Signed-off-by: guohao15 <[email protected]>
Replace sleep() with pthread_join() to properly wait for the child thread to finish, avoiding orphan threads.
Change sleep(1) to usleep(1000) to reduce test time while maintaining synchronization.
Fix loop iteration count mismatch between reader thread (6 iterations) and writer (5 iterations).

Signed-off-by: ligd <[email protected]>
…of sem wait

Remove unnecessary usleep(1000) in the read thread of eventfd test.
The eventfd read operation will block and wait for data naturally via semaphore, no additional delay is needed.

Signed-off-by: wangxingxing <[email protected]>
Reduce TEST_NUM from 1000 to 100 in fs_opendir_test.c
Reduce loop count from 100 to 30 in fs_stream_test.c

Signed-off-by: wangxingxing <[email protected]>
@acassis acassis merged commit 42e3566 into apache:master Jan 28, 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