summaryrefslogtreecommitdiffstats
path: root/tests/json_nonarray_looping.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/json_nonarray_looping.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/json_nonarray_looping.sh')
-rwxr-xr-xtests/json_nonarray_looping.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/json_nonarray_looping.sh b/tests/json_nonarray_looping.sh
new file mode 100755
index 0000000..a38b243
--- /dev/null
+++ b/tests/json_nonarray_looping.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+# added 2015-03-02 by singh.janmejay
+# test to assert attempt to iterate upon a non-array json-object fails gracefully
+# This file is part of the rsyslog project, released under ASL 2.0
+. ${srcdir:=.}/diag.sh init
+generate_conf
+add_conf '
+template(name="garply" type="string" string="garply: %$.garply%\n")
+template(name="grault" type="string" string="grault: %$.grault%\n")
+template(name="prefixed_grault" type="string" string="prefixed_grault: %$.grault%\n")
+template(name="quux" type="string" string="quux: %$.quux%\n")
+
+module(load="../plugins/mmjsonparse/.libs/mmjsonparse")
+module(load="../plugins/imptcp/.libs/imptcp")
+input(type="imptcp" port="0" listenPortFileName="'$RSYSLOG_DYNNAME'.tcpflood_port")
+
+action(type="mmjsonparse")
+set $.garply = "";
+
+ruleset(name="prefixed_writer" queue.type="linkedlist" queue.workerthreads="5") {
+ action(type="omfile" file="'$RSYSLOG_DYNNAME'.out.prefixed.log" template="prefixed_grault" queue.type="linkedlist")
+}
+
+foreach ($.quux in $!foo) do {
+ action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="quux")
+ foreach ($.corge in $.quux!bar) do {
+ reset $.grault = $.corge;
+ action(type="omfile" file="'$RSYSLOG_DYNNAME'.out.async.log" template="grault" queue.type="linkedlist" action.copyMsg="on")
+ call prefixed_writer
+ if ($.garply != "") then
+ set $.garply = $.garply & ", ";
+ reset $.garply = $.garply & $.grault!baz;
+ }
+}
+action(type="omfile" file=`echo $RSYSLOG_OUT_LOG` template="garply")
+'
+startup
+tcpflood -m 1 -I $srcdir/testsuites/json_nonarray_input
+shutdown_when_empty
+wait_shutdown
+assert_content_missing 'quux'
+exit_test