rsyslog/tests/imfile-endregex-save-lf.sh
Rainer Gerhards 8ea166d89d
testbench: fix some hardcoded names (#2895)
* testbench: fix some hardcoded names

This is prework to make parallel execution of tests possible.
2018-08-01 12:52:17 +02:00

52 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# This is part of the rsyslog testbench, licensed under ASL 2.0
# This test mimics the test imfile-readmode2.sh, but works via
# endmsg.regex. It's kind of a base test for the regex functionality.
echo ======================================================================
echo [imfile-endregex-save-lf.sh]
. $srcdir/diag.sh check-inotify
. $srcdir/diag.sh init
generate_conf
add_conf '
module(load="../plugins/imfile/.libs/imfile")
input(type="imfile"
File="./rsyslog.input"
Tag="file:"
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=`echo $RSYSLOG_OUT_LOG`
template="outfmt"
)
'
startup
# write the beginning of the file
echo 'msgnum:0
msgnum:1
msgnum:2' > rsyslog.input
# 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
# sleep a little to give rsyslog a chance to begin processing
./msleep 500
shutdown_when_empty # shut down rsyslogd when done processing messages
wait_shutdown # we need to wait until rsyslogd is finished!
printf 'HEADER msgnum:0\\\\n msgnum:1\\\\n msgnum:2\n' | cmp - $RSYSLOG_OUT_LOG
if [ ! $? -eq 0 ]; then
echo "invalid multiline message generated, $RSYSLOG_OUT_LOG is:"
cat $RSYSLOG_OUT_LOG
exit 1
fi;
exit_test