summaryrefslogtreecommitdiffstats
path: root/tests/imfile-statefile-delete.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-statefile-delete.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-statefile-delete.sh')
-rwxr-xr-xtests/imfile-statefile-delete.sh44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/imfile-statefile-delete.sh b/tests/imfile-statefile-delete.sh
new file mode 100755
index 0000000..cbe4128
--- /dev/null
+++ b/tests/imfile-statefile-delete.sh
@@ -0,0 +1,44 @@
+#!/bin/bash
+# added 2019-02-28
+# This is part of the rsyslog testbench, licensed under ASL 2.0
+. ${srcdir:=.}/diag.sh init
+export TESTMESSAGES=1000
+export TESTMESSAGESFULL=999
+export RETRIES=50
+
+# Uncomment fdor debuglogs
+#export RSYSLOG_DEBUG="debug nostdout noprintmutexaction"
+#export RSYSLOG_DEBUGLOG="$RSYSLOG_DYNNAME.debuglog"
+
+generate_conf
+add_conf '
+global(workDirectory="'${RSYSLOG_DYNNAME}'.spool")
+module(load="../plugins/imfile/.libs/imfile" mode="inotify" PollingInterval="1")
+input(type="imfile" tag="file:" file="./'$RSYSLOG_DYNNAME'.input")
+
+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")
+'
+./inputfilegen -m $TESTMESSAGES > $RSYSLOG_DYNNAME.input
+inode=$(get_inode "$RSYSLOG_DYNNAME.input")
+startup
+wait_file_lines $RSYSLOG_OUT_LOG $TESTMESSAGES $RETRIES
+rm $RSYSLOG_DYNNAME.input
+sleep_time_ms=0
+while ls $RSYSLOG_DYNNAME.spool/imfile-state:$inode:* 1> /dev/null 2>&1; do
+ ./msleep 100
+ ((sleep_time_ms+=100))
+ if [ $sleep_time_ms -ge 6000 ]; then
+ touch $RSYSLOG_DYNNAME:.tmp
+ fi
+ if [ $sleep_time_ms -ge 30000 ]; then
+ printf 'FAIL: state file still exists when it should have been deleted\nspool dir is:\n'
+ ls -l $RSYSLOG_DYNNAME.spool
+ error_exit 1
+ fi
+done
+shutdown_when_empty
+wait_shutdown
+seq_check 0 $TESTMESSAGESFULL # check we got the message correctly
+exit_test