summaryrefslogtreecommitdiffstats
path: root/tests/rscript_set_unset_invalid_var.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rscript_set_unset_invalid_var.sh')
-rwxr-xr-xtests/rscript_set_unset_invalid_var.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/rscript_set_unset_invalid_var.sh b/tests/rscript_set_unset_invalid_var.sh
new file mode 100755
index 0000000..a428be2
--- /dev/null
+++ b/tests/rscript_set_unset_invalid_var.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+# Check that invalid variable names are detected.
+# Copyright 2017-01-24 by Rainer Gerhards
+# This file is part of the rsyslog project, released under ASL 2.0
+. ${srcdir:=.}/diag.sh init
+generate_conf
+add_conf '
+template(name="json" type="string" string="%$!%\n")
+ruleset(name="rcvr" queue.type="LinkedList") {
+ set $@timestamp="test";
+ unset $@timestamp2;
+ action(type="omfile" file=`echo $RSYSLOG2_OUT_LOG`)
+}
+
+action(type="omfile" file=`echo $RSYSLOG_OUT_LOG`)
+
+'
+startup
+injectmsg 0 10
+shutdown_when_empty
+wait_shutdown
+
+grep "@timestamp" $RSYSLOG_OUT_LOG > /dev/null
+if [ ! $? -eq 0 ]; then
+ echo "expected error message on \"@timestamp\" not found, output is:"
+ echo "------------------------------------------------------------"
+ cat $RSYSLOG_OUT_LOG
+ echo "------------------------------------------------------------"
+ error_exit 1
+fi;
+
+grep "@timestamp2" $RSYSLOG_OUT_LOG > /dev/null
+if [ ! $? -eq 0 ]; then
+ echo "expected error message on \"@timestamp2\" not found, output is:"
+ echo "------------------------------------------------------------"
+ cat $RSYSLOG_OUT_LOG
+ echo "------------------------------------------------------------"
+ error_exit 1
+fi;
+
+exit_test