diff --git a/haggis.c b/haggis.c index a5c8b38..01a98c8 100644 --- a/haggis.c +++ b/haggis.c @@ -530,7 +530,7 @@ haggis_node* haggis_create_node(char *file, haggis_algorithm a, haggis_linkmap * node = calloc(1, sizeof(haggis_node)); if (node == NULL) return NULL; - if (stat(file, &st) != 0) { + if (lstat(file, &st) != 0) { free(node); return NULL; } diff --git a/test/Makefile b/test/Makefile index 522c5cf..d782c20 100644 --- a/test/Makefile +++ b/test/Makefile @@ -66,6 +66,7 @@ tests += fnv1a_hash_str tests += linkmap_init tests += linkmap_put tests += create_dir_node +tests += create_symlink_node total != echo $(tests) | wc -w | awk '{ print $$1 }' diff --git a/test/create_dir_node.c b/test/create_dir_node.c index 07846ce..0709ba7 100644 --- a/test/create_dir_node.c +++ b/test/create_dir_node.c @@ -16,4 +16,5 @@ int main() { assert(memcmp(path, node->name.name, 6) == 0); haggis_node_deinit(node); haggis_linkmap_deinit(map); + return 0; } \ No newline at end of file diff --git a/test/create_symlink_node.c b/test/create_symlink_node.c new file mode 100644 index 0000000..e6942a1 --- /dev/null +++ b/test/create_symlink_node.c @@ -0,0 +1,23 @@ +#include +#include +#include +#include + +#include "haggis.h" + +int main() { + haggis_linkmap *map; + haggis_node *node; + char *path = "output/dev"; + + map = haggis_linkmap_init(); + assert(map != NULL); + symlink("device", "output/dev"); + node = haggis_create_node(path, sha256, map); + assert(node->filetype.tag == softlink); + assert(memcmp(path, node->name.name, 10) == 0); + assert(memcmp(node->filetype.f_type.target.name, "device", 6) == 0); + haggis_node_deinit(node); + haggis_linkmap_deinit(map); + return 0; +} \ No newline at end of file diff --git a/test/init_file b/test/init_file deleted file mode 100755 index 2139d4b..0000000 Binary files a/test/init_file and /dev/null differ