Add diagnostic output to tst_QtConcurrentIterateKernel.
Add messages to comparisons and expect failure of blockSize() on Windows. Task-number: QTBUG-37822 Change-Id: Ie71d35a3d1ba0e52c93d5ba3fd7e92465b170d49 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
This commit is contained in:
parent
e215aba4aa
commit
7d012552b0
@ -151,7 +151,9 @@ void tst_QtConcurrentIterateKernel::cancel()
|
||||
f.cancel();
|
||||
f.waitForFinished();
|
||||
QVERIFY(f.isCanceled());
|
||||
QVERIFY(iterations.load() <= QThread::idealThreadCount()); // the threads might run one iteration each before they are canceled.
|
||||
// the threads might run one iteration each before they are canceled.
|
||||
QVERIFY2(iterations.load() <= QThread::idealThreadCount(),
|
||||
(QByteArray::number(iterations.load()) + ' ' + QByteArray::number(QThread::idealThreadCount())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -251,26 +253,48 @@ void tst_QtConcurrentIterateKernel::throttling()
|
||||
QCOMPARE(threads.count(), 1);
|
||||
}
|
||||
|
||||
|
||||
int peakBlockSize = 0;
|
||||
class BlockSizeRecorder : public IterateKernel<TestIterator, void>
|
||||
{
|
||||
public:
|
||||
BlockSizeRecorder(TestIterator begin, TestIterator end) : IterateKernel<TestIterator, void>(begin, end) { }
|
||||
BlockSizeRecorder(TestIterator begin, TestIterator end)
|
||||
: IterateKernel<TestIterator, void>(begin, end)
|
||||
, peakBlockSize(0)
|
||||
, peakBegin(0)
|
||||
{}
|
||||
|
||||
inline bool runIterations(TestIterator, int begin, int end, void *)
|
||||
{
|
||||
peakBlockSize = qMax(peakBlockSize, end - begin);
|
||||
const int blockSize = end - begin;
|
||||
if (blockSize > peakBlockSize) {
|
||||
peakBlockSize = blockSize;
|
||||
peakBegin = begin;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
int peakBlockSize;
|
||||
int peakBegin;
|
||||
};
|
||||
|
||||
static QByteArray msgBlockSize(const BlockSizeRecorder &recorder, int expectedMinimumBlockSize)
|
||||
{
|
||||
return QByteArrayLiteral("peakBlockSize=") + QByteArray::number(recorder.peakBlockSize)
|
||||
+ QByteArrayLiteral(" is less than expectedMinimumBlockSize=")
|
||||
+ QByteArray::number(expectedMinimumBlockSize)
|
||||
+ QByteArrayLiteral(", reached at: ") + QByteArray::number(recorder.peakBegin)
|
||||
+ QByteArrayLiteral(" (ideal thread count: ") + QByteArray::number(QThread::idealThreadCount())
|
||||
+ ')';
|
||||
}
|
||||
|
||||
void tst_QtConcurrentIterateKernel::blockSize()
|
||||
{
|
||||
const int expectedMinimumBlockSize = 1024 / QThread::idealThreadCount();
|
||||
BlockSizeRecorder(0, 10000).startBlocking();
|
||||
if (peakBlockSize < expectedMinimumBlockSize)
|
||||
qDebug() << "block size" << peakBlockSize;
|
||||
QVERIFY(peakBlockSize >= expectedMinimumBlockSize);
|
||||
BlockSizeRecorder recorder(0, 10000);
|
||||
recorder.startBlocking();
|
||||
#ifdef Q_OS_WIN
|
||||
if (recorder.peakBlockSize < expectedMinimumBlockSize)
|
||||
QEXPECT_FAIL("", msgBlockSize(recorder, expectedMinimumBlockSize).constData(), Abort);
|
||||
#endif // Q_OS_WIN
|
||||
QVERIFY2(recorder.peakBlockSize >= expectedMinimumBlockSize, msgBlockSize(recorder, expectedMinimumBlockSize));
|
||||
}
|
||||
|
||||
class MultipleResultsFor : public IterateKernel<TestIterator, int>
|
||||
|
Loading…
Reference in New Issue
Block a user