#!/bin/sh
#
# Run a simple Verify InitCatalog, then Verify Catalog
#
TestName="verify-cat-test"
JobName=VerifyCatalog
. scripts/functions

cwd=`pwd`
scripts/cleanup
scripts/copy-test-confs

# Directory to backup.
# This directory will be created by setup_data().
BackupDirectory="${tmp}/data"

# Use a tgz to setup data to be backed up.
# Data will be placed at "${tmp}/data/".
setup_data data/small.tgz

# the default fileset FS_TESTJOB backups all file and directories defined in "${tmp}/file-list".
echo "${BackupDirectory}" >${tmp}/file-list


#echo "${cwd}/do_all" >${cwd}/tmp/file-list
#echo "${cwd}/do_all_tapes" >>${cwd}/tmp/file-list
#echo "${cwd}/do_file" >>${cwd}/tmp/file-list

change_jobname NightlySave $JobName
start_test

cat <<END_OF_DATA >tmp/bconcmds
@output /dev/null
messages
@$out tmp/log1.out
@#exec "sh -c 'touch ${BackupDirectory}/xxx_new_file'"
run job=VerifyVolume level=InitCatalog yes
wait
messages
@#
@# now do a verify Catalog
@#
@$out ${cwd}/tmp/original
@#exec "sh -c 'rm -f ${BackupDirectory}/xxx_new_file'"
run job=VerifyVolume level=Catalog yes
wait
messages
quit
END_OF_DATA

run_bareos

sleep 2
check_for_zombie_jobs storage=File
stop_bareos

grep "^  Termination: *Verify OK" tmp/log1.out 2>&1 >/dev/null
bstat=$?
grep "^  Termination: *Verify OK" ${cwd}/tmp/original 2>&1 >/dev/null
rstat=$?
dstat=0
end_test
