summaryrefslogtreecommitdiffstats
path: root/testsuite
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:50:02 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-07 11:50:02 +0000
commit018cead199f4ee24f0286cbd033355eae7f8fdae (patch)
treef0a935bac9c716aa3eed352755efa62e1b2b8206 /testsuite
parentAdding debian version 1.16-2. (diff)
downloadlziprecover-018cead199f4ee24f0286cbd033355eae7f8fdae.tar.xz
lziprecover-018cead199f4ee24f0286cbd033355eae7f8fdae.zip
Merging upstream version 1.17~pre1.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rwxr-xr-xtestsuite/check.sh48
-rw-r--r--testsuite/test_bad1.lzbin7376 -> 7376 bytes
-rw-r--r--unzcrash.cc (renamed from testsuite/unzcrash.cc)21
3 files changed, 59 insertions, 10 deletions
diff --git a/testsuite/check.sh b/testsuite/check.sh
index e2cad6f..ef60713 100755
--- a/testsuite/check.sh
+++ b/testsuite/check.sh
@@ -49,7 +49,7 @@ fail=0
# fox5_bad3.lz: [100-299] --> zeroed;
# fox5_bad4.lz: [250-349] --> zeroed;
# fox5_bad5.lz: [300-399] --> zeroed;
-# test_bad1.lz: byte at offset 67 changed from 0x70 to 0x79
+# test_bad1.lz: byte at offset 66 changed from 0xA6 to 0x46
# test_bad2.lz: [ 34- 65] --> copy of bytes [ 68- 99]
# test_bad3.lz: [ 512-1535] --> zeroed; [2560-3583] --> zeroed
# test_bad4.lz: [3072-4095] --> random data; [4608-5631] --> zeroed
@@ -180,6 +180,24 @@ cmp "${in_lz}" copy.lz || fail=1
cmp "${in_lz}" copy.lz || fail=1
printf .
+cat "${bad1_lz}" "${in_lz}" "${bad1_lz}" "${bad1_lz}" > bad11.lz || framework_failure
+cat "${bad1_lz}" "${in_lz}" "${bad2_lz}" "${in_lz}" > bad12.lz || framework_failure
+cat "${bad2_lz}" "${in_lz}" "${bad2_lz}" "${bad2_lz}" > bad22.lz || framework_failure
+cat "${in_lz}" "${in_lz}" "${in_lz}" "${in_lz}" > copy4.lz || framework_failure
+"${LZIPRECOVER}" -mf -o out4.lz bad11.lz bad12.lz bad22.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad11.lz bad22.lz bad12.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad12.lz bad11.lz bad22.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad12.lz bad22.lz bad11.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad22.lz bad11.lz bad12.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad22.lz bad12.lz bad11.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+printf .
+
for i in "${bad1_lz}" "${bad2_lz}" ; do
for j in "${bad3_lz}" "${bad4_lz}" "${bad5_lz}" ; do
"${LZIPRECOVER}" -mf -o copy.lz "${i}" "${j}" || fail=1
@@ -209,6 +227,24 @@ printf .
cmp "${in_lz}" copy.lz || fail=1
printf .
+cat "${bad3_lz}" "${bad4_lz}" "${bad5_lz}" "${in_lz}" > bad345.lz || framework_failure
+cat "${bad4_lz}" "${bad5_lz}" "${bad3_lz}" "${in_lz}" > bad453.lz || framework_failure
+cat "${bad5_lz}" "${bad3_lz}" "${bad4_lz}" "${in_lz}" > bad534.lz || framework_failure
+cat "${in_lz}" "${in_lz}" "${in_lz}" "${in_lz}" > copy4.lz || framework_failure
+"${LZIPRECOVER}" -mf -o out4.lz bad345.lz bad453.lz bad534.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad345.lz bad534.lz bad453.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad453.lz bad345.lz bad534.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad453.lz bad534.lz bad345.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad534.lz bad345.lz bad453.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+"${LZIPRECOVER}" -mf -o out4.lz bad534.lz bad453.lz bad345.lz || fail=1
+cmp out4.lz copy4.lz || fail=1
+printf .
+
rm -f copy.lz
"${LZIPRECOVER}" -R -o copy.lz "${fox5_lz}" || fail=1
if [ $? = 0 ] && [ ! -e copy.lz ] ; then printf . ; else printf - ; fail=1 ; fi
@@ -220,6 +256,16 @@ cmp "${fox5_lz}" copy.lz || fail=1
cmp "${in_lz}" copy.lz || fail=1
printf .
+cat "${f5b1_lz}" > copy.tar.lz || framework_failure
+"${LZIPRECOVER}" -R copy.tar.lz || fail=1
+if [ $? = 0 ] && [ -e copy_fixed.tar.lz ] ; then printf . ; else printf - ; fail=1 ; fi
+mv copy.tar.lz copy.lz || framework_failure
+"${LZIPRECOVER}" -R copy.lz || fail=1
+if [ $? = 0 ] && [ -e copy_fixed.lz ] ; then printf . ; else printf - ; fail=1 ; fi
+mv copy.lz copy.tlz || framework_failure
+"${LZIPRECOVER}" -R copy.tlz || fail=1
+if [ $? = 0 ] && [ -e copy_fixed.tlz ] ; then printf . ; else printf - ; fail=1 ; fi
+
cat "${in_lz}" "${in_lz}" "${in_lz}" > copy || framework_failure
printf "garbage" >> copy || fail=1
"${LZIPRECOVER}" -s -o copy.lz copy || fail=1
diff --git a/testsuite/test_bad1.lz b/testsuite/test_bad1.lz
index 5f36fb7..d63dcbf 100644
--- a/testsuite/test_bad1.lz
+++ b/testsuite/test_bad1.lz
Binary files differ
diff --git a/testsuite/unzcrash.cc b/unzcrash.cc
index 470727d..0b44997 100644
--- a/testsuite/unzcrash.cc
+++ b/unzcrash.cc
@@ -33,7 +33,7 @@
#include <stdint.h>
#include <unistd.h>
-#include "../arg_parser.h"
+#include "arg_parser.h"
#if CHAR_BIT != 8
#error "Environments where CHAR_BIT != 8 are not supported."
@@ -209,18 +209,18 @@ public:
std::fflush( stderr );
int c = 0;
for( int i = 0; i < 8; ++i ) if( data[i] ) ++c;
- if( c == 8 ) std::printf( "Testing full byte.\n" );
- else if( c == 0 ) std::printf( "Nothing to test.\n" );
+ if( c == 8 ) std::fputs( "Testing full byte.\n", stdout );
+ else if( c == 0 ) std::fputs( "Nothing to test.\n", stdout );
else
{
- std::printf( "Testing " );
+ std::fputs( "Testing ", stdout );
for( int i = 0; i < 8; ++i )
if( data[i] )
{
std::printf( "%d", i + 1 );
- if( --c ) std::printf( "," );
+ if( --c ) std::fputs( ",", stdout );
}
- std::printf( " bit errors.\n" );
+ std::fputs( " bit errors.\n", stdout );
}
std::fflush( stdout );
}
@@ -241,7 +241,7 @@ int differing_bits( const uint8_t byte1, const uint8_t byte2 )
int main( const int argc, const char * const argv[] )
{
- enum { buffer_size = 3 << 20 };
+ enum { buffer_size = 75 << 20 };
Bitset8 bits; // if Bitset8::parse not called test full byte
int pos = 0;
int max_size = buffer_size;
@@ -330,18 +330,21 @@ int main( const int argc, const char * const argv[] )
if( verbosity >= 0 )
std::fprintf( stderr, "byte %d\n", i );
const uint8_t byte = buffer[i];
- for( int j = 0; j < 255; ++j )
+ for( int j = 1; j < 256; ++j )
{
++buffer[i];
if( bits.includes( differing_bits( byte, buffer[i] ) ) )
{
+ if( verbosity >= 2 )
+ std::fprintf( stderr, "0x%02X (0x%02X+0x%02X) ",
+ buffer[i], byte, j );
f = popen( parser.argument( argind ).c_str(), "w" );
if( !f )
{ show_error( "Can't open pipe", errno ); return 1; }
std::fwrite( buffer, 1, size, f );
if( pclose( f ) == 0 && verbosity >= 0 )
std::fprintf( stderr, "0x%02X (0x%02X+0x%02X) passed the test\n",
- buffer[i], byte, j + 1 );
+ buffer[i], byte, j );
}
}
buffer[i] = byte;