diff --git a/.travis.yml b/.travis.yml index c872947..357715a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ addons: apt: packages: - tree + - tshark # Custom build script for the time being, no "make test" yet script: diff --git a/test/Makefile.am b/test/Makefile.am index c0d5b82..18f9ec6 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -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 diff --git a/test/local.sh b/test/local.sh index 046988d..196b60b 100755 --- a/test/local.sh +++ b/test/local.sh @@ -3,6 +3,6 @@ MSG="foobar" -../src/logger -u ${SCK} ${MSG} +../src/logger -u ${SOCK} ${MSG} grep ${MSG} ${LOG} diff --git a/test/remote.sh b/test/remote.sh new file mode 100755 index 0000000..4a7a17e --- /dev/null +++ b/test/remote.sh @@ -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} + diff --git a/test/start.sh b/test/start.sh index 0131eb1..49b5762 100755 --- a/test/start.sh +++ b/test/start.sh @@ -5,11 +5,12 @@ if [ x"${srcdir}" = x ]; then srcdir=. fi -cat < ${CFG} +cat < ${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 diff --git a/test/stop.sh b/test/stop.sh index ed36e5f..5339a85 100755 --- a/test/stop.sh +++ b/test/stop.sh @@ -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} diff --git a/test/test.rc b/test/test.rc index e8f6bd8..da5610e 100644 --- a/test/test.rc +++ b/test/test.rc @@ -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 \ No newline at end of file