2 # A set of useful functions to be sourced in each test
10 echo "s% mail =%# mail = %g" >${outf}
11 echo "s% operator =%# operator =%g" >>${outf}
12 cp bin/bacula-dir.conf tmp/1
13 sed -f ${outf} tmp/1 >bin/bacula-dir.conf
16 echo " === Starting $TestName at `date +%R:%S` ==="
17 echo " === Starting $TestName at `date +%R:%S` ===" >>working/log
24 MUID=`/usr/bin/id | awk -F= '{print $2}' | awk -F\( '{print $1}'`
25 if [ $MUID != 0 ] ; then
27 echo "You must be root to run this test."
28 echo " ===== !!!! $TestName not run at `date +%R:%S` ==="
29 echo " ===== !!!! $TestName not run at `date +%R:%S` !!!! ===== " >>test.out
37 if test x${TAPE_DRIVE} = x/dev/null ; then
38 echo "$TestName test needs a tape drive, but has none."
43 require_second_drive()
45 if test x${TAPE_DRIVE1} = x/dev/null ; then
46 echo "$JobName needs second drive, but has none."
53 if test x${AUTOCHANGER} = x/dev/null ; then
54 echo "$TestName needs an autochanger, but has none."
61 if test x${USE_VTAPE} = x ; then
62 echo "$TestName test needs the vtape driver."
70 if [ $os != 'Linux' ]; then
71 echo "This test $TestName runs only on Linux"
76 skip_if_no_autochanger()
78 if test x${AUTOCHANGER} = x/dev/null ; then
79 echo "$TestName test skipped. No autochanger."
87 if test "$debug" -eq 1 ; then
96 if test "$debug" -eq 1 ; then
105 if test "$debug" -eq 1 ; then
106 bin/bacula-ctl-sd start
107 bin/bacula-ctl-fd start
108 bin/bacula-ctl-dir start
109 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
112 bin/bacula start 2>&1 >/dev/null
113 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
120 if test "$debug" -eq 1 ; then
121 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
123 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
129 if test "$debug" -eq 1 ; then
130 cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out
132 cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 2>&1 >tmp/log1.out
138 if test "$debug" -eq 1 ; then
139 bin/bscan $* | tee tmp/log.out
141 bin/bscan $* 2>&1 >/dev/null
147 B=`echo $LIBDBI | sed 's/;//' | sed 's/;//g'`
148 B_D=`echo $B | awk '{print $3}'`
149 B_t=`echo $B | awk '{print $6}'`
150 B_p=`echo $B | awk '{print $9}'`
152 BSCANLIBDBI="${LIBDBI:+1}"
154 if test "$BSCANLIBDBI" = "1" ; then
155 BSCANLIBDBI="-D $B_D -h $B_t -t $B_p"
163 bin/bacula stop 2>&1 >/dev/null
166 check_for_zombie_jobs()
168 scripts/check_for_zombie_jobs $*
173 if test $# -eq 1; then
181 mv bin/bacula-dir.conf bin/1
182 echo "s%${oldname}%${newname}%g" >tmp/1
183 sed -f tmp/1 bin/1 >bin/bacula-dir.conf
184 # echo "Job ${oldname} changed to ${newname}"
189 grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
191 grep "^ Termination: .*Backup Error" tmp/log1.out 2>&1 >/dev/null
192 if test $? -eq 0; then
195 grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
197 grep "^ Termination: *Restore OK -- warning file count mismatch" tmp/log2.out 2>&1 >/dev/null
198 if test $? -eq 0; then
201 grep "^ Termination: .*Verify Differences" tmp/log2.out 2>&1 >/dev/null
202 if test $? -eq 0; then
209 diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
213 check_restore_tmp_build_diff()
215 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
221 if [ $zstat != 0 ] ; then
223 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
224 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
225 echo " Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat" >>test.out
229 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
232 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
233 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
234 if [ $bstat != 0 -o $rstat != 0 ] ; then
235 echo " !!!!! Bad termination status !!!!! "
236 echo " !!!!! Bad termination status !!!!! " >>test.out
238 echo " !!!!! Restored files differ !!!!! "
239 echo " !!!!! Restored files differ !!!!! " >>test.out
241 echo " Status: backup=$bstat restore=$rstat diff=$dstat"
242 echo " Status: backup=$bstat restore=$rstat diff=$dstat" >>test.out
246 echo " ===== $TestName OK `date +%R:%S` ===== "
247 echo " ===== $TestName OK `date +%R:%S` ===== " >>test.out
248 if test "$debug" -eq 0 ; then
256 scripts/copy-tape-confs
262 scripts/copy-test-confs
268 if test "x${REGRESS_WAIT}" = "x1"; then
269 echo "Start Bacula under debugger and enter anything when ready ..."
278 if test -n "$DRIVE" -a -n "$SLOT"; then
279 if test ! -c $DRIVE -a ! -b $DRIVE -a x$USE_VTAPE != x ; then
288 if test a$USE_VTAPE = a; then
296 # Save current directory
298 if test "x${REGRESS_DEBUG}" = "x1"; then
304 # Source the configuration variables
308 AUTOCHANGER_SCRIPT=${AUTOCHANGER_SCRIPT:-mtx-changer}