Debian Codegraph @

tests/imfile-endregex-save-lf-persist.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # This is part of the rsyslog testbench, licensed under ASL 2.0
3 echoscip-shell system . . echo. ======================================================================
4 echoscip-shell system . . echo. [imfile-endregex-save-lf-persist.sh]
5 . ${srcdir:=.}/diag.sh init
6 . $srcdir/diag.sh check-inotify
7 mkdirscip-shell system . . mkdir. "$RSYSLOG_DYNNAME.work"
8 generate_conf
9 add_conf '
10 global(workDirectory="./'"$RSYSLOG_DYNNAME"'.work")
11 module(load="../plugins/imfile/.libs/imfile")
12 input(type="imfile"
13 File="./'$RSYSLOG_DYNNAME'.input"
14 Tag="file:"
15 PersistStateInterval="1"
16 startmsg.regex="^[^ ]")
17 template(name="outfmt" type="list") {
18 constant(value="HEADER ")
19 property(name="msg" format="json")
20 constant(value="\n")
21 }
22 if $msg contains "msgnum:" then
23 action(
24 type="omfile"
25 file=`echo $RSYSLOG_OUT_LOG`
26 template="outfmt"
27 )
28 '
29 startup
30
31 # we need to sleep a bit between writes to give imfile a chance
32 # to pick up the data (IN MULTIPLE ITERATIONS!)
33 echoscip-shell system . . echo. 'msgnum:0
34 msgnum:1
35 msgnum:2' > $RSYSLOG_DYNNAME.input
36 ./msleep 300
37 echoscip-shell system . . echo. 'msgnum:3' >> $RSYSLOG_DYNNAME.input
38 echoscip-shell system . . echo. 'msgnum:4
39 msgnum:5' >> $RSYSLOG_DYNNAME.input
40 ./msleep 200
41 # the next line terminates our test. It is NOT written to the output file,
42 # as imfile waits whether or not there is a follow-up line that it needs
43 # to combine.
44 echoscip-shell system . . echo. 'END OF TEST' >> $RSYSLOG_DYNNAME.input
45 ./msleep 200
46
47 shutdown_when_empty # shut down rsyslogd when done processing messages
48 wait_shutdown # we need to wait until rsyslogd is finished!
49
50 printfscip-shell system . . printf. 'HEADER msgnum:0\\\\n msgnum:1\\\\n msgnum:2
51 HEADER msgnum:3
52 HEADER msgnum:4\\\\n msgnum:5\n' | cmpscip-shell system . . cmp. - $RSYSLOG_OUT_LOG
53 if [scip-shell system . . `[`. ! $? -eq 0 ]; then
54 echoscip-shell system . . echo. "invalid multiline message generated, $RSYSLOG_OUT_LOG is:"
55 catscip-shell system . . cat. $RSYSLOG_OUT_LOG
56 exit 1
57 fi;
58
59 exit_test