From bc103013cba61fe8e6805cf7e3c9e0918544dffa Mon Sep 17 00:00:00 2001 From: Steffen Nurpmeso Date: Thu, 20 Jan 2022 14:33:45 +0100 Subject: [PATCH] Test for "Add "notify" keyword" --- test/Makefile.am | 3 ++- test/notify.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100755 test/notify.sh diff --git a/test/Makefile.am b/test/Makefile.am index f966b2b..5282297 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -1,5 +1,5 @@ EXTRA_DIST = lib.sh opts.sh -EXTRA_DIST += api.sh local.sh unicode.sh remote.sh fwd.sh mark.sh +EXTRA_DIST += api.sh local.sh unicode.sh remote.sh fwd.sh mark.sh notify.sh CLEANFILES = *~ *.trs *.log TEST_EXTENSIONS = .sh TESTS_ENVIRONMENT= unshare -mrun @@ -17,5 +17,6 @@ TESTS += remote.sh TESTS += api.sh TESTS += fwd.sh TESTS += mark.sh +TESTS += notify.sh programs: $(check_PROGRAMS) diff --git a/test/notify.sh b/test/notify.sh new file mode 100755 index 0000000..7670259 --- /dev/null +++ b/test/notify.sh @@ -0,0 +1,58 @@ +#!/bin/sh +set -x + +if [ x"${srcdir}" = x ]; then + srcdir=. +fi +. ${srcdir}/lib.sh + +NOT1=${DIR}/${NM}-1.sh +NOT1STAMP=${DIR}/${NM}-1.stamp +NOT2=${DIR}/${NM}-2.sh +NOT2STAMP=${DIR}/${NM}-2.stamp + +printf '#!/bin/sh -\necho script 1: $* > '${NOT1STAMP}'\n' > ${NOT1} +printf '#!/bin/sh -\necho script 2: $* > '${NOT2STAMP}'\n' > ${NOT2} +chmod 0755 ${NOT1} ${NOT2} + +cat < ${CONF} +notify ${NOT1} +# Match all log messages, store in RC5424 format and rotate every 1 KiB +*.* -${LOG} ;rotate=1k:2,RFC5424 +notify ${NOT2} +EOF + +../src/syslogd -m1 -b :${PORT2} -d -sF -f ${CONF} -p ${SOCK2} -p ${ALTSOCK} -P ${PID2} >${LOG2} & +sleep 3 +cat ${PID2} >> "$DIR/PIDs" + +if grep 'notify '${NOT1} ${LOG2} && grep 'notify '${NOT2} ${LOG2}; then + : +else + exit $? +fi + +if [ -x ../src/logger ]; then + : +else + exit 0 +fi + +kill -USR1 `cat ${PID2}` + +MSG=01234567890123456789012345678901234567890123456789 +MSG=$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG$MSG +../src/logger -u ${SOCK2} ${MSG} +../src/logger -u ${SOCK2} 1${MSG} +../src/logger -u ${SOCK2} 2${MSG} + +kill -9 `cat ${PID2}` + +sleep 1 # XXX synchronization of async process? +if [ -f ${LOG}.0 ] && + grep 'script 1' ${NOT1STAMP} && + grep 'script 2' ${NOT2STAMP}; then + : +else + exit 1 +fi