diff options
| author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-11-23 17:01:11 +0100 | 
|---|---|---|
| committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-11-23 17:01:11 +0100 | 
| commit | 687b880ddb0d67253d8903f92910a1ca3bea65ef (patch) | |
| tree | 7f2ab41aff608be87a45136d2ad181ef63442ab9 /tests/fstree_from_file.c | |
| parent | 650b607f339cd0ffa32e205e4501ec3fcfa88fbf (diff) | |
Make sure the unit tests build with the mingw cross compiler
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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); | 
