0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the test suite of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
|
|
43 |
#include <QtCore/QtCore>
|
|
44 |
#include <QtTest/QtTest>
|
|
45 |
|
|
46 |
#ifdef QT_NO_PROCESS
|
|
47 |
QTEST_NOOP_MAIN
|
|
48 |
#else
|
|
49 |
|
|
50 |
#include "qbic.h"
|
|
51 |
|
|
52 |
#include <stdlib.h>
|
|
53 |
|
|
54 |
class tst_Bic: public QObject
|
|
55 |
{
|
|
56 |
Q_OBJECT
|
|
57 |
|
|
58 |
public:
|
|
59 |
tst_Bic();
|
|
60 |
QBic::Info getCurrentInfo(const QString &libName);
|
|
61 |
|
|
62 |
private slots:
|
|
63 |
void initTestCase_data();
|
|
64 |
void initTestCase();
|
|
65 |
|
|
66 |
void sizesAndVTables_data();
|
|
67 |
void sizesAndVTables();
|
|
68 |
|
|
69 |
private:
|
|
70 |
QBic bic;
|
|
71 |
};
|
|
72 |
|
|
73 |
typedef QPair<QString, QString> QStringPair;
|
|
74 |
|
|
75 |
tst_Bic::tst_Bic()
|
|
76 |
{
|
|
77 |
bic.addBlacklistedClass(QLatin1String("std::*"));
|
|
78 |
bic.addBlacklistedClass(QLatin1String("qIsNull*"));
|
|
79 |
bic.addBlacklistedClass(QLatin1String("_*"));
|
|
80 |
bic.addBlacklistedClass(QLatin1String("<anonymous*"));
|
|
81 |
|
|
82 |
/* some system stuff we don't care for */
|
|
83 |
bic.addBlacklistedClass(QLatin1String("timespec"));
|
|
84 |
bic.addBlacklistedClass(QLatin1String("itimerspec"));
|
|
85 |
bic.addBlacklistedClass(QLatin1String("sched_param"));
|
|
86 |
bic.addBlacklistedClass(QLatin1String("timeval"));
|
|
87 |
bic.addBlacklistedClass(QLatin1String("drand"));
|
|
88 |
bic.addBlacklistedClass(QLatin1String("lconv"));
|
|
89 |
bic.addBlacklistedClass(QLatin1String("random"));
|
|
90 |
bic.addBlacklistedClass(QLatin1String("wait"));
|
|
91 |
bic.addBlacklistedClass(QLatin1String("tm"));
|
|
92 |
bic.addBlacklistedClass(QLatin1String("sigcontext"));
|
|
93 |
bic.addBlacklistedClass(QLatin1String("ucontext"));
|
|
94 |
bic.addBlacklistedClass(QLatin1String("ucontext64"));
|
|
95 |
bic.addBlacklistedClass(QLatin1String("sigaltstack"));
|
|
96 |
|
|
97 |
/* QtOpenGL includes qt_windows.h, and some SDKs dont have these structs present */
|
|
98 |
bic.addBlacklistedClass(QLatin1String("tagTITLEBARINFO"));
|
|
99 |
|
|
100 |
/* some bug in gcc also reported template instanciations */
|
|
101 |
bic.addBlacklistedClass(QLatin1String("QTypeInfo<*>"));
|
|
102 |
bic.addBlacklistedClass(QLatin1String("QMetaTypeId<*>"));
|
|
103 |
bic.addBlacklistedClass(QLatin1String("QVector<QGradientStop>*"));
|
|
104 |
|
|
105 |
/* this guy is never instantiated, just for compile-time checking */
|
|
106 |
bic.addBlacklistedClass(QLatin1String("QMap<*>::PayloadNode"));
|
|
107 |
|
|
108 |
/* QFileEngine was removed in 4.1 */
|
|
109 |
bic.addBlacklistedClass(QLatin1String("QFileEngine"));
|
|
110 |
bic.addBlacklistedClass(QLatin1String("QFileEngineHandler"));
|
|
111 |
bic.addBlacklistedClass(QLatin1String("QFlags<QFileEngine::FileFlag>"));
|
|
112 |
|
|
113 |
/* Private classes */
|
|
114 |
bic.addBlacklistedClass(QLatin1String("QBrushData"));
|
|
115 |
bic.addBlacklistedClass(QLatin1String("QObjectData"));
|
|
116 |
bic.addBlacklistedClass(QLatin1String("QAtomic"));
|
|
117 |
bic.addBlacklistedClass(QLatin1String("QBasicAtomic"));
|
|
118 |
|
|
119 |
/* Jambi-related classes in Designer */
|
|
120 |
bic.addBlacklistedClass(QLatin1String("QDesignerLanguageExtension"));
|
|
121 |
|
|
122 |
/* Harald says it's undocumented and private :) */
|
|
123 |
bic.addBlacklistedClass(QLatin1String("QAccessibleInterfaceEx"));
|
|
124 |
bic.addBlacklistedClass(QLatin1String("QAccessibleObjectEx"));
|
|
125 |
bic.addBlacklistedClass(QLatin1String("QAccessibleWidgetEx"));
|
|
126 |
|
|
127 |
/* This structure is semi-private and should never shrink */
|
|
128 |
bic.addBlacklistedClass(QLatin1String("QVFbHeader"));
|
|
129 |
}
|
|
130 |
|
|
131 |
void tst_Bic::initTestCase_data()
|
|
132 |
{
|
|
133 |
QTest::addColumn<QString>("libName");
|
|
134 |
|
|
135 |
QTest::newRow("QtCore") << "QtCore";
|
|
136 |
QTest::newRow("QtGui") << "QtGui";
|
|
137 |
QTest::newRow("QtScript") << "QtScript";
|
|
138 |
QTest::newRow("QtSql") << "QtSql";
|
|
139 |
QTest::newRow("QtSvg") << "QtSvg";
|
|
140 |
QTest::newRow("QtNetwork") << "QtNetwork";
|
|
141 |
QTest::newRow("QtOpenGL") << "QtOpenGL";
|
|
142 |
QTest::newRow("QtXml") << "QtXml";
|
|
143 |
QTest::newRow("QtXmlPatterns") << "QtXmlPatterns";
|
|
144 |
QTest::newRow("Qt3Support") << "Qt3Support";
|
|
145 |
QTest::newRow("QtTest") << "QtTest";
|
|
146 |
QTest::newRow("QtDBus") << "QtDBus";
|
|
147 |
QTest::newRow("QtDesigner") << "QtDesigner";
|
|
148 |
}
|
|
149 |
|
|
150 |
void tst_Bic::initTestCase()
|
|
151 |
{
|
|
152 |
QString qtDir = QString::fromLocal8Bit(qgetenv("QTDIR"));
|
|
153 |
QVERIFY2(!qtDir.isEmpty(), "This test needs $QTDIR");
|
|
154 |
|
|
155 |
if (qgetenv("PATH").contains("teambuilder"))
|
|
156 |
QTest::qWarn("This test might not work with teambuilder, consider switching it off.");
|
|
157 |
}
|
|
158 |
|
|
159 |
void tst_Bic::sizesAndVTables_data()
|
|
160 |
{
|
|
161 |
#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL)
|
|
162 |
QSKIP("Test not implemented for this compiler/platform", SkipAll);
|
|
163 |
#else
|
|
164 |
|
|
165 |
QString archFileName400;
|
|
166 |
QString archFileName410;
|
|
167 |
QString archFileName420;
|
|
168 |
QString archFileName430;
|
|
169 |
|
|
170 |
#if defined Q_OS_LINUX && defined Q_WS_X11
|
|
171 |
# if defined(__powerpc__) && !defined(__powerpc64__)
|
|
172 |
archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ppc32.txt";
|
|
173 |
archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ppc32.txt";
|
|
174 |
archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ppc32.txt";
|
|
175 |
# elif defined(__amd64__)
|
|
176 |
archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-amd64.txt";
|
|
177 |
# elif defined(__i386__)
|
|
178 |
archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ia32.txt";
|
|
179 |
archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ia32.txt";
|
|
180 |
archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ia32.txt";
|
|
181 |
archFileName430 = SRCDIR "data/%1.4.3.0.linux-gcc-ia32.txt";
|
|
182 |
# endif
|
|
183 |
#elif defined Q_OS_AIX
|
|
184 |
if (sizeof(void*) == 4)
|
|
185 |
archFileName400 = SRCDIR "data/%1.4.0.0.aix-gcc-power32.txt";
|
|
186 |
#elif defined Q_OS_MAC && defined(__powerpc__)
|
|
187 |
archFileName400 = SRCDIR "data/%1.4.0.0.macx-gcc-ppc32.txt";
|
|
188 |
archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ppc32.txt";
|
|
189 |
archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ppc32.txt";
|
|
190 |
#elif defined Q_OS_MAC && defined(__i386__)
|
|
191 |
archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ia32.txt";
|
|
192 |
archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ia32.txt";
|
|
193 |
#elif defined Q_OS_WIN && defined Q_CC_GNU
|
|
194 |
archFileName410 = SRCDIR "data/%1.4.1.0.win32-gcc-ia32.txt";
|
|
195 |
archFileName420 = SRCDIR "data/%1.4.2.0.win32-gcc-ia32.txt";
|
|
196 |
#endif
|
|
197 |
|
|
198 |
if (archFileName400.isEmpty() && archFileName410.isEmpty()
|
|
199 |
&& archFileName420.isEmpty())
|
|
200 |
QSKIP("No reference files found for this platform", SkipAll);
|
|
201 |
|
|
202 |
bool isPatchRelease400 = false;
|
|
203 |
bool isPatchRelease410 = false;
|
|
204 |
bool isPatchRelease420 = false;
|
|
205 |
bool isPatchRelease430 = false;
|
|
206 |
|
|
207 |
QTest::addColumn<QString>("oldLib");
|
|
208 |
QTest::addColumn<bool>("isPatchRelease");
|
|
209 |
|
|
210 |
QTest::newRow("4.0") << archFileName400 << isPatchRelease400;
|
|
211 |
QTest::newRow("4.1") << archFileName410 << isPatchRelease410;
|
|
212 |
QTest::newRow("4.2") << archFileName420 << isPatchRelease420;
|
|
213 |
QTest::newRow("4.3") << archFileName430 << isPatchRelease430;
|
|
214 |
#endif
|
|
215 |
}
|
|
216 |
|
|
217 |
QBic::Info tst_Bic::getCurrentInfo(const QString &libName)
|
|
218 |
{
|
|
219 |
QTemporaryFile tmpQFile;
|
|
220 |
tmpQFile.open();
|
|
221 |
QString tmpFileName = tmpQFile.fileName();
|
|
222 |
|
|
223 |
QByteArray tmpFileContents = "#include<" + libName.toLatin1() + "/" + libName.toLatin1() + ">\n";
|
|
224 |
tmpQFile.write(tmpFileContents);
|
|
225 |
tmpQFile.flush();
|
|
226 |
|
|
227 |
QString qtDir = QString::fromLocal8Bit(qgetenv("QTDIR"));
|
|
228 |
#ifdef Q_OS_WIN
|
|
229 |
qtDir.replace('\\', '/');
|
|
230 |
#endif
|
|
231 |
QString compilerName = "g++";
|
|
232 |
|
|
233 |
QStringList args;
|
|
234 |
args << "-c"
|
|
235 |
<< "-I" + qtDir + "/include"
|
|
236 |
#ifndef Q_OS_WIN
|
|
237 |
<< "-I/usr/X11R6/include/"
|
|
238 |
#endif
|
|
239 |
<< "-DQT_NO_STL" << "-DQT3_SUPPORT"
|
|
240 |
<< "-xc++"
|
|
241 |
#if !defined(Q_OS_AIX) && !defined(Q_OS_WIN)
|
|
242 |
<< "-o" << "/dev/null"
|
|
243 |
#endif
|
|
244 |
<< "-fdump-class-hierarchy"
|
|
245 |
<< tmpFileName;
|
|
246 |
|
|
247 |
QProcess proc;
|
|
248 |
proc.start(compilerName, args, QIODevice::ReadOnly);
|
|
249 |
if (!proc.waitForFinished(6000000)) {
|
|
250 |
qWarning() << "gcc didn't finish" << proc.errorString();
|
|
251 |
return QBic::Info();
|
|
252 |
}
|
|
253 |
if (proc.exitCode() != 0) {
|
|
254 |
qWarning() << "gcc returned with" << proc.exitCode();
|
|
255 |
qDebug() << proc.readAllStandardError();
|
|
256 |
return QBic::Info();
|
|
257 |
}
|
|
258 |
|
|
259 |
QString errs = QString::fromLocal8Bit(proc.readAllStandardError().constData());
|
|
260 |
if (!errs.isEmpty()) {
|
|
261 |
qDebug() << "Arguments:" << args << "Warnings:" << errs;
|
|
262 |
return QBic::Info();
|
|
263 |
}
|
|
264 |
|
|
265 |
// See if we find the gcc output file, which seems to change
|
|
266 |
// from release to release
|
|
267 |
QStringList files = QDir().entryList(QStringList() << "*.class");
|
|
268 |
if (files.isEmpty()) {
|
|
269 |
qFatal("Could not locate the GCC output file, update this test");
|
|
270 |
return QBic::Info();
|
|
271 |
} else if (files.size() > 1) {
|
|
272 |
qDebug() << files;
|
|
273 |
qFatal("Located more than one output file, please clean up before running this test");
|
|
274 |
return QBic::Info();
|
|
275 |
}
|
|
276 |
|
|
277 |
QString resultFileName = files.first();
|
|
278 |
QBic::Info inf = bic.parseFile(resultFileName);
|
|
279 |
|
|
280 |
QFile::remove(resultFileName);
|
|
281 |
tmpQFile.close();
|
|
282 |
|
|
283 |
return inf;
|
|
284 |
}
|
|
285 |
|
|
286 |
void tst_Bic::sizesAndVTables()
|
|
287 |
{
|
|
288 |
#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL)
|
|
289 |
QSKIP("Test not implemented for this compiler/platform", SkipAll);
|
|
290 |
#else
|
|
291 |
|
|
292 |
QFETCH_GLOBAL(QString, libName);
|
|
293 |
QFETCH(QString, oldLib);
|
|
294 |
QFETCH(bool, isPatchRelease);
|
|
295 |
|
|
296 |
bool isFailed = false;
|
|
297 |
|
|
298 |
//qDebug() << oldLib.arg(libName);
|
|
299 |
if (oldLib.isEmpty() || !QFile::exists(oldLib.arg(libName)))
|
|
300 |
QSKIP("No platform spec found for this platform/version.", SkipSingle);
|
|
301 |
|
|
302 |
const QBic::Info oldLibInfo = bic.parseFile(oldLib.arg(libName));
|
|
303 |
QVERIFY(!oldLibInfo.classVTables.isEmpty());
|
|
304 |
|
|
305 |
const QBic::Info currentLibInfo = getCurrentInfo(libName);
|
|
306 |
QVERIFY(!currentLibInfo.classVTables.isEmpty());
|
|
307 |
|
|
308 |
QBic::VTableDiff diff = bic.diffVTables(oldLibInfo, currentLibInfo);
|
|
309 |
|
|
310 |
if (!diff.removedVTables.isEmpty()) {
|
|
311 |
qWarning() << "VTables for the following classes were removed" << diff.removedVTables;
|
|
312 |
isFailed = true;
|
|
313 |
}
|
|
314 |
|
|
315 |
if (!diff.modifiedVTables.isEmpty()) {
|
|
316 |
foreach(QStringPair entry, diff.modifiedVTables)
|
|
317 |
qWarning() << "modified VTable:\n Old: " << entry.first
|
|
318 |
<< "\n New: " << entry.second;
|
|
319 |
isFailed = true;
|
|
320 |
}
|
|
321 |
|
|
322 |
if (isPatchRelease && !diff.addedVTables.isEmpty()) {
|
|
323 |
qWarning() << "VTables for the following classes were added in a patch release:"
|
|
324 |
<< diff.addedVTables;
|
|
325 |
isFailed = true;
|
|
326 |
}
|
|
327 |
|
|
328 |
if (isPatchRelease && !diff.reimpMethods.isEmpty()) {
|
|
329 |
foreach(QStringPair entry, diff.reimpMethods)
|
|
330 |
qWarning() << "reimplemented virtual in patch release:\n Old: " << entry.first
|
|
331 |
<< "\n New: " << entry.second;
|
|
332 |
isFailed = true;
|
|
333 |
}
|
|
334 |
|
|
335 |
QBic::SizeDiff sizeDiff = bic.diffSizes(oldLibInfo, currentLibInfo);
|
|
336 |
if (!sizeDiff.mismatch.isEmpty()) {
|
|
337 |
foreach (QString className, sizeDiff.mismatch)
|
|
338 |
qWarning() << "size mismatch for" << className
|
|
339 |
<< "old" << oldLibInfo.classSizes.value(className)
|
|
340 |
<< "new" << currentLibInfo.classSizes.value(className);
|
|
341 |
isFailed = true;
|
|
342 |
}
|
|
343 |
|
|
344 |
#ifdef Q_CC_MINGW
|
|
345 |
/**
|
|
346 |
* These symbols are from Windows' imm.h header, and is available
|
|
347 |
* conditionally depending on the value of the WINVER define. We pull
|
|
348 |
* them out since they're not relevant to the testing done.
|
|
349 |
*/
|
|
350 |
sizeDiff.removed.removeAll(QLatin1String("tagIMECHARPOSITION"));
|
|
351 |
sizeDiff.removed.removeAll(QLatin1String("tagRECONVERTSTRING"));
|
|
352 |
#endif
|
|
353 |
|
|
354 |
if (!sizeDiff.removed.isEmpty()) {
|
|
355 |
qWarning() << "the following classes were removed:" << sizeDiff.removed;
|
|
356 |
isFailed = true;
|
|
357 |
}
|
|
358 |
|
|
359 |
if (isPatchRelease && !sizeDiff.added.isEmpty()) {
|
|
360 |
qWarning() << "the following classes were added in a patch release:" << sizeDiff.added;
|
|
361 |
isFailed = true;
|
|
362 |
}
|
|
363 |
|
|
364 |
if (isFailed)
|
|
365 |
QFAIL("Test failed, read warnings above.");
|
|
366 |
#endif
|
|
367 |
}
|
|
368 |
|
|
369 |
QTEST_APPLESS_MAIN(tst_Bic)
|
|
370 |
|
|
371 |
#include "tst_bic.moc"
|
|
372 |
#endif
|