Add unit test for LITE file API

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2016-06-06 17:11:22 +02:00
1 parent 5b786ce221
commit 3c350b8862
5 files changed
+41 -44

No files matched your search

+2
View File
@@ -1,5 +1,7 @@
*.log
*.trs
lfile
makepath
pidfile
tempfile
tree
+1
View File
@@ -2,6 +2,7 @@ EXTRA_DIST = check.h
CLEANFILES = *~ *.trs *.log
TESTS =
TESTS += lfile
TESTS += makepath
TESTS += pidfile
TESTS += tempfile
+37
View File
@@ -0,0 +1,37 @@
#include <stdio.h>
#include "check.h"
int main(void)
{
int val;
val = fgetint("/etc/protocols", " \n\t", "udp");
if (val == -1) {
perror("Failed locating 'udp' protocol");
return 1;
}
printf("udp has proto %d\n", val);
val = fgetint("/etc/services", " /\n\t", "ftp");
if (val == -1) {
perror("Failed locating 'ftp' service");
return 1;
}
printf("ftp is inet port %d\n", val);
val = fgetint("/etc/group", "x:\n", "utmp");
if (val == -1) {
perror("Failed locating group 'utmp'");
return 1;
}
printf("utmp is gid %d\n", val);
val = fgetint("/etc/passwd", "x:\n", "nobody");
if (val == -1) {
perror("Failed locating user 'nobody'");
return 1;
}
printf("nobody is uid %d\n", val);
return 0;
}