test: Check sending log messages to remote server works

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson 2019-10-30 17:14:29 +01:00
parent 72bbee7812
commit 8f459d349a
7 changed files with 38 additions and 9 deletions

View File

@ -14,6 +14,7 @@ addons:
apt:
packages:
- tree
- tshark
# Custom build script for the time being, no "make test" yet
script:

View File

@ -1,8 +1,9 @@
EXTRA_DIST = start.sh stop.sh
EXTRA_DIST += local.sh
EXTRA_DIST += local.sh remote.sh
CLEANFILES = *~ *.trs *.log
TEST_EXTENSIONS = .sh
TESTS = start.sh
TESTS += local.sh
TESTS += remote.sh
TESTS += stop.sh

View File

@ -3,6 +3,6 @@
MSG="foobar"
../src/logger -u ${SCK} ${MSG}
../src/logger -u ${SOCK} ${MSG}
grep ${MSG} ${LOG}

22
test/remote.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
set -x
. ./test.rc
MSG="kilroy"
tshark -Qni lo -w ${CAP} port ${PORT} 2>/dev/null &
#tcpdump -qlni lo -w ${CAP} port ${PORT} 2>/dev/null &
PID="$!"
sleep 1
echo "Hej"
../src/logger -u ${SOCK} ${MSG}
echo "Nej"
sleep 1
kill -TERM ${PID}
wait ${PID}
tshark -d udp.port==${PORT},syslog -r ${CAP} | grep ${MSG}
rm ${CAP}

View File

@ -5,11 +5,12 @@ if [ x"${srcdir}" = x ]; then
srcdir=.
fi
cat <<EOF > ${CFG}
cat <<EOF > ${CONF}
*.* -${LOG}
*.* @192.168.1.1
*.* @127.0.0.2
EOF
../src/syslogd -d -n -f ${CFG} -p ${SCK} -P ${PID} &
../src/syslogd -b :${PORT} -d -n -f ${CONF} -p ${SOCK} &
echo "$!" > ${PID}
sleep 1

View File

@ -2,10 +2,12 @@
. ./test.rc
if [ -e ${PID} ]; then
echo "Killing `cat ${PID}` ..."
kill `cat ${PID}`
fi
rm -f ${CFG}
rm -f ${LOG}
rm -f ${PID}
rm -f ${SCK}
rm -f ${CAP}
rm -f ${SOCK}
rm -f ${CONF}

View File

@ -1,5 +1,7 @@
NM=syslog-test
CFG=/tmp/${NM}.conf
LOG=/tmp/${NM}.log
PID=/tmp/${NM}.pid
SCK=/tmp/${NM}.sock
CAP=/tmp/${NM}.pcapng
CONF=/tmp/${NM}.conf
SOCK=/tmp/${NM}.sock
PORT=5514