aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree/test
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 08:51:26 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 11:17:51 +0200
commit75fb524b5702bca4f8467309f7d95f9937ec6683 (patch)
treeb47a037c0f24873a9fc5b3f5b08583c9ad90de08 /lib/fstree/test
parenta13df03fddd9499960d4653aaee0970983b65f73 (diff)
libfstree: get rid of dir_info_t
The single boolean created_implicitly can be replaced with a general purpose flag field. The "children" pointer can then be hoisted directly into the data union of tree_node_t. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/test')
-rw-r--r--lib/fstree/test/add_by_path.c14
-rw-r--r--lib/fstree/test/fstree_sort.c16
-rw-r--r--lib/fstree/test/gen_inode_numbers.c8
-rw-r--r--lib/fstree/test/mknode_dir.c6
4 files changed, 22 insertions, 22 deletions
diff --git a/lib/fstree/test/add_by_path.c b/lib/fstree/test/add_by_path.c
index 76bae6d..7df1e55 100644
--- a/lib/fstree/test/add_by_path.c
+++ b/lib/fstree/test/add_by_path.c
@@ -40,9 +40,9 @@ int main(int argc, char **argv)
TEST_ASSERT(a->parent == fs.root);
TEST_EQUAL_UI(a->link_count, 2);
TEST_NULL(a->next);
- TEST_ASSERT(fs.root->data.dir.children == a);
+ TEST_ASSERT(fs.root->data.children == a);
TEST_EQUAL_UI(fs.root->link_count, 3);
- TEST_ASSERT(!a->data.dir.created_implicitly);
+ TEST_ASSERT(!(a->flags & FLAG_DIR_CREATED_IMPLICITLY));
memset(&sb, 0, sizeof(sb));
sb.st_mode = S_IFBLK | 0640;
@@ -60,7 +60,7 @@ int main(int argc, char **argv)
TEST_EQUAL_UI(b->data.devno, sb.st_rdev);
TEST_ASSERT(b->next == a);
TEST_EQUAL_UI(fs.root->link_count, 4);
- TEST_ASSERT(fs.root->data.dir.children == b);
+ TEST_ASSERT(fs.root->data.children == b);
TEST_NULL(fstree_add_generic(&fs, "blkdev/foo", &sb, NULL));
TEST_EQUAL_UI(errno, ENOTDIR);
@@ -84,7 +84,7 @@ int main(int argc, char **argv)
TEST_ASSERT(b->parent == a);
TEST_EQUAL_UI(b->data.devno, sb.st_rdev);
TEST_NULL(b->next);
- TEST_ASSERT(a->data.dir.children == b);
+ TEST_ASSERT(a->data.children == b);
TEST_EQUAL_UI(a->link_count, 3);
TEST_EQUAL_UI(fs.root->link_count, 4);
@@ -103,10 +103,10 @@ int main(int argc, char **argv)
TEST_EQUAL_UI(a->link_count, 4);
TEST_EQUAL_UI(fs.root->link_count, 4);
- TEST_ASSERT(a->data.dir.children != b);
+ TEST_ASSERT(a->data.children != b);
b = b->parent;
- TEST_ASSERT(b->data.dir.created_implicitly);
+ TEST_ASSERT((b->flags & FLAG_DIR_CREATED_IMPLICITLY));
TEST_EQUAL_UI(b->mode, S_IFDIR | 0755);
TEST_EQUAL_UI(b->uid, 21);
TEST_EQUAL_UI(b->gid, 42);
@@ -120,7 +120,7 @@ int main(int argc, char **argv)
a = fstree_add_generic(&fs, "dir/foo", &sb, NULL);
TEST_NOT_NULL(a);
TEST_ASSERT(a == b);
- TEST_ASSERT(!a->data.dir.created_implicitly);
+ TEST_ASSERT(!(a->flags & FLAG_DIR_CREATED_IMPLICITLY));
TEST_EQUAL_UI(a->mode, sb.st_mode);
TEST_EQUAL_UI(a->uid, sb.st_uid);
TEST_EQUAL_UI(a->gid, sb.st_gid);
diff --git a/lib/fstree/test/fstree_sort.c b/lib/fstree/test/fstree_sort.c
index 0d18ac7..fc44899 100644
--- a/lib/fstree/test/fstree_sort.c
+++ b/lib/fstree/test/fstree_sort.c
@@ -30,25 +30,25 @@ int main(int argc, char **argv)
a = fstree_mknode(fs.root, "a", 1, NULL, &sb);
TEST_NOT_NULL(a);
- TEST_ASSERT(fs.root->data.dir.children == a);
+ TEST_ASSERT(fs.root->data.children == a);
TEST_NULL(a->next);
b = fstree_mknode(fs.root, "b", 1, NULL, &sb);
TEST_NOT_NULL(a);
- TEST_ASSERT(fs.root->data.dir.children == a);
+ TEST_ASSERT(fs.root->data.children == a);
TEST_ASSERT(a->next == b);
TEST_NULL(b->next);
c = fstree_mknode(fs.root, "c", 1, NULL, &sb);
TEST_NOT_NULL(c);
- TEST_ASSERT(fs.root->data.dir.children == a);
+ TEST_ASSERT(fs.root->data.children == a);
TEST_ASSERT(a->next == b);
TEST_ASSERT(b->next == c);
TEST_NULL(c->next);
d = fstree_mknode(fs.root, "d", 1, NULL, &sb);
TEST_NOT_NULL(d);
- TEST_ASSERT(fs.root->data.dir.children == a);
+ TEST_ASSERT(fs.root->data.children == a);
TEST_ASSERT(a->next == b);
TEST_ASSERT(b->next == c);
TEST_ASSERT(c->next == d);
@@ -62,25 +62,25 @@ int main(int argc, char **argv)
d = fstree_mknode(fs.root, "d", 1, NULL, &sb);
TEST_NOT_NULL(d);
- TEST_ASSERT(fs.root->data.dir.children == d);
+ TEST_ASSERT(fs.root->data.children == d);
TEST_NULL(d->next);
c = fstree_mknode(fs.root, "c", 1, NULL, &sb);
TEST_NOT_NULL(c);
- TEST_ASSERT(fs.root->data.dir.children == c);
+ TEST_ASSERT(fs.root->data.children == c);
TEST_ASSERT(c->next == d);
TEST_NULL(d->next);
b = fstree_mknode(fs.root, "b", 1, NULL, &sb);
TEST_NOT_NULL(b);
- TEST_ASSERT(fs.root->data.dir.children == b);
+ TEST_ASSERT(fs.root->data.children == b);
TEST_ASSERT(b->next == c);
TEST_ASSERT(c->next == d);
TEST_NULL(d->next);
a = fstree_mknode(fs.root, "a", 1, NULL, &sb);
TEST_NOT_NULL(a);
- TEST_ASSERT(fs.root->data.dir.children == a);
+ TEST_ASSERT(fs.root->data.children == a);
TEST_ASSERT(a->next == b);
TEST_ASSERT(b->next == c);
TEST_ASSERT(c->next == d);
diff --git a/lib/fstree/test/gen_inode_numbers.c b/lib/fstree/test/gen_inode_numbers.c
index bb8c976..b65f64b 100644
--- a/lib/fstree/test/gen_inode_numbers.c
+++ b/lib/fstree/test/gen_inode_numbers.c
@@ -24,10 +24,10 @@ static void check_children_before_root(tree_node_t *root)
{
tree_node_t *n;
- for (n = root->data.dir.children; n != NULL; n = n->next)
+ for (n = root->data.children; n != NULL; n = n->next)
TEST_LESS_THAN_UI(n->inode_num, root->inode_num);
- for (n = root->data.dir.children; n != NULL; n = n->next)
+ for (n = root->data.children; n != NULL; n = n->next)
check_children_before_root(n);
}
@@ -35,13 +35,13 @@ static void check_children_continuous(tree_node_t *root)
{
tree_node_t *n;
- for (n = root->data.dir.children; n != NULL; n = n->next) {
+ for (n = root->data.children; n != NULL; n = n->next) {
if (n->next != NULL) {
TEST_EQUAL_UI(n->next->inode_num, (n->inode_num + 1));
}
}
- for (n = root->data.dir.children; n != NULL; n = n->next)
+ for (n = root->data.children; n != NULL; n = n->next)
check_children_continuous(n);
}
diff --git a/lib/fstree/test/mknode_dir.c b/lib/fstree/test/mknode_dir.c
index dd7eba7..a5f6d9a 100644
--- a/lib/fstree/test/mknode_dir.c
+++ b/lib/fstree/test/mknode_dir.c
@@ -31,7 +31,7 @@ int main(int argc, char **argv)
TEST_EQUAL_UI(root->link_count, 2);
TEST_ASSERT(root->name >= (char *)root->payload);
TEST_STR_EQUAL(root->name, "rootdir");
- TEST_NULL(root->data.dir.children);
+ TEST_NULL(root->data.children);
TEST_NULL(root->parent);
TEST_NULL(root->next);
@@ -40,7 +40,7 @@ int main(int argc, char **argv)
TEST_NULL(a->next);
TEST_EQUAL_UI(a->link_count, 2);
TEST_EQUAL_UI(root->link_count, 3);
- TEST_ASSERT(root->data.dir.children == a);
+ TEST_ASSERT(root->data.children == a);
TEST_NULL(root->parent);
TEST_NULL(root->next);
@@ -48,7 +48,7 @@ int main(int argc, char **argv)
TEST_ASSERT(a->parent == root);
TEST_ASSERT(b->parent == root);
TEST_EQUAL_UI(b->link_count, 2);
- TEST_ASSERT(root->data.dir.children == a);
+ TEST_ASSERT(root->data.children == a);
TEST_ASSERT(a->next == b);
TEST_EQUAL_UI(root->link_count, 4);
TEST_NULL(b->next);