mirror of
https://github.com/troglobit/libite.git
synced 2026-10-14 10:19:31 +00:00
Add autotest for fexist()
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
de8f2b087c
commit
1138822d19
3 files changed
+34
-1
No files matched your search
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user