diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:28:20 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 16:28:20 +0000 |
commit | dcc721a95bef6f0d8e6d8775b8efe33e5aecd562 (patch) | |
tree | 66a2774cd0ee294d019efd71d2544c70f42b2842 /tests/rscript_format_time.sh | |
parent | Initial commit. (diff) | |
download | rsyslog-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/rscript_format_time.sh')
-rwxr-xr-x | tests/rscript_format_time.sh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/rscript_format_time.sh b/tests/rscript_format_time.sh new file mode 100755 index 0000000..b0f53d7 --- /dev/null +++ b/tests/rscript_format_time.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Added 2017-10-03 by Stephen Workman, released under ASL 2.0 + +. ${srcdir:=.}/diag.sh init +generate_conf +add_conf ' +module(load="../plugins/imtcp/.libs/imtcp") +module(load="../plugins/omstdout/.libs/omstdout") +input(type="imtcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port") + +# $DebugLevel 2 + +set $!datetime!rfc3164 = format_time(1507165811, "date-rfc3164"); +set $!datetime!rfc3339 = format_time(1507165811, "date-rfc3339"); + +set $!datetime!rfc3164Neg = format_time(-1507165811, "date-rfc3164"); +set $!datetime!rfc3339Neg = format_time(-1507165811, "date-rfc3339"); + +set $!datetime!str1 = format_time("1507165811", "date-rfc3339"); +set $!datetime!strinv1 = format_time("ABC", "date-rfc3339"); + +template(name="outfmt" type="string" string="%!datetime%\n") +local4.* action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="outfmt") +local4.* :omstdout:;outfmt +' + +startup +tcpflood -m1 -y | sed 's|\r||' +shutdown_when_empty +wait_shutdown + +export EXPECTED='{ "rfc3164": "Oct 5 01:10:11", "rfc3339": "2017-10-05T01:10:11Z", "rfc3164Neg": "Mar 29 22:49:49", "rfc3339Neg": "1922-03-29T22:49:49Z", "str1": "2017-10-05T01:10:11Z", "strinv1": "ABC" }' + +# FreeBSD's cmp does not support reading from STDIN +cmp <(echo "$EXPECTED") $RSYSLOG_OUT_LOG + +if [[ $? -ne 0 ]]; then + printf 'Invalid function output detected!\n' + printf "Expected: $EXPECTED\n" + printf 'Got: ' + cat $RSYSLOG_OUT_LOG + error_exit 1 +fi; + +exit_test |