From 04d72dd06c3c49fcc61e5ae7b8cee112d34e8df1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 7 Nov 2015 12:42:39 +0100 Subject: Merging upstream version 1.15~rc1. Signed-off-by: Daniel Baumann --- testsuite/check.sh | 34 ++++++++++++++++++++++------------ testsuite/unzcrash.cc | 28 ++++++++++++++++++---------- 2 files changed, 40 insertions(+), 22 deletions(-) (limited to 'testsuite') diff --git a/testsuite/check.sh b/testsuite/check.sh index 4ac7f59..314c19e 100755 --- a/testsuite/check.sh +++ b/testsuite/check.sh @@ -1,5 +1,5 @@ #! /bin/sh -# check script for Lziprecover - Data recovery tool for lzipped files +# check script for Lziprecover - Data recovery tool for lzip files # Copyright (C) 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz. # # This script is free software: you have unlimited permission @@ -10,7 +10,7 @@ export LC_ALL objdir=`pwd` testdir=`cd "$1" ; pwd` LZIP="${objdir}"/lziprecover -LZIPRECOVER="${objdir}"/lziprecover +LZIPRECOVER="${LZIP}" framework_failure() { echo "failure in testing framework" ; exit 1 ; } if [ ! -x "${LZIP}" ] ; then @@ -65,9 +65,21 @@ if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi "${LZIPRECOVER}" -sq if [ $? = 1 ] ; then printf . ; else fail=1 ; printf - ; fi - -"${LZIP}" -t "${testdir}"/test.txt.lz || fail=1 -"${LZIP}" -cd "${testdir}"/test.txt.lz > copy || fail=1 +"${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 +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 + +"${LZIP}" -t "${in_lz}" || fail=1 +"${LZIP}" -cd "${in_lz}" > copy || fail=1 cmp "${in}" copy || fail=1 printf . @@ -100,8 +112,8 @@ for i in "${f5b1_lz}" "${f5b3_lz}" "${f5b4_lz}" "${f5b5_lz}" ; do cmp "${fox5_lz}" copy.lz || fail=1 "${LZIPRECOVER}" -mf -o copy.lz "${i}" "${f5b2_lz}" || fail=1 cmp "${fox5_lz}" copy.lz || fail=1 - printf . done +printf . for i in "${f5b3_lz}" "${f5b4_lz}" "${f5b5_lz}" ; do "${LZIPRECOVER}" -mf -o copy.lz "${f5b1_lz}" "${f5b2_lz}" "${i}" || fail=1 @@ -116,8 +128,8 @@ for i in "${f5b3_lz}" "${f5b4_lz}" "${f5b5_lz}" ; do cmp "${fox5_lz}" copy.lz || fail=1 "${LZIPRECOVER}" -mf -o copy.lz "${i}" "${f5b2_lz}" "${f5b1_lz}" || fail=1 cmp "${fox5_lz}" copy.lz || fail=1 - printf . done +printf . "${LZIPRECOVER}" -mf -o copy.lz "${f5b3_lz}" "${f5b4_lz}" "${f5b5_lz}" || fail=1 cmp "${fox5_lz}" copy.lz || fail=1 @@ -141,9 +153,9 @@ for i in "${bad1_lz}" "${bad2_lz}" ; do cmp "${in_lz}" copy.lz || fail=1 "${LZIPRECOVER}" -mf -o copy.lz "${j}" "${i}" || fail=1 cmp "${in_lz}" copy.lz || fail=1 - printf . done done +printf . "${LZIPRECOVER}" -mf -o copy.lz "${bad3_lz}" "${bad4_lz}" "${bad5_lz}" || fail=1 cmp "${in_lz}" copy.lz || fail=1 @@ -171,7 +183,6 @@ if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi if [ $? = 2 ] && [ ! -e copy.lz ] ; then printf . ; else fail=1 ; printf - ; fi "${LZIPRECOVER}" -Rf -o copy.lz "${f5b1_lz}" || fail=1 cmp "${fox5_lz}" copy.lz || fail=1 -printf . "${LZIPRECOVER}" -Rf -o copy.lz "${bad1_lz}" || fail=1 cmp "${in_lz}" copy.lz || fail=1 printf . @@ -182,8 +193,8 @@ printf "garbage" >> copy || fail=1 for i in 1 2 3 ; do "${LZIPRECOVER}" -cd rec${i}copy.lz > copy || fail=1 cmp "${in}" copy || fail=1 - printf . done +printf . cat "${in_lz}" > anyothername || framework_failure "${LZIP}" -d anyothername || fail=1 @@ -191,8 +202,7 @@ cmp "${in}" anyothername.out || fail=1 printf . cat "${in}" "${in}" > in2 || framework_failure -cat "${in_lz}" "${in_lz}" > out2 || framework_failure -"${LZIP}" -d < out2 > copy2 || fail=1 +cat "${in_lz}" "${in_lz}" | "${LZIP}" -d > copy2 || fail=1 cmp in2 copy2 || fail=1 printf . diff --git a/testsuite/unzcrash.cc b/testsuite/unzcrash.cc index 24defa6..b2cdc4e 100644 --- a/testsuite/unzcrash.cc +++ b/testsuite/unzcrash.cc @@ -1,5 +1,4 @@ -/* Unzcrash - A test program written to test robustness to - decompression of corrupted data. +/* Unzcrash - Tests robustness of decompressors to corrupted data. Inspired by unzcrash.c from Julian Seward's bzip2. Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Antonio Diaz Diaz. @@ -16,6 +15,12 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +/* + Exit status: 0 for a normal exit, 1 for environmental problems + (file not found, invalid flags, I/O errors, etc), 2 to indicate a + corrupt or invalid input file, 3 for an internal consistency error + (eg, bug) which caused unzcrash to panic. +*/ #include #include @@ -47,9 +52,8 @@ int verbosity = 0; void show_help() { - std::printf( "%s - A test program written to test robustness to\n", Program_name ); - std::printf( "decompression of corrupted data.\n" - "\nUsage: %s [options] \"lzip -tv\" filename.lz\n", invocation_name ); + std::printf( "%s - Tests robustness of decompressors to corrupted data.\n", Program_name ); + std::printf( "\nUsage: %s [options] \"lzip -tv\" filename.lz\n", invocation_name ); std::printf( "\nThis program reads the specified file and then repeatedly decompresses\n" "it, increasing 256 times each byte of the compressed data, so as to test\n" "all possible one-byte errors. This should not cause any invalid memory\n" @@ -63,8 +67,12 @@ void show_help() " -s, --size= number of byte positions to test [all]\n" " -v, --verbose be verbose (a 2nd -v gives more)\n" "Examples of : 1 1,2,3 1-4 1,3-5,8 1-3,5-8\n" + "\nExit status: 0 for a normal exit, 1 for environmental problems (file\n" + "not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or\n" + "invalid input file, 3 for an internal consistency error (eg, bug) which\n" + "caused unzcrash to panic.\n" "\nReport bugs to lzip-bug@nongnu.org\n" - "Lzip home page: http://www.nongnu.org/lzip/lzip.html\n" ); + "Lziprecover home page: http://www.nongnu.org/lzip/lziprecover.html\n" ); } @@ -160,7 +168,7 @@ unsigned long long getnum( const char * const ptr, } -class Bitset8 // 8 value bitset (1..8) +class Bitset8 // 8 value bitset (1 to 8) { bool data[8]; static bool valid_digit( const unsigned char ch ) @@ -195,7 +203,7 @@ public: return false; } - // number of n-bit errors per byte (n=0..8): 1 8 28 56 70 56 28 8 1 + // number of N-bit errors per byte (N=0 to 8): 1 8 28 56 70 56 28 8 1 void print() const { std::fflush( stderr ); @@ -295,9 +303,9 @@ int main( const int argc, const char * const argv[] ) if( size >= buffer_size ) { if( verbosity >= 0 ) - std::fprintf( stderr, "input file '%s' is too big.\n", + std::fprintf( stderr, "input file '%s' is too large.\n", parser.argument( argind + 1 ).c_str() ); - return 1; + return 2; } std::fclose( f ); -- cgit v1.2.3