Debian Codegraph @

tests/imfile-discard-truncated-line.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 # This test mimics the test imfile-readmode2.sh, but works via
4 # endmsg.regex. It's kind of a base test for the regex functionality.
5 echoscip-shell system . . echo. ======================================================================
6 # Check if inotify header exist
7 echoscip-shell system . . echo. [imfile-discard-truncated-line.sh]
8 . $srcdir/diag.sh check-inotify
9 . ${srcdir:=.}/diag.sh init
10 generate_conf
11 add_conf '
12 $MaxMessageSize 128
13 module(load="../plugins/imfile/.libs/imfile")
14 input(type="imfile"
15 File="./'$RSYSLOG_DYNNAME'.input"
16 discardTruncatedMsg="on"
17 msgDiscardingError="off"
18 Tag="file:"
19 startmsg.regex="^[^ ]"
20 ruleset="ruleset")
21 template(name="outfmt" type="list") {
22 constant(value="HEADER ")
23 property(name="msg" format="json")
24 constant(value="\n")
25 }
26 ruleset(name="ruleset") {
27 action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt")
28 }
29 action(type="omfile" file=`echo $RSYSLOG2_OUT_LOG` template="outfmt")
30 '
31 startup
32
33 # write the beginning of the file
34 echoscip-shell system . . echo. 'msgnum:0
35 msgnum:1
36 msgnum:2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
37 msgnum:3 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
38 msgnum:4 cccccccccccccccccccccccccccccccccccccccccccc
39 msgnum:5 dddddddddddddddddddddddddddddddddddddddddddd
40 msgnum:6 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
41 msgnum:7 ffffffffffffffffffffffffffffffffffffffffffff
42 msgnum:8 gggggggggggggggggggggggggggggggggggggggggggg
43 msgnum:9' > $RSYSLOG_DYNNAME.input
44 # the next line terminates our test. It is NOT written to the output file,
45 # as imfile waits whether or not there is a follow-up line that it needs
46 # to combine.
47 echoscip-shell system . . echo. 'END OF TEST' >> $RSYSLOG_DYNNAME.input
48 # sleep a little to give rsyslog a chance to begin processing
49 ./msleep 500
50 shutdown_when_empty # shut down rsyslogd when done processing messages
51 wait_shutdown # we need to wait until rsyslogd is finished!
52
53 printfscip-shell system . . printf. 'HEADER msgnum:0
54 HEADER msgnum:1
55 HEADER msgnum:2 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\\\n msgnum:3 bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb\\\\n msgnum:4 ccccccc
56 HEADER msgnum:6 eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee\\\\n msgnum:7 ffffffffffffffffffffffffffffffffffffffffffff\\\\n msgnum:8 ggggggg
57 HEADER msgnum:9\n' | cmpscip-shell system . . cmp. - $RSYSLOG_OUT_LOG
58 if [scip-shell system . . `[`. ! $? -eq 0 ]; then
59 echoscip-shell system . . echo. "invalid multiline message generated, $RSYSLOG_OUT_LOG is:"
60 catscip-shell system . . cat. $RSYSLOG_OUT_LOG
61 exit 1
62 fi;
63
64 grepscip-shell system . . grep. "imfile error:.*rest of message will not be processed" ${RSYSLOG2_OUT_LOG} > /dev/nullscip-shell filesystem . . `/dev/null`.
65 if [scip-shell system . . `[`. $? -eq 0 ]; then
66 echoscip-shell system . . echo.
67 echoscip-shell system . . echo. "FAIL: expected error message from missing input file not found. ${RSYSLOG2_OUT_LOG} is:"
68 catscip-shell system . . cat. ${RSYSLOG2_OUT_LOG}
69 error_exit 1
70 fi
71
72 exit_test