rsyslog/tests/imfile-endregex-save-lf-persist.sh
Rainer Gerhards 844d277f15 testbench: fix test which expected incorrect value
This was not really tested before, and with the new code it turned
out that the expected value was not adjusted when copying the test
from another test file.
2016-05-18 13:00:59 +02:00

62 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
# This is part of the rsyslog testbench, licensed under ASL 2.0
echo ======================================================================
# Check if inotify header exist
if [ -n "$(find /usr/include -name 'inotify.h' -print -quit)" ]; then
echo [imfile-endregex.sh]
else
exit 77 # no inotify available, skip this test
fi
. $srcdir/diag.sh init
. $srcdir/diag.sh generate-conf
. $srcdir/diag.sh add-conf '
module(load="../plugins/imfile/.libs/imfile")
input(type="imfile"
File="./rsyslog.input"
Tag="file:"
PersistStateInterval="1"
startmsg.regex="^[^ ]")
template(name="outfmt" type="list") {
constant(value="HEADER ")
property(name="msg" format="json")
constant(value="\n")
}
if $msg contains "msgnum:" then
action(
type="omfile"
file="rsyslog.out.log"
template="outfmt"
)
'
. $srcdir/diag.sh startup
# we need to sleep a bit between writes to give imfile a chance
# to pick up the data (IN MULTIPLE ITERATIONS!)
echo 'msgnum:0
msgnum:1
msgnum:2' > rsyslog.input
./msleep 300
echo 'msgnum:3' >> rsyslog.input
echo 'msgnum:4
msgnum:5' >> rsyslog.input
./msleep 200
# the next line terminates our test. It is NOT written to the output file,
# as imfile waits whether or not there is a follow-up line that it needs
# to combine.
echo 'END OF TEST' >> rsyslog.input
./msleep 200
. $srcdir/diag.sh shutdown-when-empty # shut down rsyslogd when done processing messages
. $srcdir/diag.sh wait-shutdown # we need to wait until rsyslogd is finished!
echo 'HEADER msgnum:0\\n msgnum:1\\n msgnum:2
HEADER msgnum:3
HEADER msgnum:4\\n msgnum:5' | cmp rsyslog.out.log
if [ ! $? -eq 0 ]; then
echo "invalid multiline message generated, rsyslog.out.log is:"
cat rsyslog.out.log
exit 1
fi;
. $srcdir/diag.sh exit