#!/bin/bash
set -e
set -o pipefail
set -u

TestName="$(basename "$(pwd)")"
export TestName

myname=$(basename "$0")

#shellcheck source=../environment.in
. ./environment

#shellcheck source=../scripts/functions
. "${rscripts}"/functions

expected_files=2

start_test

mkdir -p "${tmp}/data"
echo "$0" >"${tmp}/data/$myname"

cat <<END_OF_DATA >"$tmp/bconcmds"
@$out ${NULL_DEV}
messages
@$out $tmp/$myname.log
run job=backup-DBFileStream level=Full yes
wait
messages
quit
END_OF_DATA

run_bconsole

check_log "$tmp/$myname.log"
check_for_zombie_jobs storage=File

if ! grep -q "IClientVirtualDeviceSet2::GetConfiguration successful: 0 (NOERROR)" "$tmp/$myname.log"; then
  echo "\"IClientVirtualDeviceSet2::GetConfiguration successful: 0 (NOERROR)\" not found in log"
  exit 2
fi

end_test
