diff options
| author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-01-31 11:30:46 +0100 | 
|---|---|---|
| committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-01-31 18:04:25 +0100 | 
| commit | 72c8155d9fc0eaeac72c053f46ebb7b231d4596a (patch) | |
| tree | 5758865289c52fa93f56e3fe743bb40c283c5233 /tests/libfstree | |
| parent | cdccc69c62579b0c13b35fad0728079652b8f3c9 (diff) | |
Reintegrate test code with library code
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/libfstree')
| -rw-r--r-- | tests/libfstree/Makemodule.am | 38 | ||||
| -rw-r--r-- | tests/libfstree/add_by_path.c | 134 | ||||
| -rw-r--r-- | tests/libfstree/fstree_init.c | 50 | ||||
| -rw-r--r-- | tests/libfstree/fstree_sort.c | 88 | ||||
| -rw-r--r-- | tests/libfstree/gen_inode_numbers.c | 90 | ||||
| -rw-r--r-- | tests/libfstree/get_path.c | 59 | ||||
| -rw-r--r-- | tests/libfstree/mknode_dir.c | 63 | ||||
| -rw-r--r-- | tests/libfstree/mknode_reg.c | 42 | ||||
| -rw-r--r-- | tests/libfstree/mknode_simple.c | 98 | ||||
| -rw-r--r-- | tests/libfstree/mknode_slink.c | 54 | 
10 files changed, 0 insertions, 716 deletions
diff --git a/tests/libfstree/Makemodule.am b/tests/libfstree/Makemodule.am deleted file mode 100644 index 14e1b38..0000000 --- a/tests/libfstree/Makemodule.am +++ /dev/null @@ -1,38 +0,0 @@ -FSTDATADIR=$(top_srcdir)/tests/libfstree - -test_mknode_simple_SOURCES = tests/libfstree/mknode_simple.c -test_mknode_simple_LDADD = libfstree.a libcompat.a - -test_mknode_slink_SOURCES = tests/libfstree/mknode_slink.c -test_mknode_slink_LDADD = libfstree.a libcompat.a - -test_mknode_reg_SOURCES = tests/libfstree/mknode_reg.c -test_mknode_reg_LDADD = libfstree.a libcompat.a - -test_mknode_dir_SOURCES = tests/libfstree/mknode_dir.c -test_mknode_dir_LDADD = libfstree.a libcompat.a - -test_gen_inode_numbers_SOURCES = tests/libfstree/gen_inode_numbers.c -test_gen_inode_numbers_LDADD = libfstree.a libutil.a libcompat.a - -test_add_by_path_SOURCES = tests/libfstree/add_by_path.c -test_add_by_path_LDADD = libfstree.a libutil.a libcompat.a - -test_get_path_SOURCES = tests/libfstree/get_path.c -test_get_path_LDADD = libfstree.a libutil.a libcompat.a - -test_fstree_sort_SOURCES = tests/libfstree/fstree_sort.c -test_fstree_sort_CPPFLAGS = $(AM_CPPFLAGS) -I$(top_srcdir)/lib/fstree -test_fstree_sort_LDADD = libfstree.a libio.a libutil.a libcompat.a - -test_fstree_init_SOURCES = tests/libfstree/fstree_init.c -test_fstree_init_LDADD = libfstree.a libio.a libutil.a libcompat.a - -FSTREE_TESTS = \ -	test_mknode_simple test_mknode_slink \ -	test_mknode_reg test_mknode_dir test_gen_inode_numbers \ -	test_add_by_path test_get_path test_fstree_sort \ -	test_fstree_init - -check_PROGRAMS += $(FSTREE_TESTS) -TESTS += $(FSTREE_TESTS) diff --git a/tests/libfstree/add_by_path.c b/tests/libfstree/add_by_path.c deleted file mode 100644 index 97e5a60..0000000 --- a/tests/libfstree/add_by_path.c +++ /dev/null @@ -1,134 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * add_by_path.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -int main(int argc, char **argv) -{ -	tree_node_t *a, *b; -	struct stat sb; -	fstree_t fs; -	char *opts; -	(void)argc; (void)argv; - -	opts = strdup("mode=0755,uid=21,gid=42"); -	TEST_ASSERT(fstree_init(&fs, opts) == 0); -	free(opts); - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFDIR | 0750; -	sb.st_uid = 1000; -	sb.st_gid = 100; - -	TEST_EQUAL_UI(fs.root->link_count, 2); - -	a = fstree_add_generic(&fs, "dir", &sb, NULL); -	TEST_NOT_NULL(a); -	TEST_STR_EQUAL(a->name, "dir"); -	TEST_EQUAL_UI(a->mode, sb.st_mode); -	TEST_EQUAL_UI(a->uid, sb.st_uid); -	TEST_EQUAL_UI(a->gid, sb.st_gid); -	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_EQUAL_UI(fs.root->link_count, 3); -	TEST_ASSERT(!a->data.dir.created_implicitly); - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFBLK | 0640; -	sb.st_rdev = 1234; - -	b = fstree_add_generic(&fs, "blkdev", &sb, NULL); -	TEST_NOT_NULL(b); -	TEST_ASSERT(b != a); -	TEST_STR_EQUAL(b->name, "blkdev"); -	TEST_EQUAL_UI(b->mode, sb.st_mode); -	TEST_EQUAL_UI(b->uid, sb.st_uid); -	TEST_EQUAL_UI(b->gid, sb.st_gid); -	TEST_ASSERT(b->parent == fs.root); -	TEST_EQUAL_UI(b->link_count, 1); -	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_NULL(fstree_add_generic(&fs, "blkdev/foo", &sb, NULL)); -	TEST_EQUAL_UI(errno, ENOTDIR); - -	TEST_NULL(fstree_add_generic(&fs, "dir", &sb, NULL)); -	TEST_EQUAL_UI(errno, EEXIST); - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFDIR | 0755; -	TEST_NULL(fstree_add_generic(&fs, "dir", &sb, NULL)); -	TEST_EQUAL_UI(errno, EEXIST); - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFCHR | 0444; -	b = fstree_add_generic(&fs, "dir/chrdev", &sb, NULL); -	TEST_NOT_NULL(b); -	TEST_EQUAL_UI(b->mode, sb.st_mode); -	TEST_EQUAL_UI(b->uid, sb.st_uid); -	TEST_EQUAL_UI(b->gid, sb.st_gid); -	TEST_EQUAL_UI(b->link_count, 1); -	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_EQUAL_UI(a->link_count, 3); -	TEST_EQUAL_UI(fs.root->link_count, 4); - -	b = fstree_add_generic(&fs, "dir/foo/chrdev", &sb, NULL); -	TEST_NOT_NULL(b); -	TEST_NULL(b->next); -	TEST_EQUAL_UI(b->mode, sb.st_mode); -	TEST_EQUAL_UI(b->uid, sb.st_uid); -	TEST_EQUAL_UI(b->gid, sb.st_gid); -	TEST_EQUAL_UI(b->link_count, 1); -	TEST_ASSERT(b->parent != a); -	TEST_ASSERT(b->parent->parent == a); -	TEST_EQUAL_UI(b->data.devno, sb.st_rdev); -	TEST_NULL(b->next); - -	TEST_EQUAL_UI(a->link_count, 4); -	TEST_EQUAL_UI(fs.root->link_count, 4); -	TEST_ASSERT(a->data.dir.children != b); - -	b = b->parent; -	TEST_ASSERT(b->data.dir.created_implicitly); -	TEST_EQUAL_UI(b->mode, S_IFDIR | 0755); -	TEST_EQUAL_UI(b->uid, 21); -	TEST_EQUAL_UI(b->gid, 42); -	TEST_EQUAL_UI(b->link_count, 3); - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFDIR | 0750; -	sb.st_uid = 1000; -	sb.st_gid = 100; - -	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_EQUAL_UI(a->mode, sb.st_mode); -	TEST_EQUAL_UI(a->uid, sb.st_uid); -	TEST_EQUAL_UI(a->gid, sb.st_gid); -	TEST_EQUAL_UI(a->link_count, 3); - -	TEST_EQUAL_UI(a->parent->link_count, 4); -	TEST_EQUAL_UI(fs.root->link_count, 4); - -	TEST_NULL(fstree_add_generic(&fs, "dir/foo", &sb, NULL)); -	TEST_EQUAL_UI(errno, EEXIST); - -	fstree_cleanup(&fs); -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/fstree_init.c b/tests/libfstree/fstree_init.c deleted file mode 100644 index 186f25b..0000000 --- a/tests/libfstree/fstree_init.c +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * fstree_init.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" -#include "util/util.h" - -int main(int argc, char **argv) -{ -	fstree_t fs; -	char *str; -	(void)argc; (void)argv; - -	str = strdup("mtime=1337,uid=1000,gid=100,mode=0321"); -	TEST_NOT_NULL(str); -	TEST_ASSERT(fstree_init(&fs, str) == 0); -	free(str); -	TEST_EQUAL_UI(fs.defaults.st_mtime, 1337); -	TEST_EQUAL_UI(fs.defaults.st_uid, 1000); -	TEST_EQUAL_UI(fs.defaults.st_gid, 100); -	TEST_EQUAL_UI(fs.defaults.st_mode, S_IFDIR | 0321); -	fstree_cleanup(&fs); - -	TEST_ASSERT(fstree_init(&fs, NULL) == 0); -	if (fs.defaults.st_mtime != 0) { -		TEST_EQUAL_UI(fs.defaults.st_mtime, get_source_date_epoch()); -	} -	TEST_EQUAL_UI(fs.defaults.st_uid, 0); -	TEST_EQUAL_UI(fs.defaults.st_gid, 0); -	TEST_EQUAL_UI(fs.defaults.st_mode, S_IFDIR | 0755); -	fstree_cleanup(&fs); - -	str = strdup("mode=07777"); -	TEST_NOT_NULL(str); -	TEST_ASSERT(fstree_init(&fs, str) == 0); -	free(str); -	fstree_cleanup(&fs); - -	str = strdup("mode=017777"); -	TEST_NOT_NULL(str); -	TEST_ASSERT(fstree_init(&fs, str) != 0); -	free(str); - -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/fstree_sort.c b/tests/libfstree/fstree_sort.c deleted file mode 100644 index 7df85f5..0000000 --- a/tests/libfstree/fstree_sort.c +++ /dev/null @@ -1,88 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * fstree_sort.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -int main(int argc, char **argv) -{ -	tree_node_t *a, *b, *c, *d; -	struct stat sb; -	fstree_t fs; -	int ret; -	(void)argc; (void)argv; - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFBLK | 0600; -	sb.st_rdev = 1337; - -	/* in order */ -	ret = fstree_init(&fs, NULL); -	TEST_EQUAL_I(ret, 0); - -	a = fstree_mknode(fs.root, "a", 1, NULL, &sb); -	TEST_NOT_NULL(a); -	TEST_ASSERT(fs.root->data.dir.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(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(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(a->next == b); -	TEST_ASSERT(b->next == c); -	TEST_ASSERT(c->next == d); -	TEST_NULL(d->next); - -	fstree_cleanup(&fs); - -	/* out-of-order */ -	ret = fstree_init(&fs, NULL); -	TEST_EQUAL_I(ret, 0); - -	d = fstree_mknode(fs.root, "d", 1, NULL, &sb); -	TEST_NOT_NULL(d); -	TEST_ASSERT(fs.root->data.dir.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(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(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(a->next == b); -	TEST_ASSERT(b->next == c); -	TEST_ASSERT(c->next == d); -	TEST_NULL(d->next); - -	fstree_cleanup(&fs); -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/gen_inode_numbers.c b/tests/libfstree/gen_inode_numbers.c deleted file mode 100644 index 5403580..0000000 --- a/tests/libfstree/gen_inode_numbers.c +++ /dev/null @@ -1,90 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * gen_inode_table.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -static tree_node_t *gen_node(tree_node_t *parent, const char *name) -{ -	struct stat sb; - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFDIR | 0755; - -	return fstree_mknode(parent, name, strlen(name), NULL, &sb); -} - -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) -		TEST_LESS_THAN_UI(n->inode_num, root->inode_num); - -	for (n = root->data.dir.children; n != NULL; n = n->next) -		check_children_before_root(n); -} - -static void check_children_continuous(tree_node_t *root) -{ -	tree_node_t *n; - -	for (n = root->data.dir.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) -		check_children_continuous(n); -} - -int main(int argc, char **argv) -{ -	tree_node_t *a, *b, *c; -	fstree_t fs; -	(void)argc; (void)argv; - -	// inode table for the empty tree -	TEST_ASSERT(fstree_init(&fs, NULL) == 0); -	fstree_post_process(&fs); -	TEST_EQUAL_UI(fs.unique_inode_count, 1); -	TEST_EQUAL_UI(fs.root->inode_num, 1); -	fstree_cleanup(&fs); - -	// tree with 2 levels under root, fan out 3 -	TEST_ASSERT(fstree_init(&fs, NULL) == 0); - -	a = gen_node(fs.root, "a"); -	b = gen_node(fs.root, "b"); -	c = gen_node(fs.root, "c"); -	TEST_NOT_NULL(a); -	TEST_NOT_NULL(b); -	TEST_NOT_NULL(c); - -	TEST_NOT_NULL(gen_node(a, "a_a")); -	TEST_NOT_NULL(gen_node(a, "a_b")); -	TEST_NOT_NULL(gen_node(a, "a_c")); - -	TEST_NOT_NULL(gen_node(b, "b_a")); -	TEST_NOT_NULL(gen_node(b, "b_b")); -	TEST_NOT_NULL(gen_node(b, "b_c")); - -	TEST_NOT_NULL(gen_node(c, "c_a")); -	TEST_NOT_NULL(gen_node(c, "c_b")); -	TEST_NOT_NULL(gen_node(c, "c_c")); - -	fstree_post_process(&fs); -	TEST_EQUAL_UI(fs.unique_inode_count, 13); - -	check_children_before_root(fs.root); -	check_children_continuous(fs.root); - -	fstree_cleanup(&fs); -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/get_path.c b/tests/libfstree/get_path.c deleted file mode 100644 index 61001e9..0000000 --- a/tests/libfstree/get_path.c +++ /dev/null @@ -1,59 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * get_path.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -int main(int argc, char **argv) -{ -	tree_node_t *a, *b, *c, *d; -	struct stat sb; -	fstree_t fs; -	char *str; -	(void)argc; (void)argv; - -	TEST_ASSERT(fstree_init(&fs, NULL) == 0); - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFDIR | 0750; -	sb.st_uid = 1000; -	sb.st_gid = 100; - -	a = fstree_add_generic(&fs, "foo", &sb, NULL); -	b = fstree_add_generic(&fs, "foo/bar", &sb, NULL); -	c = fstree_add_generic(&fs, "foo/bar/baz", &sb, NULL); -	d = fstree_add_generic(&fs, "foo/bar/baz/dir", &sb, NULL); - -	str = fstree_get_path(fs.root); -	TEST_NOT_NULL(str); -	TEST_STR_EQUAL(str, "/"); -	free(str); - -	str = fstree_get_path(a); -	TEST_NOT_NULL(str); -	TEST_STR_EQUAL(str, "/foo"); -	free(str); - -	str = fstree_get_path(b); -	TEST_NOT_NULL(str); -	TEST_STR_EQUAL(str, "/foo/bar"); -	free(str); - -	str = fstree_get_path(c); -	TEST_NOT_NULL(str); -	TEST_STR_EQUAL(str, "/foo/bar/baz"); -	free(str); - -	str = fstree_get_path(d); -	TEST_NOT_NULL(str); -	TEST_STR_EQUAL(str, "/foo/bar/baz/dir"); -	free(str); - -	fstree_cleanup(&fs); -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/mknode_dir.c b/tests/libfstree/mknode_dir.c deleted file mode 100644 index dd7eba7..0000000 --- a/tests/libfstree/mknode_dir.c +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * mknode_dir.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -int main(int argc, char **argv) -{ -	tree_node_t *root, *a, *b; -	struct stat sb; -	fstree_t fs; -	(void)argc; (void)argv; - -	memset(&fs, 0, sizeof(fs)); -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFDIR | 0654; -	sb.st_uid = 123; -	sb.st_gid = 456; -	sb.st_rdev = 789; -	sb.st_size = 4096; - -	root = fstree_mknode(NULL, "rootdir", 7, NULL, &sb); -	TEST_EQUAL_UI(root->uid, sb.st_uid); -	TEST_EQUAL_UI(root->gid, sb.st_gid); -	TEST_EQUAL_UI(root->mode, sb.st_mode); -	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->parent); -	TEST_NULL(root->next); - -	a = fstree_mknode(root, "adir", 4, NULL, &sb); -	TEST_ASSERT(a->parent == root); -	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_NULL(root->parent); -	TEST_NULL(root->next); - -	b = fstree_mknode(root, "bdir", 4, NULL, &sb); -	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(a->next == b); -	TEST_EQUAL_UI(root->link_count, 4); -	TEST_NULL(b->next); -	TEST_NULL(root->parent); -	TEST_NULL(root->next); - -	free(root); -	free(a); -	free(b); - -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/mknode_reg.c b/tests/libfstree/mknode_reg.c deleted file mode 100644 index 368720f..0000000 --- a/tests/libfstree/mknode_reg.c +++ /dev/null @@ -1,42 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * mknode_reg.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -int main(int argc, char **argv) -{ -	tree_node_t *node; -	struct stat sb; -	fstree_t fs; -	(void)argc; (void)argv; - -	memset(&fs, 0, sizeof(fs)); - -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFREG | 0654; -	sb.st_uid = 123; -	sb.st_gid = 456; -	sb.st_rdev = 789; -	sb.st_size = 4096; - -	node = fstree_mknode(NULL, "filename", 8, "input", &sb); -	TEST_EQUAL_UI(node->uid, sb.st_uid); -	TEST_EQUAL_UI(node->gid, sb.st_gid); -	TEST_EQUAL_UI(node->mode, sb.st_mode); -	TEST_NULL(node->parent); -	TEST_EQUAL_UI(node->link_count, 1); -	TEST_ASSERT((char *)node->name >= (char *)node->payload); -	TEST_ASSERT(node->data.file.input_file >= (char *)node->payload); -	TEST_ASSERT(node->data.file.input_file >= node->name + 8); -	TEST_STR_EQUAL(node->name, "filename"); -	TEST_STR_EQUAL(node->data.file.input_file, "input"); -	free(node); - -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/mknode_simple.c b/tests/libfstree/mknode_simple.c deleted file mode 100644 index c7efb49..0000000 --- a/tests/libfstree/mknode_simple.c +++ /dev/null @@ -1,98 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * mknode_simple.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -int main(int argc, char **argv) -{ -	tree_node_t *node; -	struct stat sb; -	fstree_t fs; -	(void)argc; (void)argv; - -	memset(&fs, 0, sizeof(fs)); -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFSOCK | 0654; -	sb.st_uid = 123; -	sb.st_gid = 456; -	sb.st_rdev = 789; -	sb.st_size = 1337; - -	node = fstree_mknode(NULL, "sockfile", 8, NULL, &sb); -	TEST_ASSERT((char *)node->name >= (char *)node->payload); -	TEST_STR_EQUAL(node->name, "sockfile"); -	TEST_EQUAL_UI(node->uid, sb.st_uid); -	TEST_EQUAL_UI(node->gid, sb.st_gid); -	TEST_EQUAL_UI(node->mode, sb.st_mode); -	TEST_EQUAL_UI(node->link_count, 1); -	TEST_NULL(node->parent); -	TEST_NULL(node->data.target); -	TEST_EQUAL_UI(node->data.devno, 0); -	free(node); - -	memset(&fs, 0, sizeof(fs)); -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFIFO | 0654; -	sb.st_uid = 123; -	sb.st_gid = 456; -	sb.st_rdev = 789; -	sb.st_size = 1337; - -	node = fstree_mknode(NULL, "fifo", 4, NULL, &sb); -	TEST_ASSERT((char *)node->name >= (char *)node->payload); -	TEST_STR_EQUAL(node->name, "fifo"); -	TEST_EQUAL_UI(node->uid, sb.st_uid); -	TEST_EQUAL_UI(node->gid, sb.st_gid); -	TEST_EQUAL_UI(node->mode, sb.st_mode); -	TEST_EQUAL_UI(node->link_count, 1); -	TEST_NULL(node->parent); -	TEST_NULL(node->data.target); -	TEST_EQUAL_UI(node->data.devno, 0); -	free(node); - -	memset(&fs, 0, sizeof(fs)); -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFBLK | 0654; -	sb.st_uid = 123; -	sb.st_gid = 456; -	sb.st_rdev = 789; -	sb.st_size = 1337; - -	node = fstree_mknode(NULL, "blkdev", 6, NULL, &sb); -	TEST_ASSERT((char *)node->name >= (char *)node->payload); -	TEST_STR_EQUAL(node->name, "blkdev"); -	TEST_EQUAL_UI(node->uid, sb.st_uid); -	TEST_EQUAL_UI(node->gid, sb.st_gid); -	TEST_EQUAL_UI(node->mode, sb.st_mode); -	TEST_EQUAL_UI(node->link_count, 1); -	TEST_EQUAL_UI(node->data.devno, sb.st_rdev); -	TEST_NULL(node->parent); -	free(node); - -	memset(&fs, 0, sizeof(fs)); -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFCHR | 0654; -	sb.st_uid = 123; -	sb.st_gid = 456; -	sb.st_rdev = 789; -	sb.st_size = 1337; - -	node = fstree_mknode(NULL, "chardev", 7, NULL, &sb); -	TEST_ASSERT((char *)node->name >= (char *)node->payload); -	TEST_STR_EQUAL(node->name, "chardev"); -	TEST_EQUAL_UI(node->uid, sb.st_uid); -	TEST_EQUAL_UI(node->gid, sb.st_gid); -	TEST_EQUAL_UI(node->mode, sb.st_mode); -	TEST_EQUAL_UI(node->link_count, 1); -	TEST_EQUAL_UI(node->data.devno, sb.st_rdev); -	TEST_NULL(node->parent); -	free(node); - -	return EXIT_SUCCESS; -} diff --git a/tests/libfstree/mknode_slink.c b/tests/libfstree/mknode_slink.c deleted file mode 100644 index c50a0ba..0000000 --- a/tests/libfstree/mknode_slink.c +++ /dev/null @@ -1,54 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * mknode_slink.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" -#include "util/test.h" - -int main(int argc, char **argv) -{ -	tree_node_t *node; -	struct stat sb; -	fstree_t fs; -	(void)argc; (void)argv; - -	memset(&fs, 0, sizeof(fs)); -	memset(&sb, 0, sizeof(sb)); -	sb.st_mode = S_IFLNK | 0654; -	sb.st_uid = 123; -	sb.st_gid = 456; -	sb.st_rdev = 789; -	sb.st_size = 1337; - -	node = fstree_mknode(NULL, "symlink", 7, "target", &sb); -	TEST_EQUAL_UI(node->uid, sb.st_uid); -	TEST_EQUAL_UI(node->gid, sb.st_gid); -	TEST_EQUAL_UI(node->mode, S_IFLNK | 0777); -	TEST_EQUAL_UI(node->link_count, 1); -	TEST_NULL(node->parent); -	TEST_ASSERT((char *)node->name >= (char *)node->payload); -	TEST_ASSERT(node->data.target >= (char *)node->payload); -	TEST_ASSERT(node->data.target >= node->name + 8); -	TEST_STR_EQUAL(node->name, "symlink"); -	TEST_STR_EQUAL(node->data.target, "target"); -	free(node); - -	node = fstree_mknode(NULL, "symlink", 7, "", &sb); -	TEST_EQUAL_UI(node->uid, sb.st_uid); -	TEST_EQUAL_UI(node->gid, sb.st_gid); -	TEST_EQUAL_UI(node->mode, S_IFLNK | 0777); -	TEST_EQUAL_UI(node->link_count, 1); -	TEST_NULL(node->parent); -	TEST_ASSERT((char *)node->name >= (char *)node->payload); -	TEST_ASSERT(node->data.target >= (char *)node->payload); -	TEST_ASSERT(node->data.target >= node->name + 8); -	TEST_STR_EQUAL(node->name, "symlink"); -	TEST_STR_EQUAL(node->data.target, ""); -	free(node); - -	return EXIT_SUCCESS; -}  | 
