#!/bin/sh
#
# Copyright (C) 2000-2026 Kern Sibbald
# License: BSD 2-Clause; see file LICENSE-FOSS
#

#
# Run a simple backup of the Bacula build directory using the compressed option
#   then restore it.
#
TestName="lzo-test"
JobName=lzo
. scripts/functions

grep "LZO support:.*yes" ${cwd}/build/config.out >/dev/null
if [ $? != 0 ] ; then
   echo "LZO support not enabled in Bacula. Skipping lzo-test"
   exit 0
fi

scripts/cleanup
scripts/copy-test-confs
echo "${cwd}/build" >${cwd}/tmp/file-list

start_test
      
cat <<END_OF_DATA >${cwd}/tmp/bconcmds
@output /dev/null
messages
@$out ${cwd}/tmp/log1.out
status all
status all
messages
label storage=File volume=TestVolume001
run job=LZOTest storage=File yes
wait
messages
@# 
@# now do a restore
@#
@$out ${cwd}/tmp/log2.out
restore where=${cwd}/tmp/bacula-restores select storage=File
unmark *
mark *
done
yes
wait
messages
quit
END_OF_DATA

run_bacula
check_for_zombie_jobs storage=File
stop_bacula

check_two_logs
check_restore_diff
grep " Software Compression" ${cwd}/tmp/log1.out | grep "%" 2>&1 1>/dev/null
if [ $? != 0 ] ; then
   echo "  !!!!! No compression !!!!!"
   bstat=1
fi
end_test
