summaryrefslogtreecommitdiffstats
path: root/unzcrash.cc
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--unzcrash.cc (renamed from testsuite/unzcrash.cc)21
1 files changed, 12 insertions, 9 deletions
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;