diff options
Diffstat (limited to '')
-rwxr-xr-x | testsuite/check.sh | 97 | ||||
-rw-r--r-- | testsuite/fox6_mark.lz | bin | 0 -> 480 bytes | |||
-rw-r--r-- | testsuite/test_3m.txt.lz.md5 | 1 |
3 files changed, 78 insertions, 20 deletions
diff --git a/testsuite/check.sh b/testsuite/check.sh index af8d787..429ec95 100755 --- a/testsuite/check.sh +++ b/testsuite/check.sh @@ -1,14 +1,14 @@ #! /bin/sh # check script for Lziprecover - Data recovery tool for the lzip format -# Copyright (C) 2009-2022 Antonio Diaz Diaz. +# Copyright (C) 2009-2023 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` +objdir="`pwd`" +testdir="`cd "$1" ; pwd`" LZIP="${objdir}"/lziprecover LZIPRECOVER="${LZIP}" framework_failure() { echo "failure in testing framework" ; exit 1 ; } @@ -54,6 +54,7 @@ f6s3_lz="${testdir}"/fox6_sc3.lz f6s4_lz="${testdir}"/fox6_sc4.lz f6s5_lz="${testdir}"/fox6_sc5.lz f6s6_lz="${testdir}"/fox6_sc6.lz +f6ma_lz="${testdir}"/fox6_mark.lz num_lz="${testdir}"/numbers.lz nbt_lz="${testdir}"/numbersbt.lz fail=0 @@ -71,6 +72,9 @@ test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; } # test_bad8.lz: [ 66- 73] --> zeroed (reference test.txt [ 89- 110]) # test_bad9.lz: [6491-6498] --> zeroed (reference test.txt [17977-18120]) # +# test_em.txt.lz: test.txt split in 3, with 5 empty members (1,3,5-6,8) +# test_3m.txt.lz.md5: md5sum of test_em.txt.lz after removing empty members +# # 6-member files with one or more errors # fox6_bad1.lz: byte at offset 5 changed from 0x0C to 0x00 (DS) # byte at offset 142 changed from 0x50 to 0x70 (CRC) @@ -84,6 +88,8 @@ test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; } # fox6_bad5.lz: [380-479] --> zeroed (members 5,6) # fox6_bad6.lz: [430-439] --> zeroed (member 6) # +# fox6_mark.lz: 4 last members marked with bytes 'm', 'a', 'r', 'k' +# # 6-member files "shortcircuited" by a corrupt or fake trailer # fox6_sc1.lz: (corrupt but consistent last trailer) # last CRC != 0 ; dsize = 4 * msize ; msize = 480 (file size) @@ -101,6 +107,11 @@ test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; } printf "testing lziprecover-%s..." "$2" +"${LZIPRECOVER}" -q --nrep-stats=0N "${in_lz}" +[ $? = 1 ] || test_failed $LINENO +for i in 0 255 0kB 0KiB 0M 0G 0T 0P 0E 0Z 0Y 0R 0Q ; do + "${LZIPRECOVER}" -q --nrep-stats=$i "${in_lz}" || test_failed $LINENO $i +done "${LZIP}" -lq in [ $? = 2 ] || test_failed $LINENO "${LZIP}" -tq in @@ -175,6 +186,8 @@ printf "LZIP\001+.............................." | "${LZIP}" -t 2> /dev/null [ $? = 2 ] || test_failed $LINENO "${LZIPRECOVER}" -q --dump=damagedd "${in_lz}" > /dev/null [ $? = 1 ] || test_failed $LINENO +"${LZIPRECOVER}" -q --dump=empty +[ $? = 1 ] || test_failed $LINENO "${LZIPRECOVER}" -q --strip=damaged [ $? = 1 ] || test_failed $LINENO "${LZIPRECOVER}" -q --strip=damaged in > /dev/null @@ -264,11 +277,15 @@ for i in "${in_lz}" "${in_em}" ; do rm -f copy || framework_failure done -lines=$("${LZIP}" -tvv "${in_em}" 2>&1 | wc -l) || test_failed $LINENO +lines="`"${LZIP}" -tvv "${in_em}" 2>&1 | wc -l`" || test_failed $LINENO [ "${lines}" -eq 8 ] || test_failed $LINENO "${lines}" +"${LZIP}" -tq "${in_em}" --empty-error +[ $? = 2 ] || test_failed $LINENO -lines=$("${LZIP}" -lvv "${in_em}" | wc -l) || test_failed $LINENO +lines="`"${LZIP}" -lvv "${in_em}" | wc -l`" || test_failed $LINENO [ "${lines}" -eq 11 ] || test_failed $LINENO "${lines}" +"${LZIP}" -lq "${in_em}" --empty-error +[ $? = 2 ] || test_failed $LINENO "${LZIP}" -cd "${fox_lz}" > fox || test_failed $LINENO cat "${in_lz}" > copy.lz || framework_failure @@ -377,17 +394,37 @@ cmp in copy || test_failed $LINENO cmp "${inD}" copy || test_failed $LINENO "${LZIPRECOVER}" -D 21723,397 "${in_lz}" > copy || test_failed $LINENO cmp "${inD}" copy || test_failed $LINENO +"${LZIPRECOVER}" -D 21723,397 "${in_em}" > copy || test_failed $LINENO +cmp "${inD}" copy || test_failed $LINENO +"${LZIPRECOVER}" -q -D 21723,397 --empty-error "${in_em}" +[ $? = 2 ] || test_failed $LINENO + +"${LZIP}" -cd "${fox6_lz}" > out || test_failed $LINENO +"${LZIP}" -cd "${f6ma_lz}" > copy || test_failed $LINENO +cmp out copy || test_failed $LINENO +rm -f out copy || framework_failure +cat "${f6ma_lz}" > f6ma.lz || framework_failure +cat "${f6ma_lz}" > f6ma2.lz || framework_failure +cmp -s "${fox6_lz}" f6ma.lz && test_failed $LINENO +"${LZIPRECOVER}" --clear-marking f6ma.lz f6ma2.lz || test_failed $LINENO +cmp "${fox6_lz}" f6ma.lz || test_failed $LINENO +cmp "${fox6_lz}" f6ma2.lz || test_failed $LINENO +rm -f f6ma.lz f6ma2.lz || framework_failure +"${LZIP}" -lq "${f6ma_lz}" --marking-error +[ $? = 2 ] || test_failed $LINENO +"${LZIP}" -tq "${f6ma_lz}" --marking-error +[ $? = 2 ] || test_failed $LINENO 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}" > int.lz -printf "LZIP${body}" >> int.lz +cat "${in_lz}" > int.lz || framework_failure +printf "LZIP${body}" >> int.lz || framework_failure if "${LZIP}" -tq int.lz ; then for header in ${headers} ; do - printf "${header}${body}" > int.lz # first member - "${LZIP}" -lq int.lz + printf "${header}${body}" > int.lz || framework_failure + "${LZIP}" -lq int.lz # first member [ $? = 2 ] || test_failed $LINENO ${header} "${LZIP}" -tq int.lz [ $? = 2 ] || test_failed $LINENO ${header} @@ -403,9 +440,9 @@ if "${LZIP}" -tq int.lz ; then [ $? = 2 ] || test_failed $LINENO ${header} "${LZIP}" -cdq --loose-trailing int.lz > /dev/null [ $? = 2 ] || test_failed $LINENO ${header} - cat "${in_lz}" > int.lz - printf "${header}${body}" >> int.lz # trailing data - "${LZIP}" -lq int.lz + cat "${in_lz}" > int.lz || framework_failure + printf "${header}${body}" >> int.lz || framework_failure + "${LZIP}" -lq int.lz # trailing data [ $? = 2 ] || test_failed $LINENO ${header} "${LZIP}" -tq int.lz [ $? = 2 ] || test_failed $LINENO ${header} @@ -487,11 +524,11 @@ fi rm -f in3.lz trunc.lz out || framework_failure for i in "${f6s1_lz}" "${f6s2_lz}" ; do - lines=`"${LZIP}" -lvv "$i" | wc -l || test_failed $LINENO "$i"` + lines="`"${LZIP}" -lvv "$i" | wc -l || test_failed $LINENO "$i"`" [ "${lines}" -eq 2 ] || test_failed $LINENO "$i ${lines}" done for i in "${f6s3_lz}" "${f6s4_lz}" "${f6s5_lz}" "${f6s6_lz}" ; do - lines=`"${LZIP}" -lvv "$i" | wc -l || test_failed $LINENO "$i"` + lines="`"${LZIP}" -lvv "$i" | wc -l || test_failed $LINENO "$i"`" [ "${lines}" -eq 9 ] || test_failed $LINENO "$i ${lines}" done @@ -698,7 +735,7 @@ cmp out4.lz copy4.lz || test_failed $LINENO cmp out4.lz copy4.lz || test_failed $LINENO rm -f bad345.lz bad453.lz bad534.lz out4.lz copy4.lz || framework_failure -printf "\ntesting --repair..." +printf "\ntesting --byte-repair..." rm -f copy.lz || framework_failure "${LZIPRECOVER}" -R -o copy.lz "${fox6_lz}" || test_failed $LINENO @@ -1022,7 +1059,8 @@ cat "${f6b2_lz}" in > f6bt.lz || framework_failure "${LZIPRECOVER}" --dump=damaged f6bt.lz > copy || test_failed $LINENO cat "${fox_lz}" copy "${fox_lz}" "${fox_lz}" "${fox_lz}" \ "${fox_lz}" | cmp "${f6b2_lz}" - || test_failed $LINENO -cat "${fox_lz}" "${fox_lz}" "${fox_lz}" "${fox_lz}" "${fox_lz}" > fox5.lz +cat "${fox_lz}" "${fox_lz}" "${fox_lz}" "${fox_lz}" "${fox_lz}" > fox5.lz || + framework_failure "${LZIPRECOVER}" --strip=damaged "${f6b2_lz}" > copy || test_failed $LINENO cmp fox5.lz copy || test_failed $LINENO "${LZIPRECOVER}" --strip=damaged f6bt.lz > copy || test_failed $LINENO @@ -1041,7 +1079,7 @@ cat "${f6b3_lz}" in > f6bt.lz || framework_failure "${LZIPRECOVER}" --dump=damaged f6bt.lz > copy || test_failed $LINENO cat "${fox_lz}" "${fox_lz}" copy "${fox_lz}" | cmp "${f6b3_lz}" - || test_failed $LINENO -cat "${fox_lz}" "${fox_lz}" "${fox_lz}" > fox3.lz +cat "${fox_lz}" "${fox_lz}" "${fox_lz}" > fox3.lz || framework_failure "${LZIPRECOVER}" --strip=damaged "${f6b3_lz}" > copy || test_failed $LINENO cmp fox3.lz copy || test_failed $LINENO "${LZIPRECOVER}" --strip=damaged f6bt.lz > copy || test_failed $LINENO @@ -1053,7 +1091,8 @@ cmp fox3.lz f6b.lz || test_failed $LINENO cat fox3.lz in | cmp f6bt.lz - || test_failed $LINENO rm -f f6b.lz f6bt.lz fox3.lz || framework_failure -cat "${fox_lz}" "${fox_lz}" "${fox_lz}" "${fox_lz}" > fox4.lz +cat "${fox_lz}" "${fox_lz}" "${fox_lz}" "${fox_lz}" > fox4.lz || + framework_failure for i in "${f6b4_lz}" "${f6b5_lz}" ; do "${LZIPRECOVER}" --dump=damaged "$i" > copy || test_failed $LINENO "$i" cat fox4.lz copy | cmp "$i" - || test_failed $LINENO "$i" @@ -1427,7 +1466,7 @@ cmp "${num_lz}" nbt.lz || test_failed $LINENO cat "${nbt_lz}" > nbt.lz || framework_failure "${LZIPRECOVER}" --remove=damaged:tdata nbt.lz || test_failed $LINENO cmp "${num_lz}" nbt.lz || test_failed $LINENO -rm -f rec*num.lz nbt.lz empty || framework_failure +rm -f rec*num.lz nbt.lz || framework_failure for i in 1 2 3 4 5 6 7 8 9 10 ; do "${LZIPRECOVER}" -i --strip=1-$i "${nbt_lz}" > out || @@ -1436,7 +1475,25 @@ for i in 1 2 3 4 5 6 7 8 9 10 ; do "${LZIPRECOVER}" -i --remove=1-$i nbt.lz || test_failed $LINENO $i cmp nbt.lz out || test_failed $LINENO $i done -rm -f nbt.lz out || framework_failure +rm -f nbt.lz || framework_failure + +cat "${in_em}" > test_3m.txt.lz || framework_failure +"${LZIPRECOVER}" --remove=empty test_3m.txt.lz || test_failed $LINENO +"${LZIPRECOVER}" -M test_3m.txt.lz | cmp "${testdir}"/test_3m.txt.lz.md5 - || + test_failed $LINENO +"${LZIPRECOVER}" --dump=2,4,7 "${in_em}" | cmp test_3m.txt.lz - || + test_failed $LINENO +"${LZIPRECOVER}" --strip=e "${in_em}" | cmp test_3m.txt.lz - || + test_failed $LINENO +"${LZIPRECOVER}" --empty-error --strip=e "${in_em}" | cmp test_3m.txt.lz - || + test_failed $LINENO +"${LZIPRECOVER}" --strip=1,3,5-6,8 "${in_em}" | cmp test_3m.txt.lz - || + test_failed $LINENO +"${LZIPRECOVER}" -q --strip=1,3,5-6,8 --empty-error "${in_em}" > out +[ $? = 2 ] || test_failed $LINENO +"${LZIPRECOVER}" --dump=emp "${in_em}" | "${LZIP}" -d | cmp empty - || + test_failed $LINENO +rm -f test_3m.txt.lz empty out || framework_failure echo if [ ${fail} = 0 ] ; then diff --git a/testsuite/fox6_mark.lz b/testsuite/fox6_mark.lz Binary files differnew file mode 100644 index 0000000..32b2ac0 --- /dev/null +++ b/testsuite/fox6_mark.lz diff --git a/testsuite/test_3m.txt.lz.md5 b/testsuite/test_3m.txt.lz.md5 new file mode 100644 index 0000000..5bec6bc --- /dev/null +++ b/testsuite/test_3m.txt.lz.md5 @@ -0,0 +1 @@ +6a6bb58464ec8567eab17015064d0c5b test_3m.txt.lz |