mirror of
https://github.com/Dasharo/zephyr.git
synced 2026-03-06 14:57:20 -08:00
tests/posix/fs: extend readdir test
Test Zephyr POSIX readdir implementation for native POSIX behavior. Signed-off-by: Rico Ganahl <rico.ganahl@bytesatwork.ch>
This commit is contained in:
committed by
Marti Bolivar
parent
5cf1193902
commit
1cf7361f44
@@ -54,6 +54,7 @@ static int test_mkdir(void)
|
||||
static int test_lsdir(const char *path)
|
||||
{
|
||||
DIR *dirp;
|
||||
int res = 0;
|
||||
struct dirent *entry;
|
||||
|
||||
TC_PRINT("\nreaddir test:\n");
|
||||
@@ -67,20 +68,24 @@ static int test_lsdir(const char *path)
|
||||
|
||||
TC_PRINT("\nListing dir %s:\n", path);
|
||||
/* Verify fs_readdir() */
|
||||
entry = readdir(dirp);
|
||||
errno = 0;
|
||||
while ((entry = readdir(dirp)) != NULL) {
|
||||
if (entry->d_name[0] == 0) {
|
||||
res = -EIO;
|
||||
break;
|
||||
}
|
||||
|
||||
/* entry.name[0] == 0 means end-of-dir */
|
||||
if (entry == NULL) {
|
||||
closedir(dirp);
|
||||
return -EIO;
|
||||
} else {
|
||||
TC_PRINT("[FILE] %s\n", entry->d_name);
|
||||
}
|
||||
|
||||
if (errno) {
|
||||
res = -EIO;
|
||||
}
|
||||
|
||||
/* Verify fs_closedir() */
|
||||
closedir(dirp);
|
||||
|
||||
return 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user