diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-28 19:36:56 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-29 00:26:32 +0200 |
commit | 2285036e10863aba48dc6eed3c1a791118d11956 (patch) | |
tree | d94808261eb23df4c25db3c6de6dd45df2e692c7 /bin/gensquashfs/test | |
parent | 46b01473eee7301cb7b49533af16abe0ee15c286 (diff) |
gensquashfs: Dismantle the scan_dir wrapper
Create the directory iterator externally and pass it to fstree_from_dir.
The unit test is also removed, because the heavy lifting is now done
outside the function.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'bin/gensquashfs/test')
-rw-r--r-- | bin/gensquashfs/test/fstree_from_dir.c | 181 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dira/file_a0 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dira/file_a1 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dira/file_a2 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dirb/file_b0 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dirb/file_b1 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dirb/file_b2 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dirc/file_c0 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dirc/file_c1 | 0 | ||||
-rw-r--r-- | bin/gensquashfs/test/testdir/dirc/file_c2 | 0 |
10 files changed, 0 insertions, 181 deletions
diff --git a/bin/gensquashfs/test/fstree_from_dir.c b/bin/gensquashfs/test/fstree_from_dir.c deleted file mode 100644 index 7d6fc06..0000000 --- a/bin/gensquashfs/test/fstree_from_dir.c +++ /dev/null @@ -1,181 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * fstree_from_dir.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "util/test.h" -#include "mkfs.h" - -static void check_hierarchy(tree_node_t *root, bool recursive) -{ - tree_node_t *n, *m; - - n = root->data.children; - TEST_NOT_NULL(n); - TEST_STR_EQUAL(n->name, "dira"); - TEST_ASSERT(S_ISDIR(n->mode)); - TEST_ASSERT(n->parent == root); - - if (recursive) { - m = n->data.children; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_a0"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_a1"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_a2"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NULL(m); - } else { - TEST_NULL(n->data.children); - } - - n = n->next; - TEST_NOT_NULL(n); - TEST_STR_EQUAL(n->name, "dirb"); - TEST_ASSERT(S_ISDIR(n->mode)); - TEST_ASSERT(n->parent == root); - - if (recursive) { - m = n->data.children; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_b0"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_b1"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_b2"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NULL(m); - } else { - TEST_NULL(n->data.children); - } - - n = n->next; - TEST_NOT_NULL(n); - TEST_STR_EQUAL(n->name, "dirc"); - TEST_ASSERT(S_ISDIR(n->mode)); - TEST_ASSERT(n->parent == root); - - if (recursive) { - m = n->data.children; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_c0"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_c1"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NOT_NULL(m); - TEST_STR_EQUAL(m->name, "file_c2"); - TEST_ASSERT(S_ISREG(m->mode)); - TEST_ASSERT(m->parent == n); - - m = m->next; - TEST_NULL(m); - } else { - TEST_NULL(n->data.children); - } - - n = n->next; - TEST_NULL(n); -} - -int main(int argc, char **argv) -{ - fstree_defaults_t fsd; - struct stat sb; - tree_node_t *n; - fstree_t fs; - (void)argc; (void)argv; - - TEST_ASSERT(parse_fstree_defaults(&fsd, NULL) == 0); - - /* recursively scan into root */ - TEST_ASSERT(fstree_init(&fs, &fsd) == 0); - TEST_ASSERT(fstree_from_dir(&fs, fs.root, TEST_PATH, - NULL, NULL, 0) == 0); - - fstree_post_process(&fs); - check_hierarchy(fs.root, true); - fstree_cleanup(&fs); - - /* non-recursively scan into root */ - TEST_ASSERT(fstree_init(&fs, &fsd) == 0); - TEST_ASSERT(fstree_from_dir(&fs, fs.root, TEST_PATH, NULL, NULL, - DIR_SCAN_NO_RECURSION) == 0); - - fstree_post_process(&fs); - check_hierarchy(fs.root, false); - fstree_cleanup(&fs); - - /* recursively scan into a sub-directory of root */ - memset(&sb, 0, sizeof(sb)); - sb.st_mode = S_IFDIR | 0755; - - TEST_ASSERT(fstree_init(&fs, &fsd) == 0); - - n = fstree_mknode(fs.root, "foodir", 6, NULL, &sb); - TEST_NOT_NULL(n); - fs.root->data.children = n; - - TEST_ASSERT(fstree_from_dir(&fs, n, TEST_PATH, NULL, NULL, 0) == 0); - - TEST_ASSERT(fs.root->data.children == n); - TEST_NULL(n->next); - - fstree_post_process(&fs); - check_hierarchy(n, true); - fstree_cleanup(&fs); - - /* non-recursively scan into a sub-directory of root */ - memset(&sb, 0, sizeof(sb)); - sb.st_mode = S_IFDIR | 0755; - - TEST_ASSERT(fstree_init(&fs, &fsd) == 0); - - n = fstree_mknode(fs.root, "foodir", 6, NULL, &sb); - TEST_NOT_NULL(n); - fs.root->data.children = n; - - TEST_ASSERT(fstree_from_dir(&fs, n, TEST_PATH, NULL, NULL, - DIR_SCAN_NO_RECURSION) == 0); - - TEST_ASSERT(fs.root->data.children == n); - TEST_NULL(n->next); - - fstree_post_process(&fs); - check_hierarchy(n, false); - fstree_cleanup(&fs); - - return EXIT_SUCCESS; -} diff --git a/bin/gensquashfs/test/testdir/dira/file_a0 b/bin/gensquashfs/test/testdir/dira/file_a0 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dira/file_a0 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dira/file_a1 b/bin/gensquashfs/test/testdir/dira/file_a1 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dira/file_a1 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dira/file_a2 b/bin/gensquashfs/test/testdir/dira/file_a2 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dira/file_a2 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dirb/file_b0 b/bin/gensquashfs/test/testdir/dirb/file_b0 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dirb/file_b0 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dirb/file_b1 b/bin/gensquashfs/test/testdir/dirb/file_b1 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dirb/file_b1 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dirb/file_b2 b/bin/gensquashfs/test/testdir/dirb/file_b2 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dirb/file_b2 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dirc/file_c0 b/bin/gensquashfs/test/testdir/dirc/file_c0 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dirc/file_c0 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dirc/file_c1 b/bin/gensquashfs/test/testdir/dirc/file_c1 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dirc/file_c1 +++ /dev/null diff --git a/bin/gensquashfs/test/testdir/dirc/file_c2 b/bin/gensquashfs/test/testdir/dirc/file_c2 deleted file mode 100644 index e69de29..0000000 --- a/bin/gensquashfs/test/testdir/dirc/file_c2 +++ /dev/null |