forked from qt-creator/qt-creator
AutoTest: Avoid concurrent access on static function members
First thread using the helper function initialized the list object another thread accesses it afterwards. This could be problematic under some circumstances. Issue was detected using Helgrind. Change-Id: I1520b1f7364742cb02630af1fd9d98960dec1f41 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -25,54 +25,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../testframeworkmanager.h"
|
||||
#include <QHash>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QByteArrayList>
|
||||
namespace Core { class Id; }
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace QuickTestUtils {
|
||||
|
||||
class QuickTestUtils
|
||||
{
|
||||
public:
|
||||
static bool isQuickTestMacro(const QByteArray ¯o)
|
||||
{
|
||||
static const QByteArrayList valid = {"QUICK_TEST_MAIN", "QUICK_TEST_OPENGL_MAIN"};
|
||||
return valid.contains(macro);
|
||||
}
|
||||
|
||||
static QHash<QString, QString> proFilesForQmlFiles(const Core::Id &id, const QStringList &files)
|
||||
{
|
||||
QHash<QString, QString> result;
|
||||
TestTreeItem *rootNode = TestFrameworkManager::instance()->rootNodeForTestFramework(id);
|
||||
QTC_ASSERT(rootNode, return result);
|
||||
|
||||
if (files.isEmpty())
|
||||
return result;
|
||||
|
||||
for (int row = 0, rootCount = rootNode->childCount(); row < rootCount; ++row) {
|
||||
const TestTreeItem *child = rootNode->childItem(row);
|
||||
const QString &file = child->filePath();
|
||||
if (!file.isEmpty() && files.contains(file)) {
|
||||
const QString &proFile = child->proFile();
|
||||
if (!proFile.isEmpty())
|
||||
result.insert(file, proFile);
|
||||
}
|
||||
for (int subRow = 0, subCount = child->childCount(); subRow < subCount; ++subRow) {
|
||||
const TestTreeItem *grandChild = child->childItem(subRow);
|
||||
const QString &file = grandChild->filePath();
|
||||
if (!file.isEmpty() && files.contains(file)) {
|
||||
const QString &proFile = grandChild->proFile();
|
||||
if (!proFile.isEmpty())
|
||||
result.insert(file, proFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
bool isQuickTestMacro(const QByteArray ¯o);
|
||||
QHash<QString, QString> proFilesForQmlFiles(const Core::Id &id, const QStringList &files);
|
||||
|
||||
} // namespace QuickTestUtils
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
||||
Reference in New Issue
Block a user