From: Eric Bollengier Date: Wed, 6 Jan 2021 11:41:23 +0000 (+0100) Subject: regress: Add test for query file variable substitution X-Git-Tag: Release-11.3.2~935 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3fc24c30e47756f554fc8e774808b54090455dd;p=thirdparty%2Fbacula.git regress: Add test for query file variable substitution --- diff --git a/regress/tests/query-subst-test b/regress/tests/query-subst-test new file mode 100755 index 000000000..7efb5f0df --- /dev/null +++ b/regress/tests/query-subst-test @@ -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 < $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 <${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