]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
regress: Add test for query file variable substitution
authorEric Bollengier <eric@baculasystems.com>
Wed, 6 Jan 2021 11:41:23 +0000 (12:41 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:58 +0000 (09:02 +0100)
regress/tests/query-subst-test [new file with mode: 0755]

diff --git a/regress/tests/query-subst-test b/regress/tests/query-subst-test
new file mode 100755 (executable)
index 0000000..7efb5f0
--- /dev/null
@@ -0,0 +1,70 @@
+#!/bin/sh
+#
+# Copyright (C) 2000-2020 Kern Sibbald
+# License: BSD 2-Clause; see file LICENSE-FOSS
+#
+# Test the substitution on the query.sql file
+
+
+TestName="query-subst-test"
+JobName=query
+. scripts/functions
+
+scripts/cleanup
+scripts/copy-test-confs
+
+start_test
+
+cat <<EOF > $conf/query.sql
+# 1
+:Query to test substitutions
+*Enter a
+*Enter b
+*Enter c
+*Enter d
+*Enter e
+*Enter f
+*Enter g
+*Enter h
+SELECT '%1' as "a", '%2' as "b", '%3' as "c", '%4' as "d", '%1' as "a", '%2' as "b", '%3' as "c", '%8' as "h";
+# 2
+:Query to test substitutions with error
+*Enter a
+SELECT '%2' as "a";
+EOF
+
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@output /dev/null
+messages
+@$out ${cwd}/tmp/log1.out
+query
+1
+a
+b
+c
+d
+h
+
+@$out ${cwd}/tmp/log2.out
+query
+2
+quit
+END_OF_DATA
+
+run_bacula
+stop_bacula
+
+nb=`awk '/a.+b.+c.+d.+a.+b.+c.+h/ { print "OK" }' $tmp/log1.out | grep OK | wc -l`
+if [ $nb != 2 ]; then
+    print_debug "ERROR: should find 2 lines of the pattern in $tmp/log1.out"
+    estat=1
+fi
+
+grep "Warning prompt 2 missing" $tmp/log2.out > /dev/null
+if [ $? != 0 ]; then
+    print_debug "ERROR: should find error line in $tmp/log2.out"
+    estat=1
+fi
+
+
+end_test