diff options
Diffstat (limited to 'tests/fstree_from_file.c')
-rw-r--r-- | tests/fstree_from_file.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/tests/fstree_from_file.c b/tests/fstree_from_file.c index b5ac2a3..4df0a4e 100644 --- a/tests/fstree_from_file.c +++ b/tests/fstree_from_file.c @@ -13,28 +13,30 @@ #include <assert.h> #include <stdio.h> -static const char *testdesc = -"# comment line\n" -"slink /slink 0644 2 3 slinktarget\n" -"dir /dir 0755 4 5\n" -"nod /chardev 0600 6 7 c 13 37\n" -"nod /blkdev 0600 8 9 b 42 21\n" -"pipe /pipe 0644 10 11\n" -"dir \"/foo bar\" 0755 0 0\n" -"dir \"/foo bar/ test \\\"/\" 0755 0 0\n" -" sock /sock 0555 12 13 "; +#define STR(x) #x +#define STRVALUE(x) STR(x) + +#define TEST_PATH STRVALUE(TESTPATH) + +static FILE *open_read(const char *path) +{ + FILE *fp = fopen(path, "rb"); + + if (fp == NULL) { + perror(path); + exit(EXIT_FAILURE); + } + + return fp; +} int main(void) { tree_node_t *n; fstree_t fs; - char *ptr; FILE *fp; - ptr = strdup(testdesc); - assert(ptr != NULL); - - fp = fmemopen(ptr, strlen(ptr), "r"); + fp = open_read(TEST_PATH); assert(fp != NULL); assert(fstree_init(&fs, NULL) == 0); |