#!/bin/sh
#
-# Run a simple backup of the Bacula build directory
-# to two tapes where the maximum tape file size is set to 1M
#
-cwd=`pwd`
-scripts/copy-tape-confs
+TestName="eot-fail-tape"
+JobName=eotfailtape
+. scripts/functions
+
+require_tape_drive
+
scripts/cleanup-tape
+scripts/copy-tape-confs
-echo "${cwd}/build" >/tmp/file-list
+echo "${cwd}/build" >${cwd}/tmp/file-list
-out="tmp/sed_tmp"
-echo "s%# Maximum File Size% Maximum File Size%g" >${out}
+outf="${cwd}/tmp/sed_tmp"
+echo "s%# Maximum File Size% Maximum File Size%g" >${outf}
cp -f ${cwd}/bin/bacula-sd.conf ${cwd}/tmp/1
-sed -f ${out} ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
+sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-sd.conf
-echo " "
-echo " "
-echo " === Starting eot-fail-tape test at `date +%R:%S` ==="
-echo " === Starting eot-fail-tape test at `date +%R:%S` ===" >>working/log
-echo " "
+change_jobname $JobName
+start_test
-bin/bacula start -d100
-bin/bconsole -c bin/bconsole.conf <<END_OF_DATA 2>&1 >/dev/null
-@tee /dev/null
+cat <<END_OF_DATA >${cwd}/tmp/bconcmds
+@$out /dev/null
messages
-@tee tmp/log1.out
-label storage=DDS-4 volume=TestVolume001 slot=0 pool=Default
-update Volume=TestVolume001 MaxVolBytes=3000000
-run job=NightlySave yes
+@$out tmp/log1.out
+label storage=tape volume=TestVolume001 slot=0 pool=Default
+@#update Volume=TestVolume001 MaxVolBytes=3000000
+run job=$JobName yes
wait
messages
@#
@# now do a restore
@#
-@tee tmp/log2.out
-restore where=${cwd}/tmp/bacula-restores select all storage=DDS-4 done
+@$out tmp/log2.out
+restore where=${cwd}/tmp/bacula-restores select all storage=tape done
yes
wait
messages
-@tee
quit
END_OF_DATA
-scripts/check_for_zombie_jobs storage=DDS-4
-bin/bacula stop 2>&1 >/dev/null
-grep "^ Termination: *Backup OK" tmp/log1.out 2>&1 >/dev/null
-bstat=$?
-grep "^ Termination: *Restore OK" tmp/log2.out 2>&1 >/dev/null
-rstat=$?
-diff -r build tmp/bacula-restores${cwd}/build 2>&1 >/dev/null
-if [ $? != 0 -o $bstat != 0 -o $rstat != 0 ] ; then
- echo " "
- echo " "
- echo " !!!!! eot-fail-tape test Bacula source failed!!! !!!!! "
- echo " !!!!! eot-fail-tape test failed!!! !!!!! " >>test.out
- echo " "
-else
- echo " ===== eot-fail-tape test Bacula source OK ===== "
- echo " ===== eot-fail-tape test OK ===== " >>test.out
-# scripts/cleanup
-fi
+run_bacula
+check_for_zombie_jobs storage=tape
+stop_bacula
+
+check_two_logs
+check_restore_diff
+end_test