Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/testlib/qtestblacklist.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||
---|---|---|---|---|---|---|---|---|
1 | - | |||||||
2 | - | |||||||
3 | - | |||||||
4 | - | |||||||
5 | static QSet<QByteArray> keywords() | - | ||||||
6 | { | - | ||||||
7 | - | |||||||
8 | QSet<QByteArray> set = QSet<QByteArray>() | - | ||||||
9 | << "*" | - | ||||||
10 | - | |||||||
11 | << "linux" | - | ||||||
12 | << "64bit" | - | ||||||
13 | - | |||||||
14 | - | |||||||
15 | - | |||||||
16 | - | |||||||
17 | - | |||||||
18 | << "gcc" | - | ||||||
19 | << "x86" | - | ||||||
20 | - | |||||||
21 | - | |||||||
22 | - | |||||||
23 | - | |||||||
24 | - | |||||||
25 | - | |||||||
26 | << "developer-build" | - | ||||||
27 | - | |||||||
28 | ; | - | ||||||
29 | - | |||||||
30 | QCoreApplication *app = QCoreApplication::instance(); | - | ||||||
31 | if (app
| 0-2 | ||||||
32 | const QVariant platformName = app->property("platformName"); | - | ||||||
33 | if (platformName.isValid()
| 0-2 | ||||||
34 | set never executed: << platformName.toByteArray();set << platformName.toByteArray(); never executed: set << platformName.toByteArray(); | 0 | ||||||
35 | } executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
36 | - | |||||||
37 | return executed 2 times by 1 test: set;return set; Executed by:
executed 2 times by 1 test: return set; Executed by:
| 2 | ||||||
38 | } | - | ||||||
39 | - | |||||||
40 | static QSet<QByteArray> activeConditions() | - | ||||||
41 | { | - | ||||||
42 | QSet<QByteArray> result = keywords(); | - | ||||||
43 | - | |||||||
44 | QByteArray distributionName = QSysInfo::productType().toLower().toUtf8(); | - | ||||||
45 | QByteArray distributionRelease = QSysInfo::productVersion().toLower().toUtf8(); | - | ||||||
46 | if (!distributionName.isEmpty()
| 0-2 | ||||||
47 | if (result.find(distributionName) == result.end()
| 0-2 | ||||||
48 | result.insert(distributionName); executed 2 times by 1 test: result.insert(distributionName); Executed by:
| 2 | ||||||
49 | if (!distributionRelease.isEmpty()
| 0-2 | ||||||
50 | QByteArray versioned = distributionName + "-" + distributionRelease; | - | ||||||
51 | if (result.find(versioned) == result.end()
| 0-2 | ||||||
52 | result.insert(versioned); executed 2 times by 1 test: result.insert(versioned); Executed by:
| 2 | ||||||
53 | }} executed 2 times by 1 test: end of block Executed by:
| 2 | ||||||
54 | if (qEnvironmentVariableIsSet("QTEST_ENVIRONMENT")) { | 2 | ||||||
for (QForeachContainer<typename QtPrivate::remove_reference<decltype(qgetenv("QTEST_ENVIRONMENT").split(' '))>::type> _container_((qgetenv("QTEST_ENVIRONMENT").split(' '))); _container_.control && _container_.i != _container_.e; ++_container_.i, _container_.control ^= 1) for (const QByteArray &k = *_container_.i; _container_.control; _container_.control = 0) | ||||||||
result.insert(k);} executed 2 times by 1 test: end of block Executed by:
| ||||||||
55 | - | |||||||
56 | return executed 2 times by 1 test: result;return result; Executed by:
executed 2 times by 1 test: return result; Executed by:
| 2 | ||||||
57 | } | - | ||||||
58 | - | |||||||
59 | static bool checkCondition(const QByteArray &condition) | - | ||||||
60 | { | - | ||||||
61 | static const QSet<QByteArray> matchedConditions = activeConditions(); | - | ||||||
62 | QList<QByteArray> conds = condition.split(' '); | - | ||||||
63 | - | |||||||
64 | for (int i = 0; i < conds.size(); ++i) { | - | ||||||
65 | QByteArray c = conds.at(i); | - | ||||||
66 | bool result = c.startsWith('!'); | - | ||||||
67 | if (result) | - | ||||||
68 | c = c.mid(1); | - | ||||||
69 | - | |||||||
70 | result ^= matchedConditions.contains(c); | - | ||||||
71 | if (!result) | - | ||||||
72 | return false; | - | ||||||
73 | } | - | ||||||
74 | return true; | - | ||||||
75 | } | - | ||||||
76 | - | |||||||
77 | static bool ignoreAll = false; | - | ||||||
78 | static std::set<QByteArray> *ignoredTests = 0; | - | ||||||
79 | static std::set<QByteArray> *gpuFeatures = 0; | - | ||||||
80 | - | |||||||
81 | __attribute__((visibility("default"))) std::set<QByteArray> *(*qgpu_features_ptr)(const QString &) = 0; | - | ||||||
82 | - | |||||||
83 | static bool isGPUTestBlacklisted(const char *slot, const char *data = 0) | - | ||||||
84 | { | - | ||||||
85 | const QByteArray disableKey = ([]() -> QByteArray { enum { Size = sizeof("disable_") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "disable_" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()) + QByteArray(slot); | - | ||||||
86 | if (gpuFeatures->find(disableKey) != gpuFeatures->end()) { | - | ||||||
87 | QByteArray msg = ([]() -> QByteArray { enum { Size = sizeof("Skipped due to GPU blacklist: ") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "Skipped due to GPU blacklist: " }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()) + disableKey; | - | ||||||
88 | if (data) | - | ||||||
89 | msg += ':' + QByteArray(data); | - | ||||||
90 | QTest::qSkip(msg.constData(), __FILE__, 212218); | - | ||||||
91 | return true; | - | ||||||
92 | } | - | ||||||
93 | return false; | - | ||||||
94 | } | - | ||||||
95 | - | |||||||
96 | namespace QTestPrivate { | - | ||||||
97 | - | |||||||
98 | void parseBlackList() | - | ||||||
99 | { | - | ||||||
100 | QString filename = QTest::qFindTestData(([]() -> QString { enum { Size = sizeof(u"" "BLACKLIST")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "BLACKLIST" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | - | ||||||
101 | if (filename.isEmpty()) | - | ||||||
102 | return; | - | ||||||
103 | QFile ignored(filename); | - | ||||||
104 | if (!ignored.open(QIODevice::ReadOnly)) | - | ||||||
105 | return; | - | ||||||
106 | - | |||||||
107 | QByteArray function; | - | ||||||
108 | - | |||||||
109 | while (!ignored.atEnd()) { | - | ||||||
110 | QByteArray line = ignored.readLine().simplified(); | - | ||||||
111 | if (line.isEmpty() || line.startsWith('#')) | - | ||||||
112 | continue; | - | ||||||
113 | if (line.startsWith('[')) { | - | ||||||
114 | function = line.mid(1, line.length() - 2); | - | ||||||
115 | continue; | - | ||||||
116 | } | - | ||||||
117 | bool condition = checkCondition(line); | - | ||||||
118 | if (condition) { | - | ||||||
119 | if (!function.size()) { | - | ||||||
120 | ignoreAll = true; | - | ||||||
121 | } else { | - | ||||||
122 | if (!ignoredTests) | - | ||||||
123 | ignoredTests = new std::set<QByteArray>; | - | ||||||
124 | ignoredTests->insert(function); | - | ||||||
125 | } | - | ||||||
126 | } | - | ||||||
127 | } | - | ||||||
128 | } | - | ||||||
129 | - | |||||||
130 | void parseGpuBlackList() | - | ||||||
131 | { | - | ||||||
132 | if (!qgpu_features_ptr) | - | ||||||
133 | return; | - | ||||||
134 | QString filename = QTest::qFindTestData(([]() -> QString { enum { Size = sizeof(u"" "GPU_BLACKLIST")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "GPU_BLACKLIST" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }())); | - | ||||||
135 | if (filename.isEmpty()) | - | ||||||
136 | return; | - | ||||||
137 | if (!gpuFeatures) | - | ||||||
138 | gpuFeatures = qgpu_features_ptr(filename); | - | ||||||
139 | } | - | ||||||
140 | - | |||||||
141 | void checkBlackLists(const char *slot, const char *data) | - | ||||||
142 | { | - | ||||||
143 | bool ignore = ignoreAll; | - | ||||||
144 | - | |||||||
145 | if (!ignore && ignoredTests) { | - | ||||||
146 | QByteArray s = slot; | - | ||||||
147 | ignore = (ignoredTests->find(s) != ignoredTests->end()); | - | ||||||
148 | if (!ignore && data) { | - | ||||||
149 | s += ':'; | - | ||||||
150 | s += data; | - | ||||||
151 | ignore = (ignoredTests->find(s) != ignoredTests->end()); | - | ||||||
152 | } | - | ||||||
153 | } | - | ||||||
154 | - | |||||||
155 | QTestResult::setBlacklistCurrentTest(ignore); | - | ||||||
156 | - | |||||||
157 | - | |||||||
158 | - | |||||||
159 | if (!ignore && gpuFeatures) { | - | ||||||
160 | QByteArray s_gpu = slot; | - | ||||||
161 | ignore = isGPUTestBlacklisted(s_gpu, data); | - | ||||||
162 | if (!ignore && data) { | - | ||||||
163 | s_gpu += ':'; | - | ||||||
164 | s_gpu += data; | - | ||||||
165 | isGPUTestBlacklisted(s_gpu); | - | ||||||
166 | } | - | ||||||
167 | } | - | ||||||
168 | } | - | ||||||
169 | - | |||||||
170 | } | - | ||||||
171 | - | |||||||
172 | - | |||||||
173 | - | |||||||
Switch to Source code | Preprocessed file |