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."
59 skip_if_no_autochanger()
61 if test x${AUTOCHANGER} = x/dev/null ; then
62 echo "$TestName test skipped. No autochanger."
70 if test "$debug" -eq 1 ; then
79 if test "$debug" -eq 1 ; then
88 if test "$debug" -eq 1 ; then
89 bin/bacula-ctl-sd start
90 bin/bacula-ctl-fd start
91 bin/bacula-ctl-dir start
92 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
94 bin/bacula start 2>&1 >/dev/null
95 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
101 if test "$debug" -eq 1 ; then
102 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf
104 cat tmp/bconcmds | bin/bconsole -c bin/bconsole.conf 2>&1 >/dev/null
110 if test "$debug" -eq 1 ; then
111 cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 | tee tmp/log1.out
113 cat tmp/bconcmds | bin/btape -c bin/bacula-sd.conf DDS-4 2>&1 >tmp/log1.out
119 if test "$debug" -eq 1 ; then
120 bin/bscan $* | tee tmp/log.out
122 bin/bscan $* 2>&1 >/dev/null
129 bin/bacula stop 2>&1 >/dev/null
132 check_for_zombie_jobs()
134 scripts/check_for_zombie_jobs $*
139 if test $# -eq 1; then
147 mv bin/bacula-dir.conf bin/1
148 echo "s%${oldname}%${newname}%g" >tmp/1
149 sed -f tmp/1 bin/1 >bin/bacula-dir.conf
150 # echo "Job ${oldname} changed to ${newname}"
155 grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
157 grep "^ Termination: .*Backup Error" tmp/log1.out 2>&1 >/dev/null
158 if test $? -eq 0; then
161 grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
163 grep "^ Termination: *Restore OK -- warning file count mismatch" tmp/log2.out 2>&1 >/dev/null
164 if test $? -eq 0; then
167 grep "^ Termination: .*Verify Differences" tmp/log2.out 2>&1 >/dev/null
168 if test $? -eq 0; then
175 diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
179 check_restore_tmp_build_diff()
181 diff -r tmp/build tmp/bacula-restores${cwd}/tmp/build 2>&1 >/dev/null
187 if [ $zstat != 0 ] ; then
189 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
190 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
191 echo " Status: zombie=$zstat backup=$bstat restore=$rstat diff=$dstat" >>test.out
195 if [ $dstat != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
198 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! "
199 echo " !!!!! $TestName failed!!! `date +%R:%S` !!!!! " >>test.out
200 if [ $bstat != 0 -o $rstat != 0 ] ; then
201 echo " !!!!! Bad termination status !!!!! "
202 echo " !!!!! Bad termination status !!!!! " >>test.out
204 echo " !!!!! Restored files differ !!!!! "
205 echo " !!!!! Restored files differ !!!!! " >>test.out
207 echo " Status: backup=$bstat restore=$rstat diff=$dstat"
208 echo " Status: backup=$bstat restore=$rstat diff=$dstat" >>test.out
212 echo " ===== $TestName OK `date +%R:%S` ===== "
213 echo " ===== $TestName OK `date +%R:%S` ===== " >>test.out
214 if test "$debug" -eq 0 ; then
222 scripts/copy-tape-confs
228 scripts/copy-test-confs
234 if test "x${REGRESS_WAIT}" = "x1"; then
235 echo "Start Bacula under debugger and enter anything when ready ..."
240 # Save current directory
242 if test "x${REGRESS_DEBUG}" = "x1"; then
248 # Source the configuration variables