From 3760120ab33ea454bed320b10e8afcb29f7869ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 28 Jul 2017 09:42:03 +0200 Subject: [PATCH] Remove tst_qtconcurrentiteratekernel blockSize test The test is just wrong. It suggests, that it tests minimal block size, but in reality it is checking if a maximal peak of block size is bigger then expected minimum block size. The minimal block size is 1, not 1024 / ideal threads count and it is defined in BlockSizeManagerV2. The maximal block size is defined and it is fixed, but it is an implementation detail, probably not worth testing. The test is based on a race condition as peakBegin and peakBlockSize are modified in parallel from multiple threads, without any synchronization. Change-Id: I430eedcf83b0fa3e2ce2cfd294eaee7b301e48ae Reviewed-by: Simon Hausmann --- .../tst_qtconcurrentiteratekernel.cpp | 45 ------------------- 1 file changed, 45 deletions(-) diff --git a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp index 4bb3fa5b283..2e698e6615d 100644 --- a/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp +++ b/tests/auto/concurrent/qtconcurrentiteratekernel/tst_qtconcurrentiteratekernel.cpp @@ -81,7 +81,6 @@ private slots: void stresstest(); void noIterations(); void throttling(); - void blockSize(); void multipleResults(); }; @@ -240,50 +239,6 @@ void tst_QtConcurrentIterateKernel::throttling() QCOMPARE(threads.count(), 1); } -class BlockSizeRecorder : public IterateKernel -{ -public: - BlockSizeRecorder(TestIterator begin, TestIterator end) - : IterateKernel(begin, end) - , peakBlockSize(0) - , peakBegin(0) - {} - - inline bool runIterations(TestIterator, int begin, int end, void *) - { - 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 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 { public: