summaryrefslogtreecommitdiffstats
path: root/testsuite/check.sh
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/check.sh')
-rwxr-xr-xtestsuite/check.sh105
1 files changed, 64 insertions, 41 deletions
diff --git a/testsuite/check.sh b/testsuite/check.sh
index 314c19e..21da2a8 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -1,6 +1,6 @@
#! /bin/sh
# check script for Lziprecover - Data recovery tool for lzip files
-# Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
+# Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
# to copy, distribute and modify it.
@@ -13,7 +13,7 @@ LZIP="${objdir}"/lziprecover
LZIPRECOVER="${LZIP}"
framework_failure() { echo "failure in testing framework" ; exit 1 ; }
-if [ ! -x "${LZIP}" ] ; then
+if [ ! -f "${LZIP}" ] || [ ! -x "${LZIP}" ] ; then
echo "${LZIP}: cannot execute"
exit 1
fi
@@ -22,7 +22,7 @@ if [ -d tmp ] ; then rm -rf tmp ; fi
mkdir tmp
cd "${objdir}"/tmp
-in="${testdir}"/test.txt
+cat "${testdir}"/test.txt > in || framework_failure
in_lz="${testdir}"/test.txt.lz
inD="${testdir}"/test921-1921.txt
fox5_lz="${testdir}"/fox5.lz
@@ -57,30 +57,63 @@ fail=0
printf "testing lziprecover-%s..." "$2"
-"${LZIPRECOVER}" -lq
-if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
-"${LZIPRECOVER}" -mq "${bad1_lz}"
-if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
-"${LZIPRECOVER}" -Rq
-if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
-"${LZIPRECOVER}" -sq
-if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi
-"${LZIP}" -tq "${in}"
-if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
-"${LZIP}" -tq < "${in}"
-if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
-"${LZIP}" -cdq "${in}"
-if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
-"${LZIP}" -cdq < "${in}"
-if [ $? = 2 ] ; then printf . ; else fail=1 ; printf - ; fi
+printf " in: Bad magic number (file not in lzip format).\n" > msg
+"${LZIP}" -t in 2> out
+if [ $? = 2 ] && cmp out msg ; then printf . ; else printf - ; fail=1 ; fi
+printf " (stdin): Bad magic number (file not in lzip format).\n" > msg
+"${LZIP}" -t < in 2> out
+if [ $? = 2 ] && cmp out msg ; then printf . ; else printf - ; fail=1 ; fi
+rm -f out msg
+"${LZIP}" -cdq in
+if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -cdq < in
+if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
dd if="${in_lz}" bs=1 count=6 2> /dev/null | "${LZIP}" -tq
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
dd if="${in_lz}" bs=1 count=20 2> /dev/null | "${LZIP}" -tq
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIPRECOVER}" -lq
+if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIPRECOVER}" -mq "${bad1_lz}"
+if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIPRECOVER}" -Rq
+if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIPRECOVER}" -sq
+if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIP}" -t "${in_lz}" || fail=1
"${LZIP}" -cd "${in_lz}" > copy || fail=1
-cmp "${in}" copy || fail=1
+cmp in copy || fail=1
+printf .
+
+cat "${in_lz}" > copy.lz || framework_failure
+printf "to be overwritten" > copy || framework_failure
+"${LZIP}" -df copy.lz || fail=1
+cmp in copy || fail=1
+printf .
+
+printf "to be overwritten" > copy || framework_failure
+"${LZIP}" -df -o copy < "${in_lz}" || fail=1
+cmp in copy || fail=1
+printf .
+
+cat "${in_lz}" > anyothername || framework_failure
+"${LZIP}" -d anyothername || fail=1
+cmp in anyothername.out || fail=1
+printf .
+
+cat in in > in2 || framework_failure
+cat "${in_lz}" "${in_lz}" > copy2.lz || framework_failure
+"${LZIP}" -t copy2.lz || fail=1
+printf .
+"${LZIP}" -cd copy2.lz > copy2 || fail=1
+cmp in2 copy2 || fail=1
+printf .
+
+printf "garbage" >> copy2.lz || framework_failure
+printf "to be overwritten" > copy2 || framework_failure
+"${LZIP}" -df copy2.lz || fail=1
+cmp in2 copy2 || fail=1
printf .
"${LZIPRECOVER}" -D 921-1921 -fo copy "${in_lz}" || fail=1
@@ -89,23 +122,23 @@ cmp "${inD}" copy || fail=1
cmp "${inD}" copy || fail=1
printf .
"${LZIPRECOVER}" -D0 -iq "${f5b1_lz}" -fo copy
-if [ $? = 2 ] && cmp "${f5b1}" copy ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 2 ] && cmp "${f5b1}" copy ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -D0 -iq "${f5b1_lz}" > copy
-if [ $? = 2 ] && cmp "${f5b1}" copy ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 2 ] && cmp "${f5b1}" copy ; then printf . ; else printf - ; fail=1 ; fi
rm -f copy.lz
"${LZIPRECOVER}" -m -o copy.lz "${fox5_lz}" "${f5b1_lz}"
-if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -m -o copy.lz "${f5b1_lz}" "${fox5_lz}"
-if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -m -o copy.lz "${bad1_lz}" "${bad2_lz}" "${bad1_lz}" -q
-if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -m -o copy.lz "${f5b1_lz}" "${f5b5_lz}" -q
-if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -m -o copy.lz "${f5b3_lz}" "${f5b5_lz}" -q
-if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -m -o copy.lz "${bad3_lz}" "${bad4_lz}" -q
-if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
for i in "${f5b1_lz}" "${f5b3_lz}" "${f5b4_lz}" "${f5b5_lz}" ; do
"${LZIPRECOVER}" -mf -o copy.lz "${f5b2_lz}" "${i}" || fail=1
@@ -178,9 +211,9 @@ printf .
rm -f copy.lz
"${LZIPRECOVER}" -R -o copy.lz "${fox5_lz}" || fail=1
-if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -R -o copy.lz "${bad2_lz}" -q
-if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi
+if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIPRECOVER}" -Rf -o copy.lz "${f5b1_lz}" || fail=1
cmp "${fox5_lz}" copy.lz || fail=1
"${LZIPRECOVER}" -Rf -o copy.lz "${bad1_lz}" || fail=1
@@ -192,20 +225,10 @@ printf "garbage" >> copy || fail=1
"${LZIPRECOVER}" -s -o copy.lz copy || fail=1
for i in 1 2 3 ; do
"${LZIPRECOVER}" -cd rec${i}copy.lz > copy || fail=1
- cmp "${in}" copy || fail=1
+ cmp in copy || fail=1
done
printf .
-cat "${in_lz}" > anyothername || framework_failure
-"${LZIP}" -d anyothername || fail=1
-cmp "${in}" anyothername.out || fail=1
-printf .
-
-cat "${in}" "${in}" > in2 || framework_failure
-cat "${in_lz}" "${in_lz}" | "${LZIP}" -d > copy2 || fail=1
-cmp in2 copy2 || fail=1
-printf .
-
echo
if [ ${fail} = 0 ] ; then
echo "tests completed successfully."