test/rotate_all.sh: address Joachim Wiberg comments (pull/46)

This commit is contained in:
Steffen Nurpmeso 2022-03-12 17:46:47 +01:00 committed by Joachim Wiberg
parent 0bc4c82bae
commit 908f1e6821

View File

@ -6,56 +6,49 @@ if [ x"${srcdir}" = x ]; then
fi
. ${srcdir}/lib.sh
[ -x ../src/logger ] || SKIP 'logger missing'
command -v zgrep >/dev/null 2>&1 || SKIP 'zgrep(1) missing'
NOT1=${DIR}/${NM}-1.sh
echo $NOT1 > /tmp/Xxxxx
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 1: $* >> '${NOT1STAMP}'\n' > ${NOT1}
chmod 0755 ${NOT1}
cat <<EOF > ${CONF}
cat <<EOF > ${CONFD}/rotate_all.conf
notify ${NOT1}
*.* -${LOG} ;rotate=10k:2,RFC5424
*.* -${LOG}X ;rotate=10k:2,RFC5424
EOF
../src/syslogd -m1 -b :${PORT2} -d -sF -f ${CONF} -p ${SOCK2} -p ${ALTSOCK} -P ${PID2} >${LOG2} &
setup
rm -f ${NOT1STAMP}
../src/logger -u ${SOCK} notrotall-1
kill -USR2 `cat ${PID}`
sleep 3
cat ${PID2} >> "$DIR/PIDs"
sleep 1
if grep 'notify '${NOT1} ${LOG2}; then
:
else
exit $?
fi
if [ -x ../src/logger ]; then
:
else
exit 0
fi
kill -USR1 `cat ${PID2}`
../src/logger -u ${SOCK2} notrotall-1
kill -USR2 `cat ${PID2}`
sleep 1 # XXX async process sync?
if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
grep notrotall-1 ${LOG}.0 &&
grep notrotall-1 ${LOG}X.0; then
:
else
exit 1
FAIL 'Missing log entries, I.'
fi
if [ -f ${NOT1STAMP} ] && grep 'script 1' ${NOT1STAMP} &&
grep ${LOG} ${NOT1STAMP} && grep ${LOG}X ${NOT1STAMP}; then
:
else
FAIL 'Notifier did not run, I.'
fi
rm -f ${NOT1STAMP}
../src/logger -u ${SOCK2} notrotall-2
kill -USR2 `cat ${PID2}`
sleep 1 # XXX async process sync?
../src/logger -u ${SOCK} notrotall-2
kill -USR2 `cat ${PID}`
sleep 3
if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
[ -f ${LOG}.1.gz ] && [ -f ${LOG}X.1.gz ] &&
grep notrotall-2 ${LOG}.0 &&
@ -64,13 +57,21 @@ if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
zgrep notrotall-1 ${LOG}X.1.gz; then
:
else
exit 1
FAIL 'Missing log entries, II.'
fi
if [ -f ${NOT1STAMP} ] && grep 'script 1' ${NOT1STAMP} &&
grep ${LOG} ${NOT1STAMP} && grep ${LOG}X ${NOT1STAMP}; then
:
else
FAIL 'Notifier did not run, II.'
fi
cp $NOT1STAMP /tmp/
rm -f ${NOT1STAMP}
../src/logger -u ${SOCK2} notrotall-3
kill -USR2 `cat ${PID2}`
sleep 1 # XXX async process sync?
../src/logger -u ${SOCK} notrotall-3
kill -USR2 `cat ${PID}`
sleep 3
if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
[ -f ${LOG}.1.gz ] && [ -f ${LOG}X.1.gz ] &&
[ -f ${LOG}.2.gz ] && [ -f ${LOG}X.2.gz ] &&
@ -82,14 +83,13 @@ if [ -f ${LOG}.0 ] && [ -f ${LOG}X.0 ] &&
zgrep notrotall-1 ${LOG}X.2.gz; then
:
else
exit 1
FAIL 'Missing log entries, III.'
fi
kill -9 `cat ${PID2}`
sleep 1 # XXX synchronization of async process?
if [ -f ${LOG}.0 ] && grep 'script 1' ${NOT1STAMP}; then
if [ -f ${NOT1STAMP} ] && grep 'script 1' ${NOT1STAMP} &&
grep ${LOG} ${NOT1STAMP} && grep ${LOG}X ${NOT1STAMP}; then
:
else
exit 1
FAIL 'Notifier did not run, III.'
fi
OK