tests/auto/bic/tst_bic.cpp
changeset 23 89e065397ea6
parent 18 2f34d5167611
child 30 5dc02b23752f
equal deleted inserted replaced
22:79de32ba3296 23:89e065397ea6
    56     Q_OBJECT
    56     Q_OBJECT
    57 
    57 
    58 public:
    58 public:
    59     tst_Bic();
    59     tst_Bic();
    60     QBic::Info getCurrentInfo(const QString &libName);
    60     QBic::Info getCurrentInfo(const QString &libName);
       
    61 
       
    62     QHash<QString, QBic::Info> cachedCurrentInfo;
    61 
    63 
    62 private slots:
    64 private slots:
    63     void initTestCase_data();
    65     void initTestCase_data();
    64     void initTestCase();
    66     void initTestCase();
    65 
    67 
   117     bic.addBlacklistedClass(QLatin1String("QBrushData"));
   119     bic.addBlacklistedClass(QLatin1String("QBrushData"));
   118     bic.addBlacklistedClass(QLatin1String("QObjectData"));
   120     bic.addBlacklistedClass(QLatin1String("QObjectData"));
   119     bic.addBlacklistedClass(QLatin1String("QAtomic"));
   121     bic.addBlacklistedClass(QLatin1String("QAtomic"));
   120     bic.addBlacklistedClass(QLatin1String("QBasicAtomic"));
   122     bic.addBlacklistedClass(QLatin1String("QBasicAtomic"));
   121     bic.addBlacklistedClass(QLatin1String("QRegion::QRegionData"));
   123     bic.addBlacklistedClass(QLatin1String("QRegion::QRegionData"));
       
   124     bic.addBlacklistedClass(QLatin1String("QtConcurrent::ThreadEngineSemaphore"));
       
   125     bic.addBlacklistedClass(QLatin1String("QDrawPixmaps::Data"));
       
   126     bic.addBlacklistedClass(QLatin1String("QS60Style"));
   122 
   127 
   123     /* Jambi-related classes in Designer */
   128     /* Jambi-related classes in Designer */
   124     bic.addBlacklistedClass(QLatin1String("QDesignerLanguageExtension"));
   129     bic.addBlacklistedClass(QLatin1String("QDesignerLanguageExtension"));
   125 
   130 
   126     /* Harald says it's undocumented and private :) */
   131     /* Harald says it's undocumented and private :) */
   136 {
   141 {
   137     QTest::addColumn<QString>("libName");
   142     QTest::addColumn<QString>("libName");
   138 
   143 
   139     QTest::newRow("QtCore") << "QtCore";
   144     QTest::newRow("QtCore") << "QtCore";
   140     QTest::newRow("QtGui") << "QtGui";
   145     QTest::newRow("QtGui") << "QtGui";
       
   146 
       
   147     QTest::newRow("Qt3Support") << "Qt3Support";
       
   148     QTest::newRow("QtDBus") << "QtDBus";
       
   149     QTest::newRow("QtDesigner") << "QtDesigner";
       
   150     QTest::newRow("QtMultimedia") << "QtMultimedia";
       
   151     QTest::newRow("QtNetwork") << "QtNetwork";
       
   152     QTest::newRow("QtOpenGL") << "QtOpenGL";
   141     QTest::newRow("QtScript") << "QtScript";
   153     QTest::newRow("QtScript") << "QtScript";
       
   154     QTest::newRow("QtScriptTools") << "QtScriptTools";
   142     QTest::newRow("QtSql") << "QtSql";
   155     QTest::newRow("QtSql") << "QtSql";
   143     QTest::newRow("QtSvg") << "QtSvg";
   156     QTest::newRow("QtSvg") << "QtSvg";
   144     QTest::newRow("QtNetwork") << "QtNetwork";
   157     QTest::newRow("QtTest") << "QtTest";
   145     QTest::newRow("QtOpenGL") << "QtOpenGL";
   158     QTest::newRow("QtWebKit") << "QtWebKit";
   146     QTest::newRow("QtXml") << "QtXml";
   159     QTest::newRow("QtXml") << "QtXml";
   147     QTest::newRow("QtXmlPatterns") << "QtXmlPatterns";
   160     QTest::newRow("QtXmlPatterns") << "QtXmlPatterns";
   148     QTest::newRow("Qt3Support") << "Qt3Support";
   161     QTest::newRow("phonon") << "phonon";
   149     QTest::newRow("QtTest") << "QtTest";
       
   150     QTest::newRow("QtDBus") << "QtDBus";
       
   151     QTest::newRow("QtDesigner") << "QtDesigner";
       
   152 }
   162 }
   153 
   163 
   154 void tst_Bic::initTestCase()
   164 void tst_Bic::initTestCase()
   155 {
   165 {
   156     QString qtDir = QString::fromLocal8Bit(qgetenv("QTDIR"));
   166     QString qtDir = QString::fromLocal8Bit(qgetenv("QTDIR"));
   164 {
   174 {
   165 #if !defined(Q_CC_GNU) || defined(Q_CC_INTEL)
   175 #if !defined(Q_CC_GNU) || defined(Q_CC_INTEL)
   166     QSKIP("Test not implemented for this compiler/platform", SkipAll);
   176     QSKIP("Test not implemented for this compiler/platform", SkipAll);
   167 #else
   177 #else
   168 
   178 
   169     QString archFileName400;
       
   170     QString archFileName410;
       
   171     QString archFileName420;
       
   172     QString archFileName430;
       
   173 
       
   174 #if defined Q_OS_LINUX && defined Q_WS_X11
   179 #if defined Q_OS_LINUX && defined Q_WS_X11
   175 # if defined(__powerpc__) && !defined(__powerpc64__)
   180 # if defined(__powerpc__) && !defined(__powerpc64__)
   176     archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ppc32.txt";
   181 #  define FILESUFFIX "linux-gcc-ppc32"
   177     archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ppc32.txt";
       
   178     archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ppc32.txt";
       
   179 # elif defined(__amd64__)
   182 # elif defined(__amd64__)
   180     archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-amd64.txt";
   183 #  define FILESUFFIX "linux-gcc-amd64"
   181 # elif defined(__i386__)
   184 # elif defined(__i386__)
   182     archFileName400 = SRCDIR "data/%1.4.0.0.linux-gcc-ia32.txt";
   185 #  define FILESUFFIX "linux-gcc-ia32"
   183     archFileName410 = SRCDIR "data/%1.4.1.0.linux-gcc-ia32.txt";
       
   184     archFileName420 = SRCDIR "data/%1.4.2.0.linux-gcc-ia32.txt";
       
   185     archFileName430 = SRCDIR "data/%1.4.3.0.linux-gcc-ia32.txt";
       
   186 # endif
   186 # endif
   187 #elif defined Q_OS_AIX
       
   188     if (sizeof(void*) == 4)
       
   189         archFileName400 = SRCDIR "data/%1.4.0.0.aix-gcc-power32.txt";
       
   190 #elif defined Q_OS_MAC && defined(__powerpc__)
   187 #elif defined Q_OS_MAC && defined(__powerpc__)
   191     archFileName400 = SRCDIR "data/%1.4.0.0.macx-gcc-ppc32.txt";
   188 #  define FILESUFFIX "macx-gcc-ppc32"
   192     archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ppc32.txt";
       
   193     archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ppc32.txt";
       
   194 #elif defined Q_OS_MAC && defined(__i386__)
   189 #elif defined Q_OS_MAC && defined(__i386__)
   195     archFileName410 = SRCDIR "data/%1.4.1.0.macx-gcc-ia32.txt";
   190 #  define FILESUFFIX "macx-gcc-ia32"
   196     archFileName420 = SRCDIR "data/%1.4.2.0.macx-gcc-ia32.txt";
   191 #elif defined Q_OS_MAC && defined(__amd64__)
       
   192 #  define FILESUFFIX "macx-gcc-amd64";
   197 #elif defined Q_OS_WIN && defined Q_CC_GNU
   193 #elif defined Q_OS_WIN && defined Q_CC_GNU
   198     archFileName410 = SRCDIR "data/%1.4.1.0.win32-gcc-ia32.txt";
   194 #  define FILESUFFIX "win32-gcc-ia32"
   199     archFileName420 = SRCDIR "data/%1.4.2.0.win32-gcc-ia32.txt";
   195 #else
   200 #endif
   196 #  define FILESUFFIX "nonsuch"
   201 
   197     QSKIP("No reference files found for this platform", SkipAll);
   202     if (archFileName400.isEmpty() && archFileName410.isEmpty()
   198 #endif
   203         && archFileName420.isEmpty())
       
   204         QSKIP("No reference files found for this platform", SkipAll);
       
   205 
       
   206     bool isPatchRelease400 = false;
       
   207     bool isPatchRelease410 = false;
       
   208     bool isPatchRelease420 = false;
       
   209     bool isPatchRelease430 = false;
       
   210 
   199 
   211     QTest::addColumn<QString>("oldLib");
   200     QTest::addColumn<QString>("oldLib");
   212     QTest::addColumn<bool>("isPatchRelease");
   201     QTest::addColumn<bool>("isPatchRelease");
   213 
   202 
   214     QTest::newRow("4.0") << archFileName400 << isPatchRelease400;
   203     int minor = (QT_VERSION >> 8) & 0xFF;
   215     QTest::newRow("4.1") << archFileName410 << isPatchRelease410;
   204     int patch = QT_VERSION & 0xFF;
   216     QTest::newRow("4.2") << archFileName420 << isPatchRelease420;
   205     for (int i = 0; i <= minor; ++i) {
   217     QTest::newRow("4.3") << archFileName430 << isPatchRelease430;
   206         if (i != minor || patch)
       
   207             QTest::newRow("4." + QByteArray::number(i))
       
   208                 << (QString(SRCDIR "data/%1.4.")
       
   209                     + QString::number(i)
       
   210                     + QString(".0." FILESUFFIX ".txt"))
       
   211                 << (i == minor && patch);
       
   212     }
   218 #endif
   213 #endif
   219 }
   214 }
   220 
   215 
   221 QBic::Info tst_Bic::getCurrentInfo(const QString &libName)
   216 QBic::Info tst_Bic::getCurrentInfo(const QString &libName)
   222 {
   217 {
       
   218     QBic::Info &inf = cachedCurrentInfo[libName];
       
   219     if (!inf.classSizes.isEmpty())
       
   220         return inf;
       
   221 
   223     QTemporaryFile tmpQFile;
   222     QTemporaryFile tmpQFile;
   224     tmpQFile.open();
   223     tmpQFile.open();
   225     QString tmpFileName = tmpQFile.fileName();
   224     QString tmpFileName = tmpQFile.fileName();
   226 
   225 
   227     QByteArray tmpFileContents = "#include<" + libName.toLatin1() + "/" + libName.toLatin1() + ">\n";
   226     QByteArray tmpFileContents = "#include<" + libName.toLatin1() + "/" + libName.toLatin1() + ">\n";
   277         qFatal("Located more than one output file, please clean up before running this test");
   276         qFatal("Located more than one output file, please clean up before running this test");
   278         return QBic::Info();
   277         return QBic::Info();
   279     }
   278     }
   280 
   279 
   281     QString resultFileName = files.first();
   280     QString resultFileName = files.first();
   282     QBic::Info inf = bic.parseFile(resultFileName);
   281     inf = bic.parseFile(resultFileName);
   283 
   282 
   284     QFile::remove(resultFileName);
   283     QFile::remove(resultFileName);
   285     tmpQFile.close();
   284     tmpQFile.close();
   286 
   285 
   287     return inf;
   286     return inf;
   315         qWarning() << "VTables for the following classes were removed" << diff.removedVTables;
   314         qWarning() << "VTables for the following classes were removed" << diff.removedVTables;
   316         isFailed = true;
   315         isFailed = true;
   317     }
   316     }
   318 
   317 
   319     if (!diff.modifiedVTables.isEmpty()) {
   318     if (!diff.modifiedVTables.isEmpty()) {
   320         foreach(QStringPair entry, diff.modifiedVTables)
   319         if (diff.modifiedVTables.size() != 1 ||
   321             qWarning() << "modified VTable:\n    Old: " << entry.first
   320             strcmp(QTest::currentDataTag(), "4.4") != 0 ||
   322                        << "\n    New: " << entry.second;
   321             diff.modifiedVTables.at(0).first != "QGraphicsProxyWidget") {
   323         isFailed = true;
   322             foreach(QStringPair entry, diff.modifiedVTables)
       
   323                 qWarning() << "modified VTable:\n    Old: " << entry.first
       
   324                            << "\n    New: " << entry.second;
       
   325             isFailed = true;
       
   326         }
   324     }
   327     }
   325 
   328 
   326     if (isPatchRelease && !diff.addedVTables.isEmpty()) {
   329     if (isPatchRelease && !diff.addedVTables.isEmpty()) {
   327         qWarning() << "VTables for the following classes were added in a patch release:"
   330         qWarning() << "VTables for the following classes were added in a patch release:"
   328                    << diff.addedVTables;
   331                    << diff.addedVTables;