summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2016-05-25 16:01:59 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2016-05-25 16:02:34 +0000
commit33cffc3f05f0598c91c8b6b7909eb30bfa28ac0c (patch)
treec82234dd43652d896f1d1d708d84540cdde01623 /testsuite
parentAdding debian version 1.8~pre1-1. (diff)
downloadlunzip-33cffc3f05f0598c91c8b6b7909eb30bfa28ac0c.tar.xz
lunzip-33cffc3f05f0598c91c8b6b7909eb30bfa28ac0c.zip
Merging upstream version 1.8.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/check.sh91
1 files changed, 66 insertions, 25 deletions
diff --git a/testsuite/check.sh b/testsuite/check.sh
index f647d6c..f5b2088 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -1,6 +1,6 @@
#! /bin/sh
# check script for Lunzip - Decompressor for the lzip format
-# Copyright (C) 2010-2015 Antonio Diaz Diaz.
+# Copyright (C) 2010-2016 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
# to copy, distribute and modify it.
@@ -17,9 +17,16 @@ if [ ! -f "${LZIP}" ] || [ ! -x "${LZIP}" ] ; then
exit 1
fi
+if [ -e "${LZIP}" ] 2> /dev/null ; then true
+else
+ echo "$0: a POSIX shell is required to run the tests"
+ echo "Try bash -c \"$0 $1 $2\""
+ exit 1
+fi
+
if [ -d tmp ] ; then rm -rf tmp ; fi
mkdir tmp
-cd "${objdir}"/tmp
+cd "${objdir}"/tmp || framework_failure
cat "${testdir}"/test.txt > in || framework_failure
in_lz="${testdir}"/test.txt.lz
@@ -27,21 +34,20 @@ fail=0
printf "testing lunzip-%s..." "$2"
-"${LZIP}" -cqu-1 "${in_lz}" > /dev/null
-if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
-"${LZIP}" -cqu0 "${in_lz}" > /dev/null
-if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
-"${LZIP}" -cqu4095 "${in_lz}" > /dev/null
-if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
-"${LZIP}" -cqu513MiB "${in_lz}" > /dev/null
-if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; 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
+cat "${testdir}"/test.txt.lz > uin.lz || framework_failure
+"${LZIP}" -dfkqu-1 uin.lz
+if [ $? = 1 ] && [ ! -e uin ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -dfkqu0 uin.lz
+if [ $? = 1 ] && [ ! -e uin ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -dfkqu4095 uin.lz
+if [ $? = 1 ] && [ ! -e uin ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -dfkqu513MiB uin.lz
+if [ $? = 1 ] && [ ! -e uin ] ; then printf . ; else printf - ; fail=1 ; fi
+rm -f uin.lz
+"${LZIP}" -tq in
+if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -tq < in
+if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIP}" -cdq in
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIP}" -cdq < in
@@ -51,26 +57,53 @@ 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
-"${LZIP}" -t "${in_lz}" || fail=1
+printf "\ntesting decompression..."
+
+"${LZIP}" -t "${in_lz}"
+if [ $? = 0 ] ; then printf . ; else printf - ; fail=1 ; fi
"${LZIP}" -cd "${in_lz}" > copy || fail=1
cmp in copy || fail=1
printf .
+rm -f copy
cat "${in_lz}" > copy.lz || framework_failure
-printf "to be overwritten" > copy || framework_failure
-"${LZIP}" -df copy.lz || fail=1
+"${LZIP}" -dk copy.lz || fail=1
cmp in copy || fail=1
-printf .
+printf "to be overwritten" > copy || framework_failure
+"${LZIP}" -dq copy.lz
+if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -df copy.lz
+if [ $? = 0 ] && [ ! -e copy.lz ] && cmp in copy ; then
+ printf . ; else printf - ; fail=1 ; fi
printf "to be overwritten" > copy || framework_failure
"${LZIP}" -df -o copy < "${in_lz}" || fail=1
cmp in copy || fail=1
printf .
+rm -f copy
cat "${in_lz}" > anyothername || framework_failure
-"${LZIP}" -d anyothername || fail=1
-cmp in anyothername.out || fail=1
-printf .
+"${LZIP}" -d -o copy - anyothername - < "${in_lz}"
+if [ $? = 0 ] && cmp in copy && cmp in anyothername.out ; then
+ printf . ; else printf - ; fail=1 ; fi
+rm -f copy anyothername.out
+
+"${LZIP}" -tq in "${in_lz}"
+if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -tq foo.lz "${in_lz}"
+if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -cdq in "${in_lz}" > copy
+if [ $? = 2 ] && cat copy in | cmp in - ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -cdq foo.lz "${in_lz}" > copy
+if [ $? = 1 ] && cmp in copy ; then printf . ; else printf - ; fail=1 ; fi
+rm -f copy
+cat "${in_lz}" > copy.lz || framework_failure
+"${LZIP}" -dq in copy.lz
+if [ $? = 2 ] && [ -e copy.lz ] && [ ! -e copy ] && [ ! -e in.out ] ; then
+ printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -dq foo.lz copy.lz
+if [ $? = 1 ] && [ ! -e copy.lz ] && [ ! -e foo ] && cmp in copy ; then
+ printf . ; else printf - ; fail=1 ; fi
cat in in > in2 || framework_failure
cat "${in_lz}" "${in_lz}" > copy2.lz || framework_failure
@@ -80,12 +113,20 @@ cmp in2 copy2 || fail=1
printf .
printf "garbage" >> copy2.lz || framework_failure
+rm -f copy2
+"${LZIP}" -atq copy2.lz
+if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -atq < copy2.lz
+if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -adkq copy2.lz
+if [ $? = 2 ] && [ ! -e copy2 ] ; then printf . ; else printf - ; fail=1 ; fi
+"${LZIP}" -adkq -o copy2 < copy2.lz
+if [ $? = 2 ] && [ ! -e copy2 ] ; then printf . ; else printf - ; fail=1 ; fi
printf "to be overwritten" > copy2 || framework_failure
"${LZIP}" -df copy2.lz || fail=1
cmp in2 copy2 || fail=1
printf .
-rm -f copy
for i in 12 4096 4Ki 29 512KiB ; do
printf "to be overwritten" > copy || framework_failure
"${LZIP}" -df -u$i -o copy < "${in_lz}" || fail=1