Add simple API test, syslog() no call to openlog()

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-11-03 15:54:36 +01:00
parent c05956010c
commit b1548e7c73
5 changed files with 35 additions and 2 deletions

2
test/.gitignore vendored
View File

@ -1,2 +1,4 @@
*.o
*.log *.log
*.trs *.trs
api

View File

@ -1,9 +1,17 @@
EXTRA_DIST = start.sh stop.sh EXTRA_DIST = start.sh stop.sh
EXTRA_DIST += local.sh remote.sh EXTRA_DIST += api.sh local.sh remote.sh
CLEANFILES = *~ *.trs *.log CLEANFILES = *~ *.trs *.log
TEST_EXTENSIONS = .sh TEST_EXTENSIONS = .sh
check_PROGRAMS = api
api_SOURCES = api.c
api_CFLAGS = -I../src
api_LDFLAGS = -static
api_LDADD = -L../src ../src/libsyslog.la
TESTS = start.sh TESTS = start.sh
TESTS += local.sh TESTS += local.sh
TESTS += remote.sh TESTS += remote.sh
TESTS += api.sh
TESTS += stop.sh TESTS += stop.sh

14
test/api.c Normal file
View File

@ -0,0 +1,14 @@
#include <stdlib.h>
#include "syslog.h"
int main(void)
{
char *msg = getenv("MSG");
if (!msg)
return 1;
syslog(LOG_ERR, msg);
return 0;
}

7
test/api.sh Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
set -e
. ./test.rc
export MSG="no-openlog-apitest"
./api
grep "api ${MSG}" ${LOG}

View File

@ -6,3 +6,5 @@ CONF=/tmp/${NM}.conf
CONFD=/tmp/${NM}.d CONFD=/tmp/${NM}.d
SOCK=/tmp/${NM}.sock SOCK=/tmp/${NM}.sock
PORT=5514 PORT=5514
export SYSLOG_UNIX_PATH=${SOCK}