summaryrefslogtreecommitdiff
path: root/tests/add_by_path.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/add_by_path.c')
-rw-r--r--tests/add_by_path.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/add_by_path.c b/tests/add_by_path.c
index af8dd88..6abf05f 100644
--- a/tests/add_by_path.c
+++ b/tests/add_by_path.c
@@ -29,6 +29,8 @@ int main(void)
sb.st_uid = 1000;
sb.st_gid = 100;
+ assert(fs.root->link_count == 2);
+
a = fstree_add_generic(&fs, "dir", &sb, NULL);
assert(a != NULL);
assert(strcmp(a->name, "dir") == 0);
@@ -36,8 +38,10 @@ int main(void)
assert(a->uid == sb.st_uid);
assert(a->gid == sb.st_gid);
assert(a->parent == fs.root);
+ assert(a->link_count == 2);
assert(a->next == NULL);
assert(fs.root->data.dir.children == a);
+ assert(fs.root->link_count == 3);
assert(!a->data.dir.created_implicitly);
memset(&sb, 0, sizeof(sb));
@@ -52,8 +56,10 @@ int main(void)
assert(b->uid == sb.st_uid);
assert(b->gid == sb.st_gid);
assert(b->parent == fs.root);
+ assert(b->link_count == 1);
assert(b->data.devno == sb.st_rdev);
assert(b->next == a);
+ assert(fs.root->link_count == 4);
assert(fs.root->data.dir.children == b);
assert(fstree_add_generic(&fs, "blkdev/foo", &sb, NULL) == NULL);
@@ -74,21 +80,29 @@ int main(void)
assert(b->mode == sb.st_mode);
assert(b->uid == sb.st_uid);
assert(b->gid == sb.st_gid);
+ assert(b->link_count == 1);
assert(b->parent == a);
assert(b->data.devno == sb.st_rdev);
assert(b->next == NULL);
assert(a->data.dir.children == b);
+ assert(a->link_count == 3);
+ assert(fs.root->link_count == 4);
+
b = fstree_add_generic(&fs, "dir/foo/chrdev", &sb, NULL);
assert(b != NULL);
assert(b->next == NULL);
assert(b->mode == sb.st_mode);
assert(b->uid == sb.st_uid);
assert(b->gid == sb.st_gid);
+ assert(b->link_count == 1);
assert(b->parent != a);
assert(b->parent->parent == a);
assert(b->data.devno == sb.st_rdev);
assert(b->next == NULL);
+
+ assert(a->link_count == 4);
+ assert(fs.root->link_count == 4);
assert(a->data.dir.children != b);
b = b->parent;
@@ -96,6 +110,7 @@ int main(void)
assert(b->mode == (S_IFDIR | 0755));
assert(b->uid == 21);
assert(b->gid == 42);
+ assert(b->link_count == 3);
memset(&sb, 0, sizeof(sb));
sb.st_mode = S_IFDIR | 0750;
@@ -109,6 +124,10 @@ int main(void)
assert(a->mode == sb.st_mode);
assert(a->uid == sb.st_uid);
assert(a->gid == sb.st_gid);
+ assert(a->link_count == 3);
+
+ assert(a->parent->link_count == 4);
+ assert(fs.root->link_count == 4);
assert(fstree_add_generic(&fs, "dir/foo", &sb, NULL) == NULL);
assert(errno == EEXIST);