From 33f65993866e3eb2a80001f1b53f38dbfc7017ce Mon Sep 17 00:00:00 2001 From: Honglei Zhang Date: Mon, 22 Aug 2011 14:42:41 +0300 Subject: Enable running of XQuery test suite Some xmlpatterns auto test cases are still using old script. And some small bugs in test driver prevent the XQuery test suite testing. This commit updated the out-of-date scripts and fixes couple of bugs in test driver. Task-number: QTBUG-16028 Reviewed-by: Dmitry Trofimov --- tests/auto/qxmlquery/tst_qxmlquery.cpp | 1 + tests/auto/qxmlstream/test.xml | 3 + tests/auto/xmlpatternsschemats/Baseline.xml | 2 +- tests/auto/xmlpatternsschemats/ReadMe.txt | 8 +++ .../xmlpatternsschemats/TESTSUITE/updateSuite.sh | 12 +++- tests/auto/xmlpatternssdk/TestSuite.cpp | 1 + tests/auto/xmlpatternssdk/TestSuiteHandler.cpp | 17 +++++ tests/auto/xmlpatternssdk/TestSuiteHandler.h | 4 ++ tests/auto/xmlpatternssdk/Worker.cpp | 2 +- tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp | 1 + tests/auto/xmlpatternsxqts/Baseline.xml | 2 - .../auto/xmlpatternsxqts/TESTSUITE/updateSuite.sh | 72 ++++++++++++++++++++++ tests/auto/xmlpatternsxqts/tst_suitetest.cpp | 5 +- tests/auto/xmlpatternsxqts/tst_xmlpatternsxqts.cpp | 26 +------- tests/auto/xmlpatternsxslts/XSLTS/updateSuite.sh | 17 +++-- 15 files changed, 133 insertions(+), 40 deletions(-) create mode 100644 tests/auto/qxmlstream/test.xml create mode 100644 tests/auto/xmlpatternsschemats/ReadMe.txt delete mode 100644 tests/auto/xmlpatternsxqts/Baseline.xml create mode 100755 tests/auto/xmlpatternsxqts/TESTSUITE/updateSuite.sh diff --git a/tests/auto/qxmlquery/tst_qxmlquery.cpp b/tests/auto/qxmlquery/tst_qxmlquery.cpp index 1d3a0bc..e443720 100644 --- a/tests/auto/qxmlquery/tst_qxmlquery.cpp +++ b/tests/auto/qxmlquery/tst_qxmlquery.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include "MessageSilencer.h" #include "MessageValidator.h" diff --git a/tests/auto/qxmlstream/test.xml b/tests/auto/qxmlstream/test.xml new file mode 100644 index 0000000..797fd3b --- /dev/null +++ b/tests/auto/qxmlstream/test.xml @@ -0,0 +1,3 @@ + + + diff --git a/tests/auto/xmlpatternsschemats/Baseline.xml b/tests/auto/xmlpatternsschemats/Baseline.xml index 9576538..16878bc 100644 --- a/tests/auto/xmlpatternsschemats/Baseline.xml +++ b/tests/auto/xmlpatternsschemats/Baseline.xml @@ -1,2 +1,2 @@ -

Patternist is an implementation written in C++ and with the Qt/KDE libraries. It is licensed under GNU LGPL and part of KDE, the K Desktop Environment.

XQuery
\ No newline at end of file +

Patternist is an implementation written in C++ and with the Qt/KDE libraries. It is licensed under GNU LGPL and part of KDE, the K Desktop Environment.

XQuery
\ No newline at end of file diff --git a/tests/auto/xmlpatternsschemats/ReadMe.txt b/tests/auto/xmlpatternsschemats/ReadMe.txt new file mode 100644 index 0000000..0bf6d17 --- /dev/null +++ b/tests/auto/xmlpatternsschemats/ReadMe.txt @@ -0,0 +1,8 @@ +This testing requires test suite which is available from w3c website. Download, unpack and transform the test suite will take quite long time. This test is normally skipped. To get the test run, following steps are required: + +- Linux environment is normally required to retrieve and prepare test suite +- wget, Java should be preinstalled +- install Saxon(version 9 or upwards) +- Run updateSuite.sh under TESTSUITE +- create file runTests in the same directory of auto test executable. For example: touch runTests + diff --git a/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh b/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh index 0297db5..a61f0a1 100755 --- a/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh +++ b/tests/auto/xmlpatternsschemats/TESTSUITE/updateSuite.sh @@ -44,6 +44,9 @@ # # NOTE: the files checked out CANNOT be added to Qt's # repository at the moment, due to legal complications. +# +# To run the script, Saxon package version 9 and above shall be installed +# DIRECTORY_NAME="xmlschema2006-11-06" ARCHIVE_NAME="xsts-2007-06-20.tar.gz" @@ -54,7 +57,10 @@ wget http://www.w3.org/XML/2004/xml-schema-test-suite/xmlschema2006-11-06/$ARCHI tar -xzf $ARCHIVE_NAME rm $ARCHIVE_NAME -CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs login -CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs checkout -d xmlschema2006-11-06-new XML/xml-schema-test-suite/2004-01-14/xmlschema2006-11-06 +# cvs script is used to retrive newer version of test suite. +#CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs login +#CVSROOT=:pserver:anonymous@dev.w3.org:/sources/public cvs checkout -d xmlschema2006-11-06-new XML/xml-schema-test-suite/2004-01-14/xmlschema2006-11-06 + +#Saxon need to be installed before the following command works. +java -jar /usr/share/java/saxon.jar -xsl:unifyCatalog.xsl -s:$DIRECTORY_NAME/suite.xml > testSuites.xml -java net.sf.saxon.Transform -xsl:unifyCatalog.xsl $DIRECTORY_NAME/suite.xml > testSuites.xml diff --git a/tests/auto/xmlpatternssdk/TestSuite.cpp b/tests/auto/xmlpatternssdk/TestSuite.cpp index e24786a..db94f25 100644 --- a/tests/auto/xmlpatternssdk/TestSuite.cpp +++ b/tests/auto/xmlpatternssdk/TestSuite.cpp @@ -151,6 +151,7 @@ TestSuite *TestSuite::openCatalog(QIODevice *input, } reader.setContentHandler(loader.data()); + reader.setEntityResolver(loader.data()); QXmlInputSource source(input); diff --git a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp index 74a6082..c46350a 100644 --- a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp +++ b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include #include "qacceltreeresourceloader_p.h" #include "qnetworkaccessdelegator_p.h" @@ -308,5 +309,21 @@ TestSuite *TestSuiteHandler::testSuite() const return m_ts; } +bool TestSuiteHandler::resolveEntity(const QString& publicId, + const QString& systemId, + QXmlInputSource*& ret) +{ + QFileInfo catFileName(m_catalogFile.path()); + QFileInfo externalFileName(catFileName.absolutePath(), systemId); + QFile *file = new QFile(externalFileName.absoluteFilePath()); + if (file->open(QIODevice::ReadOnly | QIODevice::Text)) { + ret = new QXmlInputSource(file); + return true; + } + return false; + //return QXmlDefaultHandler::resolveEntity(publicId, systemId, ret); +} + + // vim: et:ts=4:sw=4:sts=4 diff --git a/tests/auto/xmlpatternssdk/TestSuiteHandler.h b/tests/auto/xmlpatternssdk/TestSuiteHandler.h index 7a46145..2d6a22f 100644 --- a/tests/auto/xmlpatternssdk/TestSuiteHandler.h +++ b/tests/auto/xmlpatternssdk/TestSuiteHandler.h @@ -94,6 +94,10 @@ namespace QPatternistSDK const QString &qName, const QXmlAttributes &atts); + virtual bool resolveEntity(const QString& publicId, + const QString& systemId, + QXmlInputSource*& ret); + virtual TestSuite *testSuite() const; private: diff --git a/tests/auto/xmlpatternssdk/Worker.cpp b/tests/auto/xmlpatternssdk/Worker.cpp index f2051cc..4fb7da7 100644 --- a/tests/auto/xmlpatternssdk/Worker.cpp +++ b/tests/auto/xmlpatternssdk/Worker.cpp @@ -183,7 +183,7 @@ void Worker::threadFinished() const int totPass = count(m_result, TestResult::Pass); const int total = resultCount; const int notTested = m_notTested.count(); - const int percentage = int((static_cast(totPass) / total) * 100); + const int percentage = total==0 ? 0 : int((static_cast(totPass) / total) * 100); Q_ASSERT_X(percentage >= 0 && percentage <= 100, Q_FUNC_INFO, qPrintable(QString(QLatin1String("Percentage was: %1")).arg(percentage))); diff --git a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp index 5b6fb90..9036dad 100644 --- a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp +++ b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp @@ -793,6 +793,7 @@ XSDTestSuiteHandler::XSDTestSuiteHandler(const QUrl &catalogFile) : m_ts(0) << QLatin1String("schZ012_a") << QLatin1String("stZ041") << QLatin1String("wildZ010"); + } bool XSDTestSuiteHandler::startElement(const QString &namespaceURI, diff --git a/tests/auto/xmlpatternsxqts/Baseline.xml b/tests/auto/xmlpatternsxqts/Baseline.xml deleted file mode 100644 index d9be95a..0000000 --- a/tests/auto/xmlpatternsxqts/Baseline.xml +++ /dev/null @@ -1,2 +0,0 @@ - -

Patternist is an implementation written in C++ and with the Qt/KDE libraries. It is licensed under GNU LGPL and part of KDE, the K Desktop Environment.

XQuery
\ No newline at end of file diff --git a/tests/auto/xmlpatternsxqts/TESTSUITE/updateSuite.sh b/tests/auto/xmlpatternsxqts/TESTSUITE/updateSuite.sh new file mode 100755 index 0000000..1157f51 --- /dev/null +++ b/tests/auto/xmlpatternsxqts/TESTSUITE/updateSuite.sh @@ -0,0 +1,72 @@ +#!/bin/sh +############################################################################# +## +## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). +## All rights reserved. +## Contact: Nokia Corporation (qt-info@nokia.com) +## +## This file is the build configuration utility of the Qt Toolkit. +## +## $QT_BEGIN_LICENSE:LGPL$ +## GNU Lesser General Public License Usage +## This file may be used under the terms of the GNU Lesser General Public +## License version 2.1 as published by the Free Software Foundation and +## appearing in the file LICENSE.LGPL included in the packaging of this +## file. Please review the following information to ensure the GNU Lesser +## General Public License version 2.1 requirements will be met: +## http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +## +## In addition, as a special exception, Nokia gives you certain additional +## rights. These rights are described in the Nokia Qt LGPL Exception +## version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +## +## GNU General Public License Usage +## Alternatively, this file may be used under the terms of the GNU General +## Public License version 3.0 as published by the Free Software Foundation +## and appearing in the file LICENSE.GPL included in the packaging of this +## file. Please review the following information to ensure the GNU General +## Public License version 3.0 requirements will be met: +## http://www.gnu.org/copyleft/gpl.html. +## +## Other Usage +## Alternatively, this file may be used in accordance with the terms and +## conditions contained in a signed written agreement between you and Nokia. +## +## +## +## +## +## $QT_END_LICENSE$ +## +############################################################################# + +# This script updates the suite from W3C's CVS server. +# +# NOTE: the files checked out CANNOT be added to Qt's +# repository at the moment, due to legal complications. However, +# when the test suite is publically released, it is possible as +# according to W3C's usual license agreements. + +echo "*** This script typically doesn't need to be run." + +# There are two ways to retrieve test suites, via cvs or direct downloading. +# CVS always receive the latest release. + +# download test suite from http://dev.w3.org/2006/xquery-test-suite/ + +TMPFILE='tmpfile' +wget http://dev.w3.org/2006/xquery-test-suite/PublicPagesStagingArea/XQTS_1_0_3.zip -O $TMPFILE +unzip $TMPFILE +rm $TMPFILE + +# This is W3C's internal CVS server, not the public dev.w3.org. +# export CVSROOT=":pserver:anonymous@dev.w3.org:/sources/public" + +# echo "*** Enter 'anonymous' as password. ***" +# cvs login +# cvs get 2006/xquery-test-suite + +# Substitute entity values for entity references +mv XQTSCatalog.xml XQTSCatalogUnsolved.xml +xmllint -noent -output XQTSCatalog.xml XQTSCatalogUnsolved.xml + diff --git a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp index 76b7893..19adc0b 100644 --- a/tests/auto/xmlpatternsxqts/tst_suitetest.cpp +++ b/tests/auto/xmlpatternsxqts/tst_suitetest.cpp @@ -66,9 +66,6 @@ tst_SuiteTest::tst_SuiteTest(const SuiteType suiteType, /*! Returns an absolute path to the XQTS catalog, or flags a failure using QTestLib's mechanisms. - - Finding the location of the catalog is done with `p4 where` such that we don't have - to care about where it is checked out. */ void tst_SuiteTest::initTestCase() { @@ -87,7 +84,7 @@ void tst_SuiteTest::runTestSuite() const const QFileInfo fi(m_catalogPath); const QUrl catalogPath(QUrl::fromLocalFile(fi.absoluteFilePath())); - TestSuite::SuiteType suiteType; + TestSuite::SuiteType suiteType(TestSuite::XQuerySuite); switch (m_suiteType) { case XQuerySuite: suiteType = TestSuite::XQuerySuite; diff --git a/tests/auto/xmlpatternsxqts/tst_xmlpatternsxqts.cpp b/tests/auto/xmlpatternsxqts/tst_xmlpatternsxqts.cpp index ec14872..7caaf89 100644 --- a/tests/auto/xmlpatternsxqts/tst_xmlpatternsxqts.cpp +++ b/tests/auto/xmlpatternsxqts/tst_xmlpatternsxqts.cpp @@ -70,30 +70,8 @@ void tst_XmlPatternsXQTS::catalogPath(QString &write) const if(dontRun()) QSKIP("This test takes too long time to run on the majority of platforms.", SkipAll); - QProcess p4; - - QStringList arguments; - arguments << QLatin1String("where") - << QLatin1String("//depot/autotests/4.4/tests/auto/xmlpatternsxqts/XQTS/XQTSCatalog.xml"); - p4.start(QLatin1String("p4"), arguments); - QVERIFY(p4.waitForFinished()); - QCOMPARE(p4.exitCode(), 0); - QCOMPARE(p4.exitStatus(), QProcess::NormalExit); - - /* `p4 where' prints for instance: - * - * //depot/qt/4.4/tests/auto/xmlpatternsxqts/... //fenglich-englich/qt-4.4/tests/auto/xmlpatternsxqts/... /home/fenglich/dev/autotests/4.4/tests/auto/xmlpatternsxqts/XQTS/XQTSCatalog.xml - * - * so we want the last string. - */ - write = QString::fromLocal8Bit(p4.readAllStandardOutput()).split(QLatin1Char(' ')).last().trimmed(); - - if(write.isEmpty() || !QFile::exists(write)) - { - QEXPECT_FAIL("", "//depot/autotests/4.4/tests/auto/xmlpatternsxqts/XQTS/ must be part of the perforce client spec, " - "checked out at an arbitrary location, for this test to run. The test suite will now be skipped.", Abort); - QVERIFY(false); - } + write = QLatin1String("TESTSUITE/XQTSCatalog.xml"); + return; } QTEST_MAIN(tst_XmlPatternsXQTS) diff --git a/tests/auto/xmlpatternsxslts/XSLTS/updateSuite.sh b/tests/auto/xmlpatternsxslts/XSLTS/updateSuite.sh index 52a5b07..1bac5ec 100755 --- a/tests/auto/xmlpatternsxslts/XSLTS/updateSuite.sh +++ b/tests/auto/xmlpatternsxslts/XSLTS/updateSuite.sh @@ -47,14 +47,21 @@ # when the test suite is publically released, it is possible as # according to W3C's usual license agreements. -echo "*** This script typically doesn't need to be run, and it needs to be updated anyway." -exit 1 +echo "*** This script typically doesn't need to be run. Test Suite is not available. So, this test is only a place holder! ***" +exit 0 + +# Download the test suite +TMPFILE='tmpfile' +wget http://www.w3.org/Style/XSL/XSL-TestSuite.zip -O $TMPFILE +unzip $TMPFILE +rm $TMPFILE + # This is W3C's internal CVS server, not the public dev.w3.org. -export CVSROOT="fenglich@cvs.w3.org:path is currently unknown" +# export CVSROOT="fenglich@cvs.w3.org:path is currently unknown" -echo "*** Enter 'anonymous' as password. ***" -cvs login +# echo "*** Enter 'anonymous' as password. ***" +# cvs login mv catalog.xml catalogUnresolved.xml xmllint --noent --output catalog.xml catalogUnresolved.xml -- cgit v0.12