#
# Part of the ht://Dig package   <http://www.htdig.org/>
# Copyright (c) 1999, 2000 The ht://Dig Group
# For copyright details, see the file COPYING in your distribution
# or the GNU General Public License version 2 or later
# <http://www.gnu.org/copyleft/gpl.html>
#
# $Id: t_htdb,v 1.12 2000/06/29 11:57:02 loic Exp $
#

. ./test_functions

#
# load/dump/stat with and without compression, using
# stock Berkeley DB functionalities.
#
for compress in "" # "-z"
do
   rm -f test
   ../htdb/htdb_load -f $srcdir/t_htdb.dump  $compress test || exit 1
   ../htdb/htdb_dump -p  $compress test > t_htdb.d1 || exit 1
   cmp $srcdir/t_htdb.dump t_htdb.d1 || exit 1
   ../htdb/htdb_stat  $compress -d test | grep '35	Number of unique keys in the tree' > /dev/null || exit 1
done

export MIFLUZ_CONFIG ; MIFLUZ_CONFIG=${srcdir}/mifluz-search.conf

#
# load/dump/stat with and without compression, using
# mifluz specific compression and sort functions.
#
for compress in "" "-z"
do
   rm -f test
   ../htdb/mifluzload $compress $VERBOSE test < $srcdir/search.txt
   ../htdb/htdb_dump -W -p  $compress test > t_htdb.d1 || exit 1   
   rm -f test
   ../htdb/htdb_load -W -f t_htdb.d1  $compress test || exit 1
   ../htdb/htdb_dump -W -p  $compress test > t_htdb.d2 || exit 1   
   cmp t_htdb.d1 t_htdb.d2 || exit 1
done

#
# mifluzdump/mifluzload
#
rm test
../htdb/mifluzload test < $srcdir/search.txt || exit 1
../htdb/mifluzdump test > search1.txt || exit 1
../htdb/mifluzload test < search1.txt || exit 1
../htdb/mifluzdump test > search2.txt || exit 1
cmp search[12].txt
rm -f search[12].txt

a=`../htdb/htdb_dump -W -l test`
if [ "$a" != "dead
dict
index
meta
tmp" ]
then
	echo htdb_dump -l failed
	exit 1
fi

