Changed TestOS_RNG to use a MeterFilter rather than an ArraySink with a NULL array. The NULL array meant ArraySink::Put2 returned early, and it did *not* update m_total. Even if Put2 did not exit early, it still could not update m_total because the bytes were *not* processed. This change was required in preparation for clearing UBsan errors in filters.cpp

pull/35/head
Jeffrey Walton 2015-07-19 07:15:06 -04:00
parent 8c259ee6b4
commit 1026b51922
1 changed files with 21 additions and 21 deletions

View File

@ -282,8 +282,8 @@ bool TestOS_RNG()
{
cout << "\nTesting operating system provided blocking random number generator...\n\n";
ArraySink *sink;
RandomNumberSource test(*rng, UINT_MAX, false, new Deflator(sink=new ArraySink(NULL,0)));
MeterFilter meter;
RandomNumberSource test(*rng, UINT_MAX, false, new Deflator(new Redirector(meter)));
unsigned long total=0, length=0;
time_t t = time(NULL), t1 = 0;
@ -338,14 +338,14 @@ bool TestOS_RNG()
test.AttachedTransformation()->MessageEnd();
if (sink->TotalPutLength() < total)
if (meter.GetTotalBytes() < total)
{
cout << "FAILED:";
pass = false;
}
else
cout << "passed:";
cout << " " << total << " generated bytes compressed to " << (size_t)sink->TotalPutLength() << " bytes by DEFLATE" << endl;
cout << " " << total << " generated bytes compressed to " << (size_t)meter.GetTotalBytes() << " bytes by DEFLATE" << endl;
}
else
cout << "\nNo operating system provided blocking random number generator, skipping test." << endl;
@ -360,17 +360,17 @@ bool TestOS_RNG()
{
cout << "\nTesting operating system provided nonblocking random number generator...\n\n";
ArraySink *sink;
RandomNumberSource test(*rng, 100000, true, new Deflator(sink=new ArraySink(NULL, 0)));
MeterFilter meter;
RandomNumberSource test(*rng, 100000, true, new Deflator(new Redirector(meter)));
if (sink->TotalPutLength() < 100000)
if (meter.GetTotalBytes() < 100000)
{
cout << "FAILED:";
pass = false;
}
else
cout << "passed:";
cout << " 100000 generated bytes compressed to " << (size_t)sink->TotalPutLength() << " bytes by DEFLATE" << endl;
cout << " 100000 generated bytes compressed to " << (size_t)meter.GetTotalBytes() << " bytes by DEFLATE" << endl;
}
else
cout << "\nNo operating system provided nonblocking random number generator, skipping test." << endl;