Add autotest for fexist()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-08-22 23:22:38 +02:00
1 parent de8f2b087c
commit 1138822d19
3 files changed
+34 -1

No files matched your search

+2 -1
View File
@@ -50,10 +50,11 @@ TARGET = $(STATICLIB) $(SOLIB)
#include <rules.mk>
include rules.mk
test:
test: clean
$(MAKE) -f chomp.mk
$(MAKE) -f copyfile.mk
$(MAKE) -f dir.mk
$(MAKE) -f fexist.mk
$(MAKE) -f fsendfile.mk
$(MAKE) -f makepath.mk
$(MAKE) -f pidfilefn.mk
+28
View File
@@ -44,8 +44,36 @@ int fexist(char *file)
return 1;
}
#ifdef UNITTEST
#include "lite.h"
int main(void)
{
int i = 0;
struct { char *file; int exist; } arr[] = {
{ "/etc/passwd", 1 },
{ "/etc/kalle", 0 },
{ "/sbin/init", 1 },
{ "/dev/null", 1 },
{ NULL, 0 },
};
FILE *src, *dst;
for (i = 0; i < NELEMS(arr); i++) {
if (fexist(arr[i].file) != arr[i].exist)
err(1, "Failed fexist(%s)", arr[i].file ?: "NULL");
else
printf("File %-11s %-14s => OK!\n", arr[i].file ?: "NULL",
arr[i].exist ? "does exist" : "does not exist");
}
return 0;
}
#endif /* UNITTEST */
/**
* Local Variables:
* compile-command: "make V=1 -f fexist.mk"
* version-control: t
* indent-tabs-mode: t
* c-file-style: "linux"
+4
View File
@@ -0,0 +1,4 @@
OBJS =
TARGET = fexist.test clean
include rules.mk