Add autotest for fisdir()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2015-08-22 23:26:41 +02:00
parent 1138822d19
commit e8ff38ad6a
3 changed files with 34 additions and 0 deletions
+1
View File
@@ -55,6 +55,7 @@ test: clean
$(MAKE) -f copyfile.mk
$(MAKE) -f dir.mk
$(MAKE) -f fexist.mk
$(MAKE) -f fisdir.mk
$(MAKE) -f fsendfile.mk
$(MAKE) -f makepath.mk
$(MAKE) -f pidfilefn.mk
+29
View File
@@ -42,8 +42,37 @@ int fisdir(char *file)
return 0;
}
#ifdef UNITTEST
#include "lite.h"
int main(void)
{
int i = 0;
struct { char *file; int exist; } arr[] = {
{ "/etc/passwd", 0 },
{ "/etc/", 1 },
{ "/sbin/init", 0 },
{ "/dev/null", 0 },
{ "/dev/", 1 },
{ NULL, 0 },
};
FILE *src, *dst;
for (i = 0; i < NELEMS(arr); i++) {
if (fisdir(arr[i].file) != arr[i].exist)
err(1, "Failed fisdir(%s)", arr[i].file ?: "NULL");
else
printf("fisdir() %-11s %-18s => OK!\n", arr[i].file ?: "NULL",
arr[i].exist ? "is a directory" : "is NOT a directory");
}
return 0;
}
#endif /* UNITTEST */
/**
* Local Variables:
* compile-command: "make V=1 -f fisdir.mk"
* version-control: t
* indent-tabs-mode: t
* c-file-style: "linux"
+4
View File
@@ -0,0 +1,4 @@
OBJS =
TARGET = fisdir.test clean
include rules.mk