From d94163d7214e2f4b45a5d7f2e20343137cd9de0e Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Sun, 19 Jan 2020 10:46:59 +0100 Subject: [PATCH] Add unit test to check syslog.conf rule option parsing Signed-off-by: Joachim Nilsson --- test/Makefile.am | 5 +++-- test/opts.sh | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100755 test/opts.sh diff --git a/test/Makefile.am b/test/Makefile.am index 6278473..19d8ac7 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,4 +1,4 @@ -EXTRA_DIST = test.rc start.sh stop.sh +EXTRA_DIST = test.rc opts.sh start.sh stop.sh EXTRA_DIST += api.sh local.sh remote.sh fwd.sh mark.sh CLEANFILES = *~ *.trs *.log TEST_EXTENSIONS = .sh @@ -9,7 +9,8 @@ api_CFLAGS = -I$(srcdir)/../src api_LDFLAGS = -static api_LDADD = ../src/libsyslog.la -TESTS = start.sh +TESTS = opts.sh +TESTS += start.sh TESTS += local.sh TESTS += remote.sh TESTS += api.sh diff --git a/test/opts.sh b/test/opts.sh new file mode 100755 index 0000000..62b8c7c --- /dev/null +++ b/test/opts.sh @@ -0,0 +1,21 @@ +#!/bin/sh +set -x + +if [ x"${srcdir}" = x ]; then + srcdir=. +fi +. ${srcdir}/test.rc + +mkdir -p ${CONFD} +cat < ${CONF} +# Match all log messages, store in RC5424 format and rotate every 10 MiB +*.* -${LOG} ;rotate=10M:5,RFC5424 +EOF + +../src/syslogd -m1 -b :${PORT} -d -sF -f ${CONF} -p ${SOCK} -p ${ALTSOCK} >${LOG2} & +echo "$!" > ${PID} + +sleep 1 +kill -9 ${PID} + +grep ';RFC5424,rotate=10000000:5' ${LOG2}