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,45 +25,17 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../testframeworkmanager.h"
|
||||
#include <QHash>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QByteArrayList>
|
||||
namespace Core { class Id; }
|
||||
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
namespace QTestUtils {
|
||||
|
||||
class QTestUtils
|
||||
{
|
||||
public:
|
||||
static bool isQTestMacro(const QByteArray ¯o)
|
||||
{
|
||||
static QByteArrayList valid = {"QTEST_MAIN", "QTEST_APPLESS_MAIN", "QTEST_GUILESS_MAIN"};
|
||||
return valid.contains(macro);
|
||||
}
|
||||
|
||||
static QHash<QString, QString> testCaseNamesForFiles(const Core::Id &id,
|
||||
const QStringList &files)
|
||||
{
|
||||
QHash<QString, QString> result;
|
||||
TestTreeItem *rootNode = TestFrameworkManager::instance()->rootNodeForTestFramework(id);
|
||||
QTC_ASSERT(rootNode, return result);
|
||||
|
||||
for (int row = 0, rootCount = rootNode->childCount(); row < rootCount; ++row) {
|
||||
const TestTreeItem *child = rootNode->childItem(row);
|
||||
if (files.contains(child->filePath())) {
|
||||
result.insert(child->filePath(), child->name());
|
||||
}
|
||||
for (int childRow = 0, count = child->childCount(); childRow < count; ++childRow) {
|
||||
const TestTreeItem *grandChild = child->childItem(childRow);
|
||||
if (files.contains(grandChild->filePath()))
|
||||
result.insert(grandChild->filePath(), child->name());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
bool isQTestMacro(const QByteArray ¯o);
|
||||
QHash<QString, QString> testCaseNamesForFiles(const Core::Id &id, const QStringList &files);
|
||||
|
||||
} // namespace QTestUtils
|
||||
} // namespace Internal
|
||||
} // namespace Autotest
|
||||
|
||||
Reference in New Issue
Block a user