Skip to content

Commit

Permalink
support reloading broken files with IlmImfFuzzTest
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman authored and cary-ilm committed Feb 20, 2020
1 parent d129fae commit 608b493
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 38 deletions.
2 changes: 1 addition & 1 deletion OpenEXR/IlmImfFuzzTest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <sstream>
#endif

#define TEST(x) if (argc < 2 || !strcmp (argv[1], #x)) x();
#define TEST(x) if (argc < 2 || !strcmp (argv[1], #x)) x(argc==3 ? argv[2] : nullptr);

int
main (int argc, char *argv[])
Expand Down
24 changes: 16 additions & 8 deletions OpenEXR/IlmImfFuzzTest/testFuzzDeepScanLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,21 +408,29 @@ fuzzDeepScanLines (int numThreads, Rand48 &random)


void
testFuzzDeepScanLines ()
testFuzzDeepScanLines (const char* file)
{
try
{
cout << "Testing deep scanline-based files "
"with randomly inserted errors" << endl;
if(file)
{
readFile(file);
}
else
{

Rand48 random (1);
cout << "Testing deep scanline-based files "
"with randomly inserted errors" << endl;

fuzzDeepScanLines (0, random);
Rand48 random (1);

if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzDeepScanLines (2, random);
fuzzDeepScanLines (0, random);

cout << "ok\n" << endl;
if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzDeepScanLines (2, random);

cout << "ok\n" << endl;
}
}
catch (const std::exception &e)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImfFuzzTest/testFuzzDeepScanLines.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@



void testFuzzDeepScanLines ();
void testFuzzDeepScanLines (const char* file);

25 changes: 16 additions & 9 deletions OpenEXR/IlmImfFuzzTest/testFuzzDeepTiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void generateRandomFile(const char filename[], int channelCount, int parts , Com
{
for(int x=0;x<data[k].width();x++)
{
delete reinterpret_cast<char *>( data[k][y][x] );
delete [] reinterpret_cast<char *>( data[k][y][x] );
data[k][y][x]=0;
}
}
Expand Down Expand Up @@ -503,23 +503,30 @@ fuzzDeepTiles (int numThreads, Rand48 &random)


void
testFuzzDeepTiles ()
testFuzzDeepTiles (const char* file)
{


try
{
cout << "Testing deep tile-based files "
"with randomly inserted errors" << endl;
if(file)
{
readFile(file);
}
else
{
cout << "Testing deep tile-based files "
"with randomly inserted errors" << endl;

Rand48 random (1);
Rand48 random (1);

fuzzDeepTiles (0, random);
fuzzDeepTiles (0, random);

if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzDeepTiles (2, random);
if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzDeepTiles (2, random);

cout << "ok\n" << endl;
cout << "ok\n" << endl;
}
}
catch (const std::exception &e)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImfFuzzTest/testFuzzDeepTiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@



void testFuzzDeepTiles ();
void testFuzzDeepTiles (const char* file);

23 changes: 15 additions & 8 deletions OpenEXR/IlmImfFuzzTest/testFuzzScanLines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,21 +252,28 @@ fuzzScanLines (int numThreads, Rand48 &random)


void
testFuzzScanLines ()
testFuzzScanLines (const char* file)
{
try
{
cout << "Testing scanline-based files "
"with randomly inserted errors" << endl;
if(file)
{
readImage(file);
}
else
{
cout << "Testing scanline-based files "
"with randomly inserted errors" << endl;

Rand48 random (1);
Rand48 random (1);

fuzzScanLines (0, random);
fuzzScanLines (0, random);

if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzScanLines (2, random);
if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzScanLines (2, random);

cout << "ok\n" << endl;
cout << "ok\n" << endl;
}
}
catch (const std::exception &e)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImfFuzzTest/testFuzzScanLines.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@



void testFuzzScanLines ();
void testFuzzScanLines (const char* file);

25 changes: 17 additions & 8 deletions OpenEXR/IlmImfFuzzTest/testFuzzTiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,21 +406,30 @@ fuzzTiles (int numThreads, Rand48 &random)


void
testFuzzTiles ()
testFuzzTiles (const char* file)
{
try
{
cout << "Testing tile-based files "
"with randomly inserted errors" << endl;
if(file)
{
readImageONE(file);
readImageMIP(file);
readImageRIP(file);
}
else
{
cout << "Testing tile-based files "
"with randomly inserted errors" << endl;

Rand48 random (5);
Rand48 random (5);

fuzzTiles (0, random);
fuzzTiles (0, random);

if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzTiles (2, random);
if (ILMTHREAD_NAMESPACE::supportsThreads())
fuzzTiles (2, random);

cout << "ok\n" << endl;
cout << "ok\n" << endl;
}
}
catch (const std::exception &e)
{
Expand Down
2 changes: 1 addition & 1 deletion OpenEXR/IlmImfFuzzTest/testFuzzTiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@



void testFuzzTiles ();
void testFuzzTiles (const char* file);

0 comments on commit 608b493

Please sign in to comment.