summaryrefslogtreecommitdiffstats
path: root/testsuite/check.sh
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/check.sh')
-rwxr-xr-xtestsuite/check.sh170
1 files changed, 102 insertions, 68 deletions
diff --git a/testsuite/check.sh b/testsuite/check.sh
index a4113c3..59fe3f5 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -1,6 +1,6 @@
#! /bin/sh
-# check script for Plzip - Parallel compressor compatible with lzip
-# Copyright (C) 2009-2018 Antonio Diaz Diaz.
+# check script for Plzip - Massively parallel implementation of lzip
+# Copyright (C) 2009-2019 Antonio Diaz Diaz.
#
# This script is free software: you have unlimited permission
# to copy, distribute and modify it.
@@ -31,17 +31,28 @@ cd "${objdir}"/tmp || framework_failure
cat "${testdir}"/test.txt > in || framework_failure
in_lz="${testdir}"/test.txt.lz
fail=0
+lwarn8=0
+lwarn10=0
test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; }
+lzlib_1_8() { [ ${lwarn8} = 0 ] &&
+ printf "\nwarning: header truncation detection requires lzlib 1.8 or newer"
+ lwarn8=1 ; }
+lzlib_1_10() { [ ${lwarn10} = 0 ] &&
+ printf "\nwarning: header HD=3 detection requires lzlib 1.10 or newer"
+ lwarn10=1 ; }
printf "testing plzip-%s..." "$2"
"${LZIP}" -fkqm4 in
-{ [ $? = 1 ] && [ ! -e in.lz ] ; } || test_failed $LINENO
+[ $? = 1 ] || test_failed $LINENO
+[ ! -e in.lz ] || test_failed $LINENO
"${LZIP}" -fkqm274 in
-{ [ $? = 1 ] && [ ! -e in.lz ] ; } || test_failed $LINENO
+[ $? = 1 ] || test_failed $LINENO
+[ ! -e in.lz ] || test_failed $LINENO
for i in bad_size -1 0 4095 513MiB 1G 1T 1P 1E 1Z 1Y 10KB ; do
"${LZIP}" -fkqs $i in
- { [ $? = 1 ] && [ ! -e in.lz ] ; } || test_failed $LINENO $i
+ [ $? = 1 ] || test_failed $LINENO $i
+ [ ! -e in.lz ] || test_failed $LINENO $i
done
"${LZIP}" -lq in
[ $? = 2 ] || test_failed $LINENO
@@ -91,26 +102,34 @@ printf "\ntesting decompression..."
"${LZIP}" -cd "${in_lz}" > copy || test_failed $LINENO
cmp in copy || test_failed $LINENO
-rm -f copy
+rm -f copy || framework_failure
cat "${in_lz}" > copy.lz || framework_failure
"${LZIP}" -dk copy.lz || test_failed $LINENO
cmp in copy || test_failed $LINENO
printf "to be overwritten" > copy || framework_failure
"${LZIP}" -d copy.lz 2> /dev/null
[ $? = 1 ] || test_failed $LINENO
-"${LZIP}" -df copy.lz
-{ [ $? = 0 ] && [ ! -e copy.lz ] && cmp in copy ; } || test_failed $LINENO
+"${LZIP}" -df copy.lz || test_failed $LINENO
+[ ! -e copy.lz ] || test_failed $LINENO
+cmp in copy || test_failed $LINENO
+
+rm -f copy || framework_failure
+cat "${in_lz}" > copy.lz || framework_failure
+"${LZIP}" -d -S100k copy.lz || test_failed $LINENO # ignore -S
+[ ! -e copy.lz ] || test_failed $LINENO
+cmp in copy || test_failed $LINENO
printf "to be overwritten" > copy || framework_failure
"${LZIP}" -df -o copy < "${in_lz}" || test_failed $LINENO
cmp in copy || test_failed $LINENO
-rm -f copy
+rm -f copy || framework_failure
"${LZIP}" < in > anyothername || test_failed $LINENO
-"${LZIP}" -dv --output copy - anyothername - < "${in_lz}" 2> /dev/null
-{ [ $? = 0 ] && cmp in copy && cmp in anyothername.out ; } ||
+"${LZIP}" -dv --output copy - anyothername - < "${in_lz}" 2> /dev/null ||
test_failed $LINENO
-rm -f copy anyothername.out
+cmp in copy || test_failed $LINENO
+cmp in anyothername.out || test_failed $LINENO
+rm -f copy anyothername.out || framework_failure
"${LZIP}" -lq in "${in_lz}"
[ $? = 2 ] || test_failed $LINENO
@@ -121,10 +140,12 @@ rm -f copy anyothername.out
"${LZIP}" -tq nx_file.lz "${in_lz}"
[ $? = 1 ] || test_failed $LINENO
"${LZIP}" -cdq in "${in_lz}" > copy
-{ [ $? = 2 ] && cat copy in | cmp in - ; } || test_failed $LINENO
+[ $? = 2 ] || test_failed $LINENO
+cat copy in | cmp in - || test_failed $LINENO
"${LZIP}" -cdq nx_file.lz "${in_lz}" > copy
-{ [ $? = 1 ] && cmp in copy ; } || test_failed $LINENO
-rm -f copy
+[ $? = 1 ] || test_failed $LINENO
+cmp in copy || test_failed $LINENO
+rm -f copy || framework_failure
cat "${in_lz}" > copy.lz || framework_failure
for i in 1 2 3 4 5 6 7 ; do
printf "g" >> copy.lz || framework_failure
@@ -134,11 +155,15 @@ for i in 1 2 3 4 5 6 7 ; do
[ $? = 2 ] || test_failed $LINENO $i
done
"${LZIP}" -dq in copy.lz
-{ [ $? = 2 ] && [ -e copy.lz ] && [ ! -e copy ] && [ ! -e in.out ] ; } ||
- test_failed $LINENO
+[ $? = 2 ] || test_failed $LINENO
+[ -e copy.lz ] || test_failed $LINENO
+[ ! -e copy ] || test_failed $LINENO
+[ ! -e in.out ] || test_failed $LINENO
"${LZIP}" -dq nx_file.lz copy.lz
-{ [ $? = 1 ] && [ ! -e copy.lz ] && [ ! -e nx_file ] && cmp in copy ; } ||
- test_failed $LINENO
+[ $? = 1 ] || test_failed $LINENO
+[ ! -e copy.lz ] || test_failed $LINENO
+[ ! -e nx_file ] || test_failed $LINENO
+cmp in copy || test_failed $LINENO
cat in in > in2 || framework_failure
cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure
@@ -155,7 +180,7 @@ cmp in2 copy2 || test_failed $LINENO
printf "\ngarbage" >> copy2.lz || framework_failure
"${LZIP}" -tvvvv copy2.lz 2> /dev/null || test_failed $LINENO
-rm -f copy2
+rm -f copy2 || framework_failure
"${LZIP}" -alq copy2.lz
[ $? = 2 ] || test_failed $LINENO
"${LZIP}" -atq copy2.lz
@@ -163,12 +188,15 @@ rm -f copy2
"${LZIP}" -atq < copy2.lz
[ $? = 2 ] || test_failed $LINENO
"${LZIP}" -adkq copy2.lz
-{ [ $? = 2 ] && [ ! -e copy2 ] ; } || test_failed $LINENO
+[ $? = 2 ] || test_failed $LINENO
+[ ! -e copy2 ] || test_failed $LINENO
"${LZIP}" -adkq -o copy2 < copy2.lz
-{ [ $? = 2 ] && [ ! -e copy2 ] ; } || test_failed $LINENO
+[ $? = 2 ] || test_failed $LINENO
+[ ! -e copy2 ] || test_failed $LINENO
printf "to be overwritten" > copy2 || framework_failure
"${LZIP}" -df copy2.lz || test_failed $LINENO
cmp in2 copy2 || test_failed $LINENO
+rm -f in2 copy2 || framework_failure
printf "\ntesting compression..."
@@ -204,24 +232,30 @@ for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
"${LZIP}" -df -o copy < out.lz || test_failed $LINENO $i
cmp in copy || test_failed $LINENO $i
done
+rm -f out.lz || framework_failure
cat in in in in > in4 || framework_failure
for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
+ "${LZIP}" -s4Ki -B8Ki -n$i < in4 > out4.lz || test_failed $LINENO $i
+ printf "g" >> out4.lz || framework_failure
+ "${LZIP}" -d -n$i < out4.lz > out4 || test_failed $LINENO $i
+ cmp in4 out4 || test_failed $LINENO $i
+ "${LZIP}" -d --in-slots=$i < out4.lz > out4 || test_failed $LINENO $i
+ cmp in4 out4 || test_failed $LINENO $i
+ "${LZIP}" -d --out-slots=$i < out4.lz > out4 || test_failed $LINENO $i
+ cmp in4 out4 || test_failed $LINENO $i
+
"${LZIP}" -c -s4Ki -B8Ki -n$i in4 > out4.lz || test_failed $LINENO $i
printf "g" >> out4.lz || framework_failure
- "${LZIP}" -cd -n$i out4.lz > copy4 || test_failed $LINENO $i
- cmp in4 copy4 || test_failed $LINENO $i
+ "${LZIP}" -cd -n$i out4.lz > out4 || test_failed $LINENO $i
+ cmp in4 out4 || test_failed $LINENO $i
+ "${LZIP}" -cd --out-slots=$i out4.lz > out4 || test_failed $LINENO $i
+ cmp in4 out4 || test_failed $LINENO $i
+ rm -f out4 || framework_failure
"${LZIP}" -d -n$i out4.lz || test_failed $LINENO $i
cmp in4 out4 || test_failed $LINENO $i
- rm -f out4
-done
-
-for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; do
- "${LZIP}" -s4Ki -B8Ki -n$i < in4 > out4 || test_failed $LINENO $i
- printf "g" >> out4 || framework_failure
- "${LZIP}" -d -n$i < out4 > copy4 || test_failed $LINENO $i
- cmp in4 copy4 || test_failed $LINENO $i
done
+rm -f out4 || framework_failure
cat in in in in in in in in | "${LZIP}" -1s4Ki | "${LZIP}" -t ||
test_failed $LINENO
@@ -230,58 +264,58 @@ printf "\ntesting bad input..."
headers='LZIp LZiP LZip LzIP LzIp LziP lZIP lZIp lZiP lzIP'
body='\001\014\000\203\377\373\377\377\300\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000$\000\000\000\000\000\000\000'
-cat "${in_lz}" > in0.lz
-printf "LZIP${body}" >> in0.lz
-if "${LZIP}" -tq in0.lz ; then
+cat "${in_lz}" > int.lz
+printf "LZIP${body}" >> int.lz
+if "${LZIP}" -tq int.lz ; then
for header in ${headers} ; do
- printf "${header}${body}" > in0.lz # first member
- "${LZIP}" -lq in0.lz
+ printf "${header}${body}" > int.lz # first member
+ "${LZIP}" -lq int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -tq in0.lz
+ "${LZIP}" -tq int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -tq < in0.lz
+ "${LZIP}" -tq < int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -cdq in0.lz > /dev/null
+ "${LZIP}" -cdq int.lz > /dev/null
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -lq --loose-trailing in0.lz
+ "${LZIP}" -lq --loose-trailing int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -tq --loose-trailing in0.lz
+ "${LZIP}" -tq --loose-trailing int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -tq --loose-trailing < in0.lz
+ "${LZIP}" -tq --loose-trailing < int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -cdq --loose-trailing in0.lz > /dev/null
+ "${LZIP}" -cdq --loose-trailing int.lz > /dev/null
[ $? = 2 ] || test_failed $LINENO ${header}
- cat "${in_lz}" > in0.lz
- printf "${header}${body}" >> in0.lz # trailing data
- "${LZIP}" -lq in0.lz
+ cat "${in_lz}" > int.lz
+ printf "${header}${body}" >> int.lz # trailing data
+ "${LZIP}" -lq int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -tq in0.lz
+ "${LZIP}" -tq int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
-# "${LZIP}" -tq < in0.lz # requires lzlib-1.10
-# [ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -cdq in0.lz > /dev/null
+ "${LZIP}" -tq < int.lz
+ [ $? = 2 ] || lzlib_1_10 # requires lzlib 1.10
+ "${LZIP}" -cdq int.lz > /dev/null
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -lq --loose-trailing in0.lz
- [ $? = 0 ] || test_failed $LINENO ${header}
- "${LZIP}" -t --loose-trailing in0.lz
- [ $? = 0 ] || test_failed $LINENO ${header}
- "${LZIP}" -t --loose-trailing < in0.lz
- [ $? = 0 ] || test_failed $LINENO ${header}
- "${LZIP}" -cd --loose-trailing in0.lz > /dev/null
- [ $? = 0 ] || test_failed $LINENO ${header}
- "${LZIP}" -lq --loose-trailing --trailing-error in0.lz
+ "${LZIP}" -lq --loose-trailing int.lz ||
+ test_failed $LINENO ${header}
+ "${LZIP}" -t --loose-trailing int.lz ||
+ test_failed $LINENO ${header}
+ "${LZIP}" -t --loose-trailing < int.lz ||
+ test_failed $LINENO ${header}
+ "${LZIP}" -cd --loose-trailing int.lz > /dev/null ||
+ test_failed $LINENO ${header}
+ "${LZIP}" -lq --loose-trailing --trailing-error int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -tq --loose-trailing --trailing-error in0.lz
+ "${LZIP}" -tq --loose-trailing --trailing-error int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -tq --loose-trailing --trailing-error < in0.lz
+ "${LZIP}" -tq --loose-trailing --trailing-error < int.lz
[ $? = 2 ] || test_failed $LINENO ${header}
- "${LZIP}" -cdq --loose-trailing --trailing-error in0.lz > /dev/null
+ "${LZIP}" -cdq --loose-trailing --trailing-error int.lz > /dev/null
[ $? = 2 ] || test_failed $LINENO ${header}
done
else
printf "\nwarning: skipping header test: 'printf' does not work on your system."
fi
-rm -f in0.lz
+rm -f int.lz || framework_failure
cat "${in_lz}" "${in_lz}" "${in_lz}" > in3.lz || framework_failure
if dd if=in3.lz of=trunc.lz bs=14752 count=1 2> /dev/null &&
@@ -293,16 +327,16 @@ if dd if=in3.lz of=trunc.lz bs=14752 count=1 2> /dev/null &&
"${LZIP}" -tq trunc.lz
[ $? = 2 ] || test_failed $LINENO $i
"${LZIP}" -tq < trunc.lz
- [ $? = 2 ] || test_failed $LINENO $i
+ [ $? = 2 ] || lzlib_1_8 # requires lzlib 1.8
"${LZIP}" -cdq trunc.lz > out
[ $? = 2 ] || test_failed $LINENO $i
"${LZIP}" -dq < trunc.lz > out
- [ $? = 2 ] || test_failed $LINENO $i
+ [ $? = 2 ] || lzlib_1_8 # requires lzlib 1.8
done
else
printf "\nwarning: skipping truncation test: 'dd' does not work on your system."
fi
-rm -f in3.lz trunc.lz
+rm -f in2.lz in3.lz trunc.lz out || framework_failure
cat "${in_lz}" > ingin.lz || framework_failure
printf "g" >> ingin.lz || framework_failure
@@ -316,7 +350,7 @@ cat "${in_lz}" >> ingin.lz || framework_failure
"${LZIP}" -t < ingin.lz || test_failed $LINENO
"${LZIP}" -d < ingin.lz > copy || test_failed $LINENO
cmp in copy || test_failed $LINENO
-rm -f ingin.lz
+rm -f copy ingin.lz || framework_failure
echo
if [ ${fail} = 0 ] ; then