summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2022-10-10 08:14:37 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2022-10-11 17:00:50 +0200
commit7876018f73330338c029fa0ec32e59367354a123 (patch)
tree638ab6b8ef94512ae8d08cbcd983aaef219ea173 /test
parent299d87b7ac8a3bb6bbd43d8d5ce07c4fb7bc12a4 (diff)
downloadbarebox-7876018f73330338c029fa0ec32e59367354a123.tar.gz
fs: implement unreaddir
When iterating over a directory, it can be useful to put back the just read directory entry, so it can be retried at a later time. This will be needed for the EFI loader variable support. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20221010061437.2085412-4-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'test')
-rw-r--r--test/self/ramfs.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/self/ramfs.c b/test/self/ramfs.c
index 927b035e1e..f8e1d60a61 100644
--- a/test/self/ramfs.c
+++ b/test/self/ramfs.c
@@ -44,6 +44,7 @@ static inline int get_file_count(int i)
static void test_ramfs(void)
{
+ int files[] = { 1, 3, 5, 7, 11, 13, 17 };
char fname[128];
char *content = NULL;
char *oldpwd = NULL;
@@ -127,6 +128,7 @@ static void test_ramfs(void)
goto out;
i = 1;
+ j = 0;
while ((d = readdir(dir))) {
size_t size = 0;
@@ -150,7 +152,20 @@ static void test_ramfs(void)
free(buf);
- i++;
+ /*
+ * For select files, we test unreaddir once and check if
+ * we read back same element on repeated readdir
+ */
+ for (j = 0; j < ARRAY_SIZE(files); j++) {
+ if (size == files[j]) {
+ ret = unreaddir(dir, d);
+ expect_success(ret, "unreaddir");
+ files[j] = -1;
+ break;
+ }
+ }
+ if (j == ARRAY_SIZE(files))
+ i++;
}
expect_success(i == 90 ? 0 : -EINVAL,