2 # A set of useful functions to be sourced in each test
9 echo "s% mail =%# mail = %g" >${outf}
10 echo "s% operator =%# operator =%g" >>${outf}
11 cp bin/bacula-dir.conf tmp/1
12 sed -f ${outf} tmp/1 >bin/bacula-dir.conf
15 echo " === Starting $TestName at `date +%R:%S` ==="
16 echo " === Starting $TestName at `date +%R:%S` ===" >>working/log
23 MUID=`/usr/bin/id | awk -F= '{print $2}' | awk -F\( '{print $1}'`
24 if [ $MUID != 0 ] ; then
26 echo "You must be root to run this test."
27 echo " ===== !!!! $TestName not run at `date +%R:%S` ==="
28 echo " ===== !!!! $TestName not run at `date +%R:%S` !!!! ===== " >>test.out
36 if test x${TAPE_DRIVE} = x/dev/null ; then
37 echo "$TestName test needs a tape drive, but has none."
42 require_second_drive()
44 if test x${TAPE_DRIVE1} = x/dev/null ; then
45 echo "$JobName needs second drive, but has none."
52 if test x${AUTOCHANGER} = x/dev/null ; then
53 echo "$TestName needs an autochanger, but has none."
60 if test x${USE_FAKETAPE} = x ; then
61 echo "$TestName test needs the faketape driver."
66 skip_if_no_autochanger()
68 if test x${AUTOCHANGER} = x/dev/null ; then
69 echo "$TestName test skipped. No autochanger."
77 if test "$debug" -eq 1 ; then
86 if test "$debug" -eq 1 ; then
95 if test "$debug" -eq 1 ; then
96 bin/bacula-ctl-sd start
97 bin/bacula-ctl-fd start
98 bin/bacula-ctl-dir start
99 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
101 bin/bacula start 2>&1 >/dev/null
102 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
108 if test "$debug" -eq 1 ; then
109 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
111 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
117 if test "$debug" -eq 1 ; then
118 cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out
120 cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 2>&1 >tmp/log1.out
126 if test "$debug" -eq 1 ; then
127 bin/bscan $* | tee tmp/log.out
129 bin/bscan $* 2>&1 >/dev/null
135 B=`echo $LIBDBI | sed 's/;//' | sed 's/;//g'`
136 B_D=`echo $B | awk '{print $3}'`
137 B_t=`echo $B | awk '{print $6}'`
138 B_p=`echo $B | awk '{print $9}'`
140 BSCANLIBDBI="${LIBDBI:+1}"
142 if test "$BSCANLIBDBI" = "1" ; then
143 BSCANLIBDBI="-D $B_D -h $B_t -t $B_p"
151 bin/bacula stop 2>&1 >/dev/null
154 check_for_zombie_jobs()
156 scripts/check_for_zombie_jobs $*
161 if test $# -eq 1; then
169 mv bin/bacula-dir.conf bin/1
170 echo "s%${oldname}%${newname}%g" >tmp/1
171 sed -f tmp/1 bin/1 >bin/bacula-dir.conf
172 # echo "Job ${oldname} changed to ${newname}"
177 grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
179 grep "^ Termination: .*Backup Error" tmp/log1.out 2>&1 >/dev/null
180 if test $? -eq 0; then
183 grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
185 grep "^ Termination: *Restore OK -- warning file count mismatch" tmp/log2.out 2>&1 >/dev/null
186 if test $? -eq 0; then
189 grep "^ Termination: .*Verify Differences" tmp/log2.out 2>&1 >/dev/null
190 if test $? -eq 0; then
197 diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
201 check_restore_tmp_build_diff()
203 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
209 if [ $zstat != 0 ] ; then
211 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
212 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
213 echo " Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat" >>test.out
217 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
220 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
221 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
222 if [ $bstat != 0 -o $rstat != 0 ] ; then
223 echo " !!!!! Bad termination status !!!!! "
224 echo " !!!!! Bad termination status !!!!! " >>test.out
226 echo " !!!!! Restored files differ !!!!! "
227 echo " !!!!! Restored files differ !!!!! " >>test.out
229 echo " Status: backup=$bstat restore=$rstat diff=$dstat"
230 echo " Status: backup=$bstat restore=$rstat diff=$dstat" >>test.out
234 echo " ===== $TestName OK `date +%R:%S` ===== "
235 echo " ===== $TestName OK `date +%R:%S` ===== " >>test.out
236 if test "$debug" -eq 0 ; then
244 scripts/copy-tape-confs
250 scripts/copy-test-confs
256 if test "x${REGRESS_WAIT}" = "x1"; then
257 echo "Start Bacula under debugger and enter anything when ready ..."
264 if test a$USE_FAKETAPE = a; then
272 # Save current directory
274 if test "x${REGRESS_DEBUG}" = "x1"; then
280 # Source the configuration variables