diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-06-25 13:49:53 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-06-25 13:49:53 (GMT) |
commit | db8f05e257019694f5e8076845626008f2adc3dd (patch) | |
tree | 05d3959403cf15ac5f702091439e028af01f343b /tests/auto/selftests/tst_selftests.cpp | |
parent | 8aafaa65a1d16f8b982279f5aceedf1e281ddb5a (diff) | |
parent | 796a5a2c7d8c91a46ac761dde18b7da2ec6c177b (diff) | |
download | Qt-db8f05e257019694f5e8076845626008f2adc3dd.zip Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.gz Qt-db8f05e257019694f5e8076845626008f2adc3dd.tar.bz2 |
Merge commit 'qt/master-stable' into 4.6-stable
Bring Qt 4.6 into the Qt-S60 repo.
Conflicts:
configure.exe
mkspecs/features/qttest_p4.prf
qmake/generators/makefile.cpp
src/corelib/io/qdir.cpp
src/corelib/io/qprocess.h
src/corelib/kernel/qcoreevent.h
src/corelib/kernel/qobject.cpp
src/corelib/kernel/qsharedmemory_unix.cpp
src/corelib/thread/qthread_p.h
src/corelib/tools/qvector.h
src/gui/dialogs/qdialog.cpp
src/gui/dialogs/qfiledialog.cpp
src/gui/dialogs/qfiledialog_p.h
src/gui/dialogs/qmessagebox.cpp
src/gui/graphicsview/qgraphicsitem.cpp
src/gui/graphicsview/qgraphicsview.cpp
src/gui/image/qpixmapcache.cpp
src/gui/kernel/qapplication.cpp
src/gui/kernel/qapplication_p.h
src/gui/kernel/qwidget.cpp
src/gui/kernel/qwidget_p.h
src/gui/painting/qdrawhelper.cpp
src/gui/painting/qpaintengine_raster.cpp
src/gui/text/qfontengine_qpf.cpp
src/gui/widgets/qmenubar.cpp
src/network/socket/qlocalserver.cpp
src/testlib/qtestcase.cpp
src/testlib/testlib.pro
tests/auto/qimagereader/tst_qimagereader.cpp
tests/auto/qitemdelegate/tst_qitemdelegate.cpp
tests/auto/qnetworkreply/tst_qnetworkreply.cpp
tests/auto/qpixmap/qpixmap.pro
Diffstat (limited to 'tests/auto/selftests/tst_selftests.cpp')
-rw-r--r-- | tests/auto/selftests/tst_selftests.cpp | 99 |
1 files changed, 87 insertions, 12 deletions
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp index 6776b12..eca9aa6 100644 --- a/tests/auto/selftests/tst_selftests.cpp +++ b/tests/auto/selftests/tst_selftests.cpp @@ -54,9 +54,13 @@ private slots: void runSubTest(); void checkXML() const; void checkXML_data(); + void checkXunitxml() const; + void checkXunitxml_data(); private: QStringList m_checkXMLBlacklist; + QStringList m_checkXunitBlacklist; + void doRunSubTest(QString &subdir, QStringList &arguments ); }; struct BenchmarkResult @@ -97,7 +101,7 @@ inline bool qCompare variance = 0.001; } else if (r1.unit == "ticks") { - variance = 0.0001; + variance = 0.001; } if (variance == 0.) { /* No variance allowed - compare whole string */ @@ -186,17 +190,16 @@ void tst_Selftests::runSubTest_data() QTest::newRow("benchlibtickcounter") << "benchlibtickcounter" << QStringList("-tickcounter"); #endif + QTest::newRow("xunit") << "xunit" << QStringList("-xunitxml"); + } -void tst_Selftests::runSubTest() +void tst_Selftests::doRunSubTest(QString &subdir, QStringList &arguments ) { - QFETCH(QString, subdir); - QFETCH(QStringList, arguments); - QProcess proc; proc.setEnvironment(QStringList("")); proc.start(subdir + "/" + subdir, arguments); - QVERIFY(proc.waitForFinished()); + QVERIFY2(proc.waitForFinished(), qPrintable(proc.errorString())); const QByteArray out(proc.readAllStandardOutput()); const QByteArray err(proc.readAllStandardError()); @@ -206,8 +209,8 @@ void tst_Selftests::runSubTest() #if defined(Q_OS_WIN) if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus")) #endif - QVERIFY2(err.isEmpty(), err.constData()); - + if(subdir != QLatin1String("xunit")) + QVERIFY2(err.isEmpty(), err.constData()); QList<QByteArray> res = splitLines(out); QList<QByteArray> exp = expectedResult(subdir); @@ -255,8 +258,8 @@ void tst_Selftests::runSubTest() { if(output != expected && qstrcmp(QTest::currentDataTag(), "subtest") == 0) { - /* The floating point formatting differs between platforms, so let's just skip it. */ - continue; + /* The floating point formatting differs between platforms, so let's just skip it. */ + continue; } else { /* @@ -284,6 +287,14 @@ void tst_Selftests::runSubTest() } } +void tst_Selftests::runSubTest() +{ + QFETCH(QString, subdir); + QFETCH(QStringList, arguments); + + doRunSubTest(subdir, arguments); +} + void tst_Selftests::initTestCase() { m_checkXMLBlacklist.append("crashes"); // This test crashes @@ -300,6 +311,8 @@ void tst_Selftests::initTestCase() m_checkXMLBlacklist.append("subtest"); m_checkXMLBlacklist.append("globaldata"); m_checkXMLBlacklist.append("warnings"); + + m_checkXunitBlacklist = m_checkXMLBlacklist; } void tst_Selftests::checkXML() const @@ -310,7 +323,53 @@ void tst_Selftests::checkXML() const if(m_checkXMLBlacklist.contains(subdir)) return; - arguments.prepend("-xml"); + QStringList args; + /* Test both old (-flush) and new XML logger implementation */ + for (int i = 0; i < 2; ++i) { + bool flush = i; + args = arguments; + args.prepend("-xml"); + if (flush) args.prepend("-flush"); + + QProcess proc; + proc.setEnvironment(QStringList("")); + proc.start(subdir + "/" + subdir, args); + QVERIFY(proc.waitForFinished()); + + QByteArray out(proc.readAllStandardOutput()); + QByteArray err(proc.readAllStandardError()); + + /* Some platforms decides to output a message for uncaught exceptions. For instance, + * this is what windows platforms says: + * "This application has requested the Runtime to terminate it in an unusual way. + * Please contact the application's support team for more information." */ + if(subdir != QLatin1String("exception") && subdir != QLatin1String("fetchbogus")) + QVERIFY2(err.isEmpty(), err.constData()); + + QXmlStreamReader reader(out); + + while(!reader.atEnd()) + reader.readNext(); + + QVERIFY2(!reader.error(), qPrintable(QString("(flush %0) line %1, col %2: %3") + .arg(flush) + .arg(reader.lineNumber()) + .arg(reader.columnNumber()) + .arg(reader.errorString()) + )); + } +} + +void tst_Selftests::checkXunitxml() const +{ + QFETCH(QString, subdir); + QFETCH(QStringList, arguments); + + if(m_checkXunitBlacklist.contains(subdir)) + return; + + arguments.prepend("-xunitxml"); + arguments.prepend("-flush"); QProcess proc; proc.setEnvironment(QStringList("")); @@ -320,6 +379,8 @@ void tst_Selftests::checkXML() const QByteArray out(proc.readAllStandardOutput()); QByteArray err(proc.readAllStandardError()); +// qDebug()<<out; + /* Some platforms decides to output a message for uncaught exceptions. For instance, * this is what windows platforms says: * "This application has requested the Runtime to terminate it in an unusual way. @@ -332,12 +393,26 @@ void tst_Selftests::checkXML() const while(!reader.atEnd()) reader.readNext(); - QVERIFY(!reader.error()); + QVERIFY2(!reader.error(), qPrintable(QString("line %1, col %2: %3") + .arg(reader.lineNumber()) + .arg(reader.columnNumber()) + .arg(reader.errorString()) + )); +} + +void tst_Selftests::checkXunitxml_data() +{ + checkXML_data(); } void tst_Selftests::checkXML_data() { runSubTest_data(); + QTest::newRow("badxml 1") << "badxml" << QStringList(); + QTest::newRow("badxml 2") << "badxml" << (QStringList() << "-badstring" << "0"); + QTest::newRow("badxml 3") << "badxml" << (QStringList() << "-badstring" << "1"); + QTest::newRow("badxml 4") << "badxml" << (QStringList() << "-badstring" << "2"); + QTest::newRow("badxml 5") << "badxml" << (QStringList() << "-badstring" << "3"); } /* Parse line into the BenchmarkResult it represents. */ |