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:
Rico Ganahl
2022-04-20 14:26:27 +02:00
committed by Marti Bolivar
parent 5cf1193902
commit 1cf7361f44
+12 -7
View File
@@ -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;
}
/**