From 848af97440730afcfab2ea48ca0c483fe9a9bb43 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 15 Dec 2021 18:20:01 +0100 Subject: QXmlStreamReader: update test distribution As mentioned in the linked bugreport, we are not allowed to distribute the uncompressed files from one of the XML test datasets that we use in our tests. This patch removes the uncompressed version, and replaces it by the xmltest.zip archive taken from [0]. Once the test is started, QZipReader is used to uncompress the archive, and once the test is done, the uncompressed data is removed. However the test data from [0] is very old, so it is slightly different from what we had previously (the previous data was taken from w3c). As a result, 4 test cases are failing with this data. To fix it, we store the updated versions of 4 xml files separately, and replace them after uncompressing the archive. [0]: http://www.jclark.com/xml/ Fixes: QTBUG-81503 Change-Id: Ied5233970a529deebca56b1eab07fe1c328a2ee0 Reviewed-by: Lars Knoll Reviewed-by: Qt CI Bot (cherry picked from commit f8b74a49576ea453b3bfc7356a23cd4f2171fa76) Reviewed-by: Alex Blasche --- .../serialization/qxmlstream/tst_qxmlstream.cpp | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp') diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index 28922574b8..533fcd96f5 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -36,6 +36,9 @@ #include #include #include +#include +#include +#include #include "qc14n.h" @@ -44,6 +47,10 @@ Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour) static const char *const catalogFile = "XML-Test-Suite/xmlconf/finalCatalog.xml"; static const int expectedRunCount = 1646; static const int expectedSkipCount = 532; +static const char *const xmlconfDir = "XML-Test-Suite/xmlconf/"; +static const char *const xmlDatasetName = "xmltest"; +static const char *const updateFilesDir = "xmltest_updates"; +static const char *const destinationFolder = "/valid/sa/out/"; static inline int best(int a, int b) { @@ -591,6 +598,27 @@ private: void tst_QXmlStream::initTestCase() { +#ifdef Q_OS_WINRT + QSKIP("Skipping the tests because we cannot unzip the data archive from WinRT app"); +#endif + // Due to license restrictions, we need to distribute part of the test + // suit as a zip archive. So we need to unzip it before running the tests, + // and also update some files there. + // We also need to remove the unzipped data during cleanup. + const QString filesDir(QFINDTESTDATA(xmlconfDir)); + QZipReader reader(filesDir + xmlDatasetName + ".zip"); + QVERIFY(reader.isReadable()); + QVERIFY(reader.extractAll(filesDir)); + // update files + const auto files = + QDir(filesDir + updateFilesDir).entryInfoList(QDir::Files | QDir::NoDotAndDotDot); + for (const auto &fileInfo : files) { + const QString destinationPath = + filesDir + xmlDatasetName + destinationFolder + fileInfo.fileName(); + QFile::remove(destinationPath); // copy will fail if file exists + QVERIFY(QFile::copy(fileInfo.filePath(), destinationPath)); + } + QFile file(QFINDTESTDATA(catalogFile)); QVERIFY2(file.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Failed to open the test suite catalog; %1").arg(file.fileName()))); @@ -600,6 +628,8 @@ void tst_QXmlStream::initTestCase() void tst_QXmlStream::cleanupTestCase() { + QDir d(QFINDTESTDATA(xmlconfDir) + xmlDatasetName); + d.removeRecursively(); QFile::remove(QLatin1String("test.xml")); } -- cgit v1.2.1