summaryrefslogtreecommitdiffstats
path: root/testsuite/check.sh
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtestsuite/check.sh103
1 files changed, 103 insertions, 0 deletions
diff --git a/testsuite/check.sh b/testsuite/check.sh
new file mode 100755
index 0000000..5885ba2
--- /dev/null
+++ b/testsuite/check.sh
@@ -0,0 +1,103 @@
+#! /bin/sh
+# check script for Lziprecover - Data recovery tool for lzipped files
+# Copyright (C) 2009, 2010, 2011 Antonio Diaz Diaz.
+#
+# This script is free software: you have unlimited permission
+# to copy, distribute and modify it.
+
+LC_ALL=C
+export LC_ALL
+objdir=`pwd`
+testdir=`cd "$1" ; pwd`
+LZIPRECOVER="${objdir}"/lziprecover
+framework_failure() { echo "failure in testing framework" ; exit 1 ; }
+
+if [ ! -x "${LZIPRECOVER}" ] ; then
+ echo "${LZIPRECOVER}: cannot execute"
+ exit 1
+fi
+
+if [ -d tmp ] ; then rm -rf tmp ; fi
+mkdir tmp
+cd "${objdir}"/tmp
+
+ln "${testdir}"/test.txt in || framework_failure
+ln "${testdir}"/test_v1.lz in.lz || framework_failure
+cat in.lz in.lz in.lz > in3.lz || framework_failure
+for i in 1 2 3 4 5 ; do
+ ln "${testdir}"/test_bad${i}.lz bad${i}.lz
+done
+fail=0
+
+# Description of test files for lziprecover:
+# test_bad1.lz: byte at offset 67 changed from 0xCC to 0x33
+# test_bad2.lz: [ 34- 66) --> copy of bytes [ 68- 100)
+# test_bad3.lz: [ 512-1536) --> zeroed; [2560-3584) --> zeroed
+# test_bad4.lz: [3072-4096) --> random data; [4608-5632) --> zeroed
+# test_bad5.lz: [1024-2048) --> random data; [5120-6144) --> random data
+
+printf "testing lziprecover-%s..." "$2"
+
+"${LZIPRECOVER}" -m -o copy.lz bad1.lz bad2.lz bad1.lz -q
+if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
+"${LZIPRECOVER}" -m -o copy.lz bad1.lz bad2.lz || fail=1
+"${LZIPRECOVER}" -df copy.lz || fail=1
+cmp in copy || fail=1
+printf .
+"${LZIPRECOVER}" -m -o copy.lz bad2.lz bad1.lz || fail=1
+"${LZIPRECOVER}" -df copy.lz || fail=1
+cmp in copy || fail=1
+printf .
+
+for i in 1 2 ; do
+ for j in 3 4 5 ; do
+ "${LZIPRECOVER}" -m -o copy.lz bad${i}.lz bad${j}.lz || fail=1
+ "${LZIPRECOVER}" -df copy.lz || fail=1
+ cmp in copy || fail=1
+ printf .
+ "${LZIPRECOVER}" -m -o copy.lz bad${j}.lz bad${i}.lz || fail=1
+ "${LZIPRECOVER}" -df copy.lz || fail=1
+ cmp in copy || fail=1
+ printf .
+ done
+done
+
+"${LZIPRECOVER}" -m -o copy.lz bad3.lz bad4.lz bad5.lz || fail=1
+"${LZIPRECOVER}" -df copy.lz || fail=1
+cmp in copy || fail=1
+printf .
+"${LZIPRECOVER}" -m -o copy.lz bad4.lz bad5.lz bad3.lz || fail=1
+"${LZIPRECOVER}" -df copy.lz || fail=1
+cmp in copy || fail=1
+printf .
+"${LZIPRECOVER}" -m -o copy.lz bad5.lz bad3.lz bad4.lz || fail=1
+"${LZIPRECOVER}" -df copy.lz || fail=1
+cmp in copy || fail=1
+printf .
+
+"${LZIPRECOVER}" -R in.lz || fail=1
+printf .
+"${LZIPRECOVER}" -R -o copy.lz bad2.lz -q
+if [ $? != 2 ] ; then fail=1 ; printf - ; else printf . ; fi
+"${LZIPRECOVER}" -R -o copy.lz bad1.lz || fail=1
+"${LZIPRECOVER}" -df copy.lz || fail=1
+cmp in copy || fail=1
+printf .
+
+cat in3.lz > out || framework_failure
+printf "garbage" >> out || fail=1
+"${LZIPRECOVER}" -s out -o out.lz || fail=1
+for i in 1 2 3 ; do
+ "${LZIPRECOVER}" -cd rec0000${i}out.lz > copy || fail=1
+ cmp in copy || fail=1
+ printf .
+done
+
+echo
+if [ ${fail} = 0 ] ; then
+ echo "tests completed successfully."
+ cd "${objdir}" && rm -r tmp
+else
+ echo "tests failed."
+fi
+exit ${fail}