From bad363883d29d68dd529fb4964bf8054a780b860 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sat, 7 Jan 2017 12:59:27 +0100 Subject: [PATCH] Fix leaky makepath() unit test Signed-off-by: Joachim Nilsson --- tests/makepath.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/tests/makepath.c b/tests/makepath.c index 58bbcf2..76bfdc4 100644 --- a/tests/makepath.c +++ b/tests/makepath.c @@ -1,4 +1,6 @@ #include +#include +#include #include #include "check.h" @@ -34,27 +36,32 @@ int main(void) { int i, ret = 0; char *list[] = { - "/tmp/tok/", - "/tmp/tok2", - "/tmp/ab", - "/tmp/b", - "/tmp/a/", - "/tmp/a/b", - "/tmp/a/c/", - "../../sometestdir/arpa/inet", + "/tmp/libite-test/tok/", + "/tmp/libite-test/tok2", + "/tmp/libite-test/ab", + "/tmp/libite-test/b", + "/tmp/libite-test/a/", + "/tmp/libite-test/a/b", + "/tmp/libite-test/a/c/", NULL }; - for (i = 0; list[i]; i++) - rmdir(list[i]); - printf("Testing makepath() ...\n"); + mkdir("/tmp/libite-test", 0755); + for (i = 0; list[i] && !ret; i++) ret |= test_makepath(list[i]); printf("\nCleaning up ...\n"); - for (i = 0; list[i]; i++) - rmdir(list[i]); + system("rm -rf /tmp/libite-test"); return ret; } + +/** + * Local Variables: + * indent-tabs-mode: t + * c-file-style: "linux" + * compile-command: "make makepath && ./makepath" + * End: + */