diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2022-02-21 14:54:52 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-02 14:06:24 +0000 |
commit | 8496fb484c7941d96782232dacc9dc4e5617fdfd (patch) | |
tree | ba46733bd11c2d2453c641ba0209e37c68d37f5d /tests | |
parent | 7dd2c28120ff3af9f140af6860681d4321878a73 (diff) |
Activate tst_qxmlstream for Android
tst_qxmlstream was disabled because it crashed. It does not any more.
But it extracted an input zip archive in-place, which is not
possible on Android. To resolve this, input files are
copied to a temporary directory first.
Also, input directories were given to rcc. rcc has a problem
with recursive directories. To circumvent this,
the file list is created in CMake and then given to rcc.
Task-number: QTBUG-87671
Change-Id: I88bb823b9e5c085404e263d4a648d65c9cd6024c
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
(cherry picked from commit 5a8052f9c1d8525b62248d7fcc2b292b2bac24f8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
3 files changed, 42 insertions, 11 deletions
diff --git a/tests/auto/corelib/serialization/CMakeLists.txt b/tests/auto/corelib/serialization/CMakeLists.txt index 576261fcfe..53f59dc1a5 100644 --- a/tests/auto/corelib/serialization/CMakeLists.txt +++ b/tests/auto/corelib/serialization/CMakeLists.txt @@ -12,7 +12,6 @@ endif() if(TARGET Qt::Network) add_subdirectory(qtextstream) endif() -# QTBUG-87671 # special case -if(TARGET Qt::Network AND TARGET Qt::Xml AND NOT ANDROID AND NOT INTEGRITY) +if(TARGET Qt::Network AND TARGET Qt::Xml AND NOT INTEGRITY) add_subdirectory(qxmlstream) endif() diff --git a/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt b/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt index ab20f4d49e..f3602c92fb 100644 --- a/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt +++ b/tests/auto/corelib/serialization/qxmlstream/CMakeLists.txt @@ -5,8 +5,9 @@ ##################################################################### # Collect test data -list(APPEND test_data "data") -list(APPEND test_data "XML-Test-Suite") +file(GLOB_RECURSE test_data + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + data/* XML-Test-Suite/*) qt_internal_add_test(tst_qxmlstream SOURCES diff --git a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp index f32e044de6..7db4b73fc8 100644 --- a/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/serialization/qxmlstream/tst_qxmlstream.cpp @@ -46,6 +46,7 @@ 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 xmlTestsuiteDir = "XML-Test-Suite"; static const char *const xmlconfDir = "XML-Test-Suite/xmlconf/"; static const char *const xmlDatasetName = "xmltest"; static const char *const updateFilesDir = "xmltest_updates"; @@ -71,6 +72,28 @@ static inline int best(int a, int b, int c) return qMin(qMin(a, b), c); } +// copied from tst_qmake.cpp +static void copyDir(const QString &sourceDirPath, const QString &targetDirPath) +{ + QDir currentDir; + QDirIterator dit(sourceDirPath, QDir::Dirs | QDir::NoDotAndDotDot | QDir::Hidden); + while (dit.hasNext()) { + dit.next(); + const QString targetPath = targetDirPath + QLatin1Char('/') + dit.fileName(); + currentDir.mkpath(targetPath); + copyDir(dit.filePath(), targetPath); + } + + QDirIterator fit(sourceDirPath, QDir::Files | QDir::Hidden); + while (fit.hasNext()) { + fit.next(); + const QString targetPath = targetDirPath + QLatin1Char('/') + fit.fileName(); + QFile::remove(targetPath); // allowed to fail + QFile src(fit.filePath()); + QVERIFY2(src.copy(targetPath), qPrintable(src.errorString())); + } +} + template <typename C> const C sorted_by_name(C c) { // return by const value so we can feed directly into range-for loops below using T = typename C::value_type; @@ -535,7 +558,7 @@ class tst_QXmlStream: public QObject { Q_OBJECT public: - tst_QXmlStream() : m_handler(QUrl::fromLocalFile(QFINDTESTDATA(catalogFile))) + tst_QXmlStream() : m_handler(QUrl::fromLocalFile(m_tempDir.filePath(catalogFile))) { } @@ -589,6 +612,7 @@ private slots: private: static QByteArray readFile(const QString &filename); + QTemporaryDir m_tempDir; TestSuiteHandler m_handler; }; @@ -598,8 +622,18 @@ void tst_QXmlStream::initTestCase() // 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"); + + // On Android, we cannot unzip at the resource location, so we copy + // everything to a temporary directory first. + const QString XML_Test_Suite_dir = QFINDTESTDATA(xmlTestsuiteDir); + const QString XML_Test_Suite_destDir = m_tempDir.filePath(xmlTestsuiteDir); + copyDir(XML_Test_Suite_dir, XML_Test_Suite_destDir); + + + const QString filesDir(m_tempDir.filePath(xmlconfDir)); + const QString fileName = filesDir + xmlDatasetName + ".zip"; + QVERIFY(QFile::exists(fileName)); + QZipReader reader(fileName); QVERIFY(reader.isReadable()); QVERIFY(reader.extractAll(filesDir)); // update files @@ -612,7 +646,7 @@ void tst_QXmlStream::initTestCase() QVERIFY(QFile::copy(fileInfo.filePath(), destinationPath)); } - QFile file(QFINDTESTDATA(catalogFile)); + QFile file(m_tempDir.filePath(catalogFile)); QVERIFY2(file.open(QIODevice::ReadOnly), qPrintable(QString::fromLatin1("Failed to open the test suite catalog; %1").arg(file.fileName()))); @@ -621,9 +655,6 @@ void tst_QXmlStream::initTestCase() void tst_QXmlStream::cleanupTestCase() { - QDir d(QFINDTESTDATA(xmlconfDir) + xmlDatasetName); - d.removeRecursively(); - QFile::remove(QLatin1String("test.xml")); } void tst_QXmlStream::reportFailures() const |