diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-03-05 15:53:21 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-03-06 22:08:36 +0100 |
commit | b950412ca3a91aa37349cf51ebe98cc84767d448 (patch) | |
tree | e3bb062114d019984321a5a21b29818c88c36795 /tests/libfstree/fstree_init.c | |
parent | 3fc6bf24b5cc071fc323f08ece541e37578f6369 (diff) |
Cleanup: add some structure to the test directory
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/libfstree/fstree_init.c')
-rw-r--r-- | tests/libfstree/fstree_init.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/libfstree/fstree_init.c b/tests/libfstree/fstree_init.c new file mode 100644 index 0000000..a101143 --- /dev/null +++ b/tests/libfstree/fstree_init.c @@ -0,0 +1,49 @@ +/* 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 "internal.h" +#include "../test.h" + +int main(void) +{ + fstree_t fs; + char *str; + + 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; +} |