summaryrefslogtreecommitdiffstats
path: root/tests/imfile-truncate.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:28:20 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 16:28:20 +0000
commitdcc721a95bef6f0d8e6d8775b8efe33e5aecd562 (patch)
tree66a2774cd0ee294d019efd71d2544c70f42b2842 /tests/imfile-truncate.sh
parentInitial commit. (diff)
downloadrsyslog-dcc721a95bef6f0d8e6d8775b8efe33e5aecd562.tar.xz
rsyslog-dcc721a95bef6f0d8e6d8775b8efe33e5aecd562.zip
Adding upstream version 8.2402.0.upstream/8.2402.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/imfile-truncate.sh')
-rwxr-xr-xtests/imfile-truncate.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/imfile-truncate.sh b/tests/imfile-truncate.sh
new file mode 100755
index 0000000..72ef168
--- /dev/null
+++ b/tests/imfile-truncate.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# addd 2016-10-06 by RGerhards, released under ASL 2.0
+. ${srcdir:=.}/diag.sh init
+. $srcdir/diag.sh check-inotify
+generate_conf
+add_conf '
+module(load="../plugins/imfile/.libs/imfile")
+
+input(type="imfile" File="./'$RSYSLOG_DYNNAME'.input" Tag="file:" reopenOnTruncate="on")
+
+template(name="outfmt" type="string" string="%msg:F,58:2%\n")
+if $msg contains "msgnum:" then {
+ action( type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt")
+} else {
+ action( type="omfile" file="'$RSYSLOG_DYNNAME'.rsyslog")
+}
+'
+
+# write the beginning of the file
+echo 'msgnum:0
+msgnum:1' > $RSYSLOG_DYNNAME.input
+
+startup
+
+wait_queueempty # wait for message to be processed
+
+# truncate and write some more lines (see https://github.com/rsyslog/rsyslog/issues/1090)
+echo 'msgnum:2' > $RSYSLOG_DYNNAME.input
+wait_queueempty # wait for message to be processed
+
+echo 'msgnum:3
+msgnum:4' >> $RSYSLOG_DYNNAME.input
+
+shutdown_when_empty # shut down rsyslogd when done processing messages
+wait_shutdown
+
+printf 'Messages from rsyslog itself:\n'
+cat -n $RSYSLOG_DYNNAME.rsyslog
+
+seq_check 0 4
+exit_test