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 Pick-to: 6.2 6.3 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>
This commit is contained in:
parent
f8f8c38ec7
commit
5a8052f9c1
@ -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()
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user