diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-02 17:22:24 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-02 17:22:24 +0200 |
commit | 9940efe053263478c5f29367b11d6f7ed1276aa4 (patch) | |
tree | 99d1c9e9712c73ba4e6e8e145f007cb74294f12a /lib/fstree/test | |
parent | 32eb57dd9a19254565a0792ab9b627a3dac319f9 (diff) |
Move fstree CLI code to libcommon
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.c | 5 | ||||
-rw-r--r-- | lib/fstree/test/fstree_init.c | 50 | ||||
-rw-r--r-- | lib/fstree/test/fstree_sort.c | 7 | ||||
-rw-r--r-- | lib/fstree/test/gen_inode_numbers.c | 7 | ||||
-rw-r--r-- | lib/fstree/test/get_path.c | 5 |
5 files changed, 18 insertions, 56 deletions
diff --git a/lib/fstree/test/add_by_path.c b/lib/fstree/test/add_by_path.c index 97e5a60..76bae6d 100644 --- a/lib/fstree/test/add_by_path.c +++ b/lib/fstree/test/add_by_path.c @@ -7,10 +7,12 @@ #include "config.h" #include "fstree.h" +#include "common.h" #include "util/test.h" int main(int argc, char **argv) { + fstree_defaults_t fsd; tree_node_t *a, *b; struct stat sb; fstree_t fs; @@ -18,8 +20,9 @@ int main(int argc, char **argv) (void)argc; (void)argv; opts = strdup("mode=0755,uid=21,gid=42"); - TEST_ASSERT(fstree_init(&fs, opts) == 0); + TEST_ASSERT(parse_fstree_defaults(&fsd, opts) == 0); free(opts); + TEST_ASSERT(fstree_init(&fs, &fsd) == 0); memset(&sb, 0, sizeof(sb)); sb.st_mode = S_IFDIR | 0750; diff --git a/lib/fstree/test/fstree_init.c b/lib/fstree/test/fstree_init.c deleted file mode 100644 index 186f25b..0000000 --- a/lib/fstree/test/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/lib/fstree/test/fstree_sort.c b/lib/fstree/test/fstree_sort.c index 7df85f5..0d18ac7 100644 --- a/lib/fstree/test/fstree_sort.c +++ b/lib/fstree/test/fstree_sort.c @@ -7,11 +7,13 @@ #include "config.h" #include "fstree.h" +#include "common.h" #include "util/test.h" int main(int argc, char **argv) { tree_node_t *a, *b, *c, *d; + fstree_defaults_t fsd; struct stat sb; fstree_t fs; int ret; @@ -22,7 +24,8 @@ int main(int argc, char **argv) sb.st_rdev = 1337; /* in order */ - ret = fstree_init(&fs, NULL); + TEST_ASSERT(parse_fstree_defaults(&fsd, NULL) == 0); + ret = fstree_init(&fs, &fsd); TEST_EQUAL_I(ret, 0); a = fstree_mknode(fs.root, "a", 1, NULL, &sb); @@ -54,7 +57,7 @@ int main(int argc, char **argv) fstree_cleanup(&fs); /* out-of-order */ - ret = fstree_init(&fs, NULL); + ret = fstree_init(&fs, &fsd); TEST_EQUAL_I(ret, 0); d = fstree_mknode(fs.root, "d", 1, NULL, &sb); diff --git a/lib/fstree/test/gen_inode_numbers.c b/lib/fstree/test/gen_inode_numbers.c index 5403580..bb8c976 100644 --- a/lib/fstree/test/gen_inode_numbers.c +++ b/lib/fstree/test/gen_inode_numbers.c @@ -7,6 +7,7 @@ #include "config.h" #include "fstree.h" +#include "common.h" #include "util/test.h" static tree_node_t *gen_node(tree_node_t *parent, const char *name) @@ -47,18 +48,20 @@ static void check_children_continuous(tree_node_t *root) int main(int argc, char **argv) { tree_node_t *a, *b, *c; + fstree_defaults_t fsd; fstree_t fs; (void)argc; (void)argv; // inode table for the empty tree - TEST_ASSERT(fstree_init(&fs, NULL) == 0); + TEST_ASSERT(parse_fstree_defaults(&fsd, NULL) == 0); + TEST_ASSERT(fstree_init(&fs, &fsd) == 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); + TEST_ASSERT(fstree_init(&fs, &fsd) == 0); a = gen_node(fs.root, "a"); b = gen_node(fs.root, "b"); diff --git a/lib/fstree/test/get_path.c b/lib/fstree/test/get_path.c index 61001e9..572cde7 100644 --- a/lib/fstree/test/get_path.c +++ b/lib/fstree/test/get_path.c @@ -7,17 +7,20 @@ #include "config.h" #include "fstree.h" +#include "common.h" #include "util/test.h" int main(int argc, char **argv) { tree_node_t *a, *b, *c, *d; + fstree_defaults_t fsd; struct stat sb; fstree_t fs; char *str; (void)argc; (void)argv; - TEST_ASSERT(fstree_init(&fs, NULL) == 0); + TEST_ASSERT(parse_fstree_defaults(&fsd, NULL) == 0); + TEST_ASSERT(fstree_init(&fs, &fsd) == 0); memset(&sb, 0, sizeof(sb)); sb.st_mode = S_IFDIR | 0750; |