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