| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/testlib/qtestblacklist.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtTest module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||
| 25 | ** | - | ||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||
| 29 | ** | - | ||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 31 | ** | - | ||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||
| 33 | #include "qtestblacklist_p.h" | - | ||||||||||||
| 34 | #include "qtestresult_p.h" | - | ||||||||||||
| 35 | - | |||||||||||||
| 36 | #include <QtTest/qtestcase.h> | - | ||||||||||||
| 37 | #include <QtCore/qbytearray.h> | - | ||||||||||||
| 38 | #include <QtCore/qfile.h> | - | ||||||||||||
| 39 | #include <QtCore/qset.h> | - | ||||||||||||
| 40 | #include <QtCore/qcoreapplication.h> | - | ||||||||||||
| 41 | #include <QtCore/qvariant.h> | - | ||||||||||||
| 42 | #include <QtCore/QSysInfo> | - | ||||||||||||
| 43 | - | |||||||||||||
| 44 | #include <set> | - | ||||||||||||
| 45 | - | |||||||||||||
| 46 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 47 | - | |||||||||||||
| 48 | /* | - | ||||||||||||
| 49 | The BLACKLIST file format is a grouped listing of keywords. | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | Blank lines and lines starting with # are simply ignored. An initial #-line | - | ||||||||||||
| 52 | referring to this documentation is kind to readers. Comments can also be used | - | ||||||||||||
| 53 | to indicate the reasons for ignoring particular cases. | - | ||||||||||||
| 54 | - | |||||||||||||
| 55 | A key names a platform, O/S, distribution, tool-chain or architecture; a ! | - | ||||||||||||
| 56 | prefix reverses what it checks. A version, joined to a key (at present, only | - | ||||||||||||
| 57 | for distributions and for msvc) with a hyphen, limits the key to the specific | - | ||||||||||||
| 58 | version. A keyword line matches if every key on it applies to the present | - | ||||||||||||
| 59 | run. Successive lines are alternate conditions for ignoring a test. | - | ||||||||||||
| 60 | - | |||||||||||||
| 61 | Ungrouped lines at the beginning of a file apply to the whole testcase. | - | ||||||||||||
| 62 | A group starts with a [square-bracketed] identification of a test function, | - | ||||||||||||
| 63 | optionally with (after a colon, the name of) a specific data set, to ignore. | - | ||||||||||||
| 64 | Subsequent lines give conditions for ignoring this test. | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | # See qtbase/src/testlib/qtestblacklist.cpp for format | - | ||||||||||||
| 67 | osx | - | ||||||||||||
| 68 | - | |||||||||||||
| 69 | # QTBUG-12345 | - | ||||||||||||
| 70 | [testFunction] | - | ||||||||||||
| 71 | linux | - | ||||||||||||
| 72 | windows 64bit | - | ||||||||||||
| 73 | - | |||||||||||||
| 74 | # Needs basic C++11 support | - | ||||||||||||
| 75 | [testfunction2:testData] | - | ||||||||||||
| 76 | msvc-2010 | - | ||||||||||||
| 77 | - | |||||||||||||
| 78 | Keys are lower-case. Distribution name and version are supported if | - | ||||||||||||
| 79 | QSysInfo's productType() and productVersion() return them. Keys can be | - | ||||||||||||
| 80 | added via the space-separated QTEST_ENVIRONMENT environment variable. | - | ||||||||||||
| 81 | - | |||||||||||||
| 82 | The other known keys are listed below: | - | ||||||||||||
| 83 | */ | - | ||||||||||||
| 84 | - | |||||||||||||
| 85 | static QSet<QByteArray> keywords() | - | ||||||||||||
| 86 | { | - | ||||||||||||
| 87 | // this list can be extended with new keywords as required | - | ||||||||||||
| 88 | QSet<QByteArray> set = QSet<QByteArray>() | - | ||||||||||||
| 89 | << "*" | - | ||||||||||||
| 90 | #ifdef Q_OS_LINUX | - | ||||||||||||
| 91 | << "linux" | - | ||||||||||||
| 92 | #endif | - | ||||||||||||
| 93 | #ifdef Q_OS_OSX | - | ||||||||||||
| 94 | << "osx" | - | ||||||||||||
| 95 | #endif | - | ||||||||||||
| 96 | #ifdef Q_OS_WIN | - | ||||||||||||
| 97 | << "windows" | - | ||||||||||||
| 98 | #endif | - | ||||||||||||
| 99 | #ifdef Q_OS_IOS | - | ||||||||||||
| 100 | << "ios" | - | ||||||||||||
| 101 | #endif | - | ||||||||||||
| 102 | #ifdef Q_OS_ANDROID | - | ||||||||||||
| 103 | << "android" | - | ||||||||||||
| 104 | #endif | - | ||||||||||||
| 105 | #ifdef Q_OS_QNX | - | ||||||||||||
| 106 | << "qnx" | - | ||||||||||||
| 107 | #endif | - | ||||||||||||
| 108 | #ifdef Q_OS_WINRT | - | ||||||||||||
| 109 | << "winrt" | - | ||||||||||||
| 110 | #endif | - | ||||||||||||
| 111 | #ifdef Q_OS_WINCE | - | ||||||||||||
| 112 | << "wince" | - | ||||||||||||
| 113 | #endif | - | ||||||||||||
| 114 | - | |||||||||||||
| 115 | #if QT_POINTER_SIZE == 8 | - | ||||||||||||
| 116 | << "64bit" | - | ||||||||||||
| 117 | #else | - | ||||||||||||
| 118 | << "32bit" | - | ||||||||||||
| 119 | #endif | - | ||||||||||||
| 120 | - | |||||||||||||
| 121 | #ifdef Q_CC_GNU | - | ||||||||||||
| 122 | << "gcc" | - | ||||||||||||
| 123 | #endif | - | ||||||||||||
| 124 | #ifdef Q_CC_CLANG | - | ||||||||||||
| 125 | << "clang" | - | ||||||||||||
| 126 | #endif | - | ||||||||||||
| 127 | #ifdef Q_CC_MSVC | - | ||||||||||||
| 128 | << "msvc" | - | ||||||||||||
| 129 | #ifdef _MSC_VER | - | ||||||||||||
| 130 | #if _MSC_VER == 1900 | - | ||||||||||||
| 131 | << "msvc-2015" | - | ||||||||||||
| 132 | #elif _MSC_VER == 1800 | - | ||||||||||||
| 133 | << "msvc-2013" | - | ||||||||||||
| 134 | #elif _MSC_VER == 1700 | - | ||||||||||||
| 135 | << "msvc-2012" | - | ||||||||||||
| 136 | #elif _MSC_VER == 1600 | - | ||||||||||||
| 137 | << "msvc-2010" | - | ||||||||||||
| 138 | #endif | - | ||||||||||||
| 139 | #endif | - | ||||||||||||
| 140 | #endif | - | ||||||||||||
| 141 | - | |||||||||||||
| 142 | #ifdef Q_AUTOTEST_EXPORT | - | ||||||||||||
| 143 | << "developer-build" | - | ||||||||||||
| 144 | #endif | - | ||||||||||||
| 145 | ; | - | ||||||||||||
| 146 | - | |||||||||||||
| 147 | QCoreApplication *app = QCoreApplication::instance(); | - | ||||||||||||
| 148 | if (app) {
| 0-2 | ||||||||||||
| 149 | const QVariant platformName = app->property("platformName"); | - | ||||||||||||
| 150 | if (platformName.isValid())
| 0-2 | ||||||||||||
| 151 | set << platformName.toByteArray(); never executed: set << platformName.toByteArray(); | 0 | ||||||||||||
| 152 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 153 | - | |||||||||||||
| 154 | return set; executed 2 times by 1 test: return set;Executed by:
| 2 | ||||||||||||
| 155 | } | - | ||||||||||||
| 156 | - | |||||||||||||
| 157 | static QSet<QByteArray> activeConditions() | - | ||||||||||||
| 158 | { | - | ||||||||||||
| 159 | QSet<QByteArray> result = keywords(); | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | QByteArray distributionName = QSysInfo::productType().toLower().toUtf8(); | - | ||||||||||||
| 162 | QByteArray distributionRelease = QSysInfo::productVersion().toLower().toUtf8(); | - | ||||||||||||
| 163 | if (!distributionName.isEmpty()) {
| 0-2 | ||||||||||||
| 164 | if (result.find(distributionName) == result.end())
| 0-2 | ||||||||||||
| 165 | result.insert(distributionName); executed 2 times by 1 test: result.insert(distributionName);Executed by:
| 2 | ||||||||||||
| 166 | if (!distributionRelease.isEmpty()) {
| 0-2 | ||||||||||||
| 167 | QByteArray versioned = distributionName + "-" + distributionRelease; | - | ||||||||||||
| 168 | if (result.find(versioned) == result.end())
| 0-2 | ||||||||||||
| 169 | result.insert(versioned); executed 2 times by 1 test: result.insert(versioned);Executed by:
| 2 | ||||||||||||
| 170 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 171 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 172 | - | |||||||||||||
| 173 | if (qEnvironmentVariableIsSet("QTEST_ENVIRONMENT")) {
| 0-2 | ||||||||||||
| 174 | foreach (const QByteArray &k, qgetenv("QTEST_ENVIRONMENT").split(' ')) | - | ||||||||||||
| 175 | result.insert(k); never executed: result.insert(k); | 0 | ||||||||||||
| 176 | } never executed: end of block | 0 | ||||||||||||
| 177 | - | |||||||||||||
| 178 | return result; executed 2 times by 1 test: return result;Executed by:
| 2 | ||||||||||||
| 179 | } | - | ||||||||||||
| 180 | - | |||||||||||||
| 181 | static bool checkCondition(const QByteArray &condition) | - | ||||||||||||
| 182 | { | - | ||||||||||||
| 183 | static const QSet<QByteArray> matchedConditions = activeConditions(); | - | ||||||||||||
| 184 | QList<QByteArray> conds = condition.split(' '); | - | ||||||||||||
| 185 | - | |||||||||||||
| 186 | for (int i = 0; i < conds.size(); ++i) {
| 12 | ||||||||||||
| 187 | QByteArray c = conds.at(i); | - | ||||||||||||
| 188 | bool result = c.startsWith('!'); | - | ||||||||||||
| 189 | if (result)
| 0-12 | ||||||||||||
| 190 | c = c.mid(1); never executed: c = c.mid(1); | 0 | ||||||||||||
| 191 | - | |||||||||||||
| 192 | result ^= matchedConditions.contains(c); | - | ||||||||||||
| 193 | if (!result)
| 0-12 | ||||||||||||
| 194 | return false; never executed: return false; | 0 | ||||||||||||
| 195 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||
| 196 | return true; executed 12 times by 1 test: return true;Executed by:
| 12 | ||||||||||||
| 197 | } | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | static bool ignoreAll = false; | - | ||||||||||||
| 200 | static std::set<QByteArray> *ignoredTests = 0; | - | ||||||||||||
| 201 | static std::set<QByteArray> *gpuFeatures = 0; | - | ||||||||||||
| 202 | - | |||||||||||||
| 203 | Q_TESTLIB_EXPORT std::set<QByteArray> *(*qgpu_features_ptr)(const QString &) = 0; | - | ||||||||||||
| 204 | - | |||||||||||||
| 205 | static bool isGPUTestBlacklisted(const char *slot, const char *data = 0) | - | ||||||||||||
| 206 | { | - | ||||||||||||
| 207 | const QByteArray disableKey = QByteArrayLiteral("disable_") + QByteArray(slot); never executed: return ba; | 0 | ||||||||||||
| 208 | if (gpuFeatures->find(disableKey) != gpuFeatures->end()) {
| 0 | ||||||||||||
| 209 | QByteArray msg = QByteArrayLiteral("Skipped due to GPU blacklist: ") + disableKey; never executed: return ba; | 0 | ||||||||||||
| 210 | if (data)
| 0 | ||||||||||||
| 211 | msg += ':' + QByteArray(data); never executed: msg += ':' + QByteArray(data); | 0 | ||||||||||||
| 212 | QTest::qSkip(msg.constData(), __FILE__, __LINE__); | - | ||||||||||||
| 213 | return true; never executed: return true; | 0 | ||||||||||||
| 214 | } | - | ||||||||||||
| 215 | return false; never executed: return false; | 0 | ||||||||||||
| 216 | } | - | ||||||||||||
| 217 | - | |||||||||||||
| 218 | namespace QTestPrivate { | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | void parseBlackList() | - | ||||||||||||
| 221 | { | - | ||||||||||||
| 222 | QString filename = QTest::qFindTestData(QStringLiteral("BLACKLIST")); executed 699 times by 1 test: return qstring_literal_temp;Executed by:
| 699 | ||||||||||||
| 223 | if (filename.isEmpty())
| 2-697 | ||||||||||||
| 224 | return; executed 697 times by 1 test: return;Executed by:
| 697 | ||||||||||||
| 225 | QFile ignored(filename); | - | ||||||||||||
| 226 | if (!ignored.open(QIODevice::ReadOnly))
| 0-2 | ||||||||||||
| 227 | return; never executed: return; | 0 | ||||||||||||
| 228 | - | |||||||||||||
| 229 | QByteArray function; | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | while (!ignored.atEnd()) {
| 2-24 | ||||||||||||
| 232 | QByteArray line = ignored.readLine().simplified(); | - | ||||||||||||
| 233 | if (line.isEmpty() || line.startsWith('#'))
| 0-24 | ||||||||||||
| 234 | continue; never executed: continue; | 0 | ||||||||||||
| 235 | if (line.startsWith('[')) {
| 12 | ||||||||||||
| 236 | function = line.mid(1, line.length() - 2); | - | ||||||||||||
| 237 | continue; executed 12 times by 1 test: continue;Executed by:
| 12 | ||||||||||||
| 238 | } | - | ||||||||||||
| 239 | bool condition = checkCondition(line); | - | ||||||||||||
| 240 | if (condition) {
| 0-12 | ||||||||||||
| 241 | if (!function.size()) {
| 0-12 | ||||||||||||
| 242 | ignoreAll = true; | - | ||||||||||||
| 243 | } else { never executed: end of block | 0 | ||||||||||||
| 244 | if (!ignoredTests)
| 2-10 | ||||||||||||
| 245 | ignoredTests = new std::set<QByteArray>; executed 2 times by 1 test: ignoredTests = new std::set<QByteArray>;Executed by:
| 2 | ||||||||||||
| 246 | ignoredTests->insert(function); | - | ||||||||||||
| 247 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||
| 248 | } | - | ||||||||||||
| 249 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||
| 250 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||
| 251 | - | |||||||||||||
| 252 | void parseGpuBlackList() | - | ||||||||||||
| 253 | { | - | ||||||||||||
| 254 | if (!qgpu_features_ptr)
| 21-678 | ||||||||||||
| 255 | return; executed 678 times by 1 test: return;Executed by:
| 678 | ||||||||||||
| 256 | QString filename = QTest::qFindTestData(QStringLiteral("GPU_BLACKLIST")); executed 21 times by 1 test: return qstring_literal_temp;Executed by:
| 21 | ||||||||||||
| 257 | if (filename.isEmpty())
| 0-21 | ||||||||||||
| 258 | return; executed 21 times by 1 test: return;Executed by:
| 21 | ||||||||||||
| 259 | if (!gpuFeatures)
| 0 | ||||||||||||
| 260 | gpuFeatures = qgpu_features_ptr(filename); never executed: gpuFeatures = qgpu_features_ptr(filename); | 0 | ||||||||||||
| 261 | } never executed: end of block | 0 | ||||||||||||
| 262 | - | |||||||||||||
| 263 | void checkBlackLists(const char *slot, const char *data) | - | ||||||||||||
| 264 | { | - | ||||||||||||
| 265 | bool ignore = ignoreAll; | - | ||||||||||||
| 266 | - | |||||||||||||
| 267 | if (!ignore && ignoredTests) {
| 471-130010 | ||||||||||||
| 268 | QByteArray s = slot; | - | ||||||||||||
| 269 | ignore = (ignoredTests->find(s) != ignoredTests->end()); | - | ||||||||||||
| 270 | if (!ignore && data) {
| 70-3667 | ||||||||||||
| 271 | s += ':'; | - | ||||||||||||
| 272 | s += data; | - | ||||||||||||
| 273 | ignore = (ignoredTests->find(s) != ignoredTests->end()); | - | ||||||||||||
| 274 | } executed 2847 times by 18 tests: end of blockExecuted by:
| 2847 | ||||||||||||
| 275 | } executed 3737 times by 24 tests: end of blockExecuted by:
| 3737 | ||||||||||||
| 276 | - | |||||||||||||
| 277 | QTestResult::setBlacklistCurrentTest(ignore); | - | ||||||||||||
| 278 | - | |||||||||||||
| 279 | // Tests blacklisted in GPU_BLACKLIST are to be skipped. Just ignoring the result is | - | ||||||||||||
| 280 | // not sufficient since these are expected to crash or behave in undefined ways. | - | ||||||||||||
| 281 | if (!ignore && gpuFeatures) {
| 0-129932 | ||||||||||||
| 282 | QByteArray s_gpu = slot; | - | ||||||||||||
| 283 | ignore = isGPUTestBlacklisted(s_gpu, data); | - | ||||||||||||
| 284 | if (!ignore && data) {
| 0 | ||||||||||||
| 285 | s_gpu += ':'; | - | ||||||||||||
| 286 | s_gpu += data; | - | ||||||||||||
| 287 | isGPUTestBlacklisted(s_gpu); | - | ||||||||||||
| 288 | } never executed: end of block | 0 | ||||||||||||
| 289 | } never executed: end of block | 0 | ||||||||||||
| 290 | } executed 130481 times by 535 tests: end of blockExecuted by:
| 130481 | ||||||||||||
| 291 | - | |||||||||||||
| 292 | } | - | ||||||||||||
| 293 | - | |||||||||||||
| 294 | - | |||||||||||||
| 295 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |