Add a functionality test suite.

This commit is contained in:
Moinak Ghosh 2012-11-08 22:22:37 +05:30
parent eacbf207aa
commit 7debc60dd5
9 changed files with 39539 additions and 0 deletions

View file

@ -96,6 +96,7 @@ BAKFILES = *~ lzma/*~ lzfx/*~ lz4/*~ rabin/*~ bsdiff/*~ lzp/*~ utils/*~ crypto/s
crypto/sha2/intel/*~ crypto/aes/*~ crypto/scrypt/*~ crypto/*~
RM = rm -f
RM_RF = rm -rf
COMMON_CPPFLAGS = -I. -I./lzma -I./lzfx -I./lz4 -I./rabin -I./bsdiff -DNODEFAULT_PROPS \
-DFILE_OFFSET_BITS=64 -D_REENTRANT -D__USE_SSE_INTRIN__ -D_LZMA_PROB32 \
-I./lzp @LIBBSCCPPFLAGS@ -I./crypto/skein -I./utils -I@OPENSSL_INCDIR@ \
@ -190,8 +191,13 @@ $(MAINOBJS): $(MAINSRCS) $(MAINHDRS)
$(PROG): $(OBJS)
$(LINK) -o $@ $(OBJS) $(LDLIBS)
test: all
(cd test; sh ./run_test.sh) 2>&1 | tee test.log
clean:
$(RM) $(PROG) $(OBJS) $(BAKFILES)
$(RM) test.log
$(RM_RF) test/datafiles
distclean: clean
$(RM) Makefile

BIN
test/res/jpg/screen.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

39178
test/res/xml/iso_639_3.xml Normal file

File diff suppressed because it is too large Load diff

64
test/run_test.sh Normal file
View file

@ -0,0 +1,64 @@
#!/bin/sh
tst=$1
if [ ! -d datafiles ]
then
mkdir datafiles
else
rm -f datafiles/.pco*
rm -f datafiles/*.pz
rm -f datafiles/*.1
fi
PDIR=`pwd`
[ ! -f datafiles/bin.dat ] && (tar cpf - /usr/bin | dd of=datafiles/bin.dat bs=1024 count=5120; cat res/jpg/*.jpg >> datafiles/bin.dat)
[ ! -f datafiles/share.dat ] && tar cpf - /usr/share | dd of=datafiles/share.dat bs=1024 count=5120
[ ! -f datafiles/inc.dat ] && (tar cpf - /usr/include | dd of=datafiles/inc.dat bs=1024 count=5120; cat res/xml/*.xml >> datafiles/inc.dat)
[ ! -f datafiles/combined.dat ] && cat datafiles/bin.dat datafiles/share.dat datafiles/inc.dat >> datafiles/combined.dat
[ ! -f datafiles/comb_d.dat ] && sh -c "cat datafiles/combined.dat > datafiles/comb_d.dat; cat datafiles/combined.dat >> datafiles/comb_d.dat"
failures=0
if [ "x$tst" = "x" ]
then
for tf in *
do
echo "$tf" | grep "tst" > /dev/null
[ $? -ne 0 ] && continue
cd datafiles
(. ../${tf})
if [ $? -ne 0 ]
then
echo "FATAL: Test ${tf} failed"
failures=$((failures + 1))
fi
cd $PDIR
done
else
tf="t${tst}.tst"
if [ -f $tf ]
then
cd datafiles
(. ../${tf})
if [ $? -ne 0 ]
then
echo "FATAL: Test ${tf} failed"
failures=$((failures + 1))
fi
cd $PDIR
else
echo "No such test $tst"
exit 1
fi
fi
if [ $failures -gt 0 ]
then
echo "$failures tests Failed!"
exit 1
else
echo "All tests PASSED"
fi

51
test/t1.tst Normal file
View file

@ -0,0 +1,51 @@
#
# Simple compress and decompress
#
echo "#################################################"
echo "# Simple compress and decompress"
echo "#################################################"
for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc ppmd adapt adapt2
do
../../pcompress 2>&1 | grep $algo > /dev/null
[ $? -ne 0 ] && continue
for level in 1 3 9 14
do
for tf in bin.dat share.dat inc.dat
do
for seg in 1m 100m
do
[ $level -lt 14 -a "$seg" = "100m" ] && continue
cmd="../../pcompress -c ${algo} -l ${level} -s ${seg} ${tf}"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
diff ${tf} ${tf}.1 | grep -i differ
if [ $? -eq 0 ]
then
echo "${cmd}: Decompression was not correct"
exit 1
fi
rm -f ${tf}.pz ${tf}.1
done
done
done
done
echo "#################################################"
echo ""

44
test/t2.tst Normal file
View file

@ -0,0 +1,44 @@
#
# Test all checksum mechanisms
#
echo "#################################################"
echo "# All checksums"
echo "#################################################"
for algo in zlib ppmd
do
for tf in bin.dat share.dat inc.dat
do
for cksum in CRC64 SHA256 SHA512 SKEIN256 SKEIN512
do
cmd="../../pcompress -c ${algo} -l 6 -s 1m -S ${cksum} ${tf}"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
diff ${tf} ${tf}.1 | grep -i differ
if [ $? -eq 0 ]
then
echo "${cmd}: Decompression was not correct"
exit 1
fi
rm -f ${tf}.pz ${tf}.1
done
done
done
echo "#################################################"
echo ""

83
test/t3.tst Normal file
View file

@ -0,0 +1,83 @@
#
# Simple compress and decompress
#
clean() {
for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc
do
for tf in bin.dat share.dat inc.dat
do
rm -f ${tf}.${algo}
done
done
}
echo "#################################################"
echo "# Compress compressed files"
echo "#################################################"
clean
for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc ppmd adapt adapt2
do
../../pcompress 2>&1 | grep $algo > /dev/null
[ $? -ne 0 ] && continue
for tf in bin.dat share.dat inc.dat
do
echo "Preparing ${algo} compressed ${tf} datafile ..."
cmd="../../pcompress -c ${algo} -l5 -s500k ${tf}"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
mv ${tf}.pz ${tf}.${algo}
done
done
for algo in lzfx lz4 zlib bzip2 lzma lzmaMt libbsc ppmd adapt adapt2
do
../../pcompress 2>&1 | grep $algo > /dev/null
[ $? -ne 0 ] && continue
for level in 1 3 9 14
do
for tf in bin.dat share.dat inc.dat
do
for seg in 1m 100m
do
[ $level -lt 14 -a "$seg" = "100m" ] && continue
cmd="../../pcompress -c ${algo} -l ${level} -s ${seg} ${tf}.${algo}"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
cmd="../../pcompress -d ${tf}.${algo}.pz ${tf}.${algo}.1"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
diff ${tf}.${algo} ${tf}.${algo}.1 | grep -i differ
if [ $? -eq 0 ]
then
echo "${cmd}: Decompression was not correct"
exit 1
fi
rm -f ${tf}.${algo}.pz ${tf}.${algo}.1
done
done
done
done
clean
echo "#################################################"
echo ""

47
test/t4.tst Normal file
View file

@ -0,0 +1,47 @@
#
# Dedupe, Delta et al.
#
echo "#################################################"
echo "# Test Deduplication, Delta Encoding and LZP"
echo "#################################################"
for algo in lzfx lz4 adapt
do
for tf in combined.dat comb_d.dat
do
for feat in "-D" "-D -B3 -L" "-D -B4 -E" "-D -B2 -EE" "-D -B5 -EE -L" "-D -B2 -r"
do
for seg in 2m 100m
do
cmd="../../pcompress -c ${algo} -l 3 -s ${seg} $feat ${tf}"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
cmd="../../pcompress -d ${tf}.pz ${tf}.1"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
diff ${tf} ${tf}.1 | grep -i differ
if [ $? -eq 0 ]
then
echo "${cmd}: Decompression was not correct"
exit 1
fi
rm -f ${tf}.pz ${tf}.1
done
done
done
done
echo "#################################################"
echo ""

66
test/t5.tst Normal file
View file

@ -0,0 +1,66 @@
#
# Test crypto
#
echo "#################################################"
echo "# Crypto tests"
echo "#################################################"
for algo in lzfx adapt2
do
for tf in comb_d.dat
do
for feat in "-e" "-e -L" "-D -e" "-D -EE -L -e" "-e -S CRC64"
do
for seg in 2m 100m
do
echo "sillypassword" > /tmp/pwf
cmd="../../pcompress -c ${algo} -l 3 -s ${seg} $feat -w /tmp/pwf ${tf}"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
pw=`cat /tmp/pwf`
if [ "$pw" = "sillypassword" ]
then
echo "ERROR: Password file /tmp/pwf not zeroed!"
exit 1
fi
echo "sillypassword" > /tmp/pwf
cmd="../../pcompress -d -w /tmp/pwf ${tf}.pz ${tf}.1"
echo "Running $cmd"
eval $cmd
if [ $? -ne 0 ]
then
echo "${cmd} errored."
exit 1
fi
diff ${tf} ${tf}.1 | grep -i differ
if [ $? -eq 0 ]
then
echo "${cmd}: Decompression was not correct"
exit 1
fi
pw=`cat /tmp/pwf`
if [ "$pw" = "sillypassword" ]
then
echo "ERROR: Password file /tmp/pwf not zeroed!"
exit 1
fi
rm -f ${tf}.pz ${tf}.1
done
done
done
done
rm -f /tmp/pwf
echo "#################################################"
echo ""