summaryrefslogtreecommitdiffstats
path: root/tests/rscript_script_error.sh
blob: 372e8d0cc5412d25e789e8f1e7381eb6525c4e6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# Added 2017-12-09 by Rainer Gerhards, released under ASL 2.0
. ${srcdir:=.}/diag.sh init
generate_conf
add_conf '
module(load="../plugins/imtcp/.libs/imtcp")
input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")
template(name="outfmt" type="string" string="%$!%\n")

local4.* {
	set $!valid!serial   = parse_time("2017-10-05T01:10:11Z");
	set $!valid!error    = script_error();
	set $!invalid!serial = parse_time("not a date/time");
	set $!invalid!error  = script_error();
	set $!valid2!serial   = parse_time("2017-10-05T01:10:11Z");
	set $!valid2!error    = script_error();
	action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt")
}
'

startup
tcpflood -m1
shutdown_when_empty
wait_shutdown

# Our fixed and calculated expected results
export EXPECTED='{ "valid": { "serial": 1507165811, "error": 0 }, "invalid": { "serial": 0, "error": 1 }, "valid2": { "serial": 1507165811, "error": 0 } }'
cmp_exact $RSYSLOG_OUT_LOG

exit_test