CI: Enable tests under corelib/serialization for Wasm platform
Add more tests on WebAssembly platform for better tests coverage. Change-Id: Iaaaa824ae6058a9ae5dba4c4038a7f687bfc17e0 Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
This commit is contained in:
parent
8eca7fffa3
commit
592f8630c6
55
src/3rdparty/tinycbor/tests/encoder/data.cpp
vendored
55
src/3rdparty/tinycbor/tests/encoder/data.cpp
vendored
@ -24,7 +24,29 @@
|
|||||||
|
|
||||||
#include <QtTest>
|
#include <QtTest>
|
||||||
|
|
||||||
static float myNaNf()
|
struct NegativeInteger { quint64 abs; };
|
||||||
|
Q_DECLARE_METATYPE(NegativeInteger)
|
||||||
|
|
||||||
|
struct SimpleType { uint8_t type; };
|
||||||
|
Q_DECLARE_METATYPE(SimpleType)
|
||||||
|
|
||||||
|
struct Float16Standin { uint16_t val; };
|
||||||
|
Q_DECLARE_METATYPE(Float16Standin)
|
||||||
|
|
||||||
|
struct Tag { CborTag tag; QVariant tagged; };
|
||||||
|
Q_DECLARE_METATYPE(Tag)
|
||||||
|
|
||||||
|
typedef QVector<QPair<QVariant, QVariant>> Map;
|
||||||
|
Q_DECLARE_METATYPE(Map)
|
||||||
|
|
||||||
|
struct IndeterminateLengthArray : QVariantList { using QVariantList::QVariantList; };
|
||||||
|
struct IndeterminateLengthMap : Map { using Map::Map; };
|
||||||
|
Q_DECLARE_METATYPE(IndeterminateLengthArray)
|
||||||
|
Q_DECLARE_METATYPE(IndeterminateLengthMap)
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
float myNaNf()
|
||||||
{
|
{
|
||||||
uint32_t v = 0x7fc00000;
|
uint32_t v = 0x7fc00000;
|
||||||
float f;
|
float f;
|
||||||
@ -33,7 +55,7 @@ static float myNaNf()
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float myInff()
|
float myInff()
|
||||||
{
|
{
|
||||||
uint32_t v = 0x7f800000;
|
uint32_t v = 0x7f800000;
|
||||||
float f;
|
float f;
|
||||||
@ -42,7 +64,7 @@ static float myInff()
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float myNInff()
|
float myNInff()
|
||||||
{
|
{
|
||||||
uint32_t v = 0xff800000;
|
uint32_t v = 0xff800000;
|
||||||
float f;
|
float f;
|
||||||
@ -51,7 +73,7 @@ static float myNInff()
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double myNaN()
|
double myNaN()
|
||||||
{
|
{
|
||||||
uint64_t v = UINT64_C(0x7ff8000000000000);
|
uint64_t v = UINT64_C(0x7ff8000000000000);
|
||||||
double f;
|
double f;
|
||||||
@ -60,7 +82,7 @@ static double myNaN()
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double myInf()
|
double myInf()
|
||||||
{
|
{
|
||||||
uint64_t v = UINT64_C(0x7ff0000000000000);
|
uint64_t v = UINT64_C(0x7ff0000000000000);
|
||||||
double f;
|
double f;
|
||||||
@ -69,7 +91,7 @@ static double myInf()
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static double myNInf()
|
double myNInf()
|
||||||
{
|
{
|
||||||
uint64_t v = UINT64_C(0xfff0000000000000);
|
uint64_t v = UINT64_C(0xfff0000000000000);
|
||||||
double f;
|
double f;
|
||||||
@ -83,36 +105,17 @@ template <size_t N> QByteArray raw(const char (&data)[N])
|
|||||||
return QByteArray::fromRawData(data, N - 1);
|
return QByteArray::fromRawData(data, N - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NegativeInteger { quint64 abs; };
|
|
||||||
Q_DECLARE_METATYPE(NegativeInteger)
|
|
||||||
|
|
||||||
struct SimpleType { uint8_t type; };
|
|
||||||
Q_DECLARE_METATYPE(SimpleType)
|
|
||||||
|
|
||||||
struct Float16Standin { uint16_t val; };
|
|
||||||
Q_DECLARE_METATYPE(Float16Standin)
|
|
||||||
|
|
||||||
struct Tag { CborTag tag; QVariant tagged; };
|
|
||||||
Q_DECLARE_METATYPE(Tag)
|
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
QVariant make_list(const Args &... args)
|
QVariant make_list(const Args &... args)
|
||||||
{
|
{
|
||||||
return QVariantList{args...};
|
return QVariantList{args...};
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef QVector<QPair<QVariant, QVariant>> Map;
|
|
||||||
Q_DECLARE_METATYPE(Map)
|
|
||||||
QVariant make_map(const std::initializer_list<QPair<QVariant, QVariant>> &list)
|
QVariant make_map(const std::initializer_list<QPair<QVariant, QVariant>> &list)
|
||||||
{
|
{
|
||||||
return QVariant::fromValue(Map(list));
|
return QVariant::fromValue(Map(list));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IndeterminateLengthArray : QVariantList { using QVariantList::QVariantList; };
|
|
||||||
struct IndeterminateLengthMap : Map { using Map::Map; };
|
|
||||||
Q_DECLARE_METATYPE(IndeterminateLengthArray)
|
|
||||||
Q_DECLARE_METATYPE(IndeterminateLengthMap)
|
|
||||||
|
|
||||||
QVariant make_ilarray(const std::initializer_list<QVariant> &list)
|
QVariant make_ilarray(const std::initializer_list<QVariant> &list)
|
||||||
{
|
{
|
||||||
return QVariant::fromValue(IndeterminateLengthArray(list));
|
return QVariant::fromValue(IndeterminateLengthArray(list));
|
||||||
@ -343,4 +346,4 @@ void addArraysAndMaps()
|
|||||||
QTest::newRow("array-1(map)") << raw("\x81\xc1\xa0") << make_list(QVariant::fromValue(Tag{1, make_map({})}));
|
QTest::newRow("array-1(map)") << raw("\x81\xc1\xa0") << make_list(QVariant::fromValue(Tag{1, make_map({})}));
|
||||||
QTest::newRow("map-1(2):3(4)") << raw("\xa1\xc1\2\xc3\4") << make_map({{QVariant::fromValue(Tag{1, 2}), QVariant::fromValue(Tag{3, 4})}});
|
QTest::newRow("map-1(2):3(4)") << raw("\xa1\xc1\2\xc3\4") << make_map({{QVariant::fromValue(Tag{1, 2}), QVariant::fromValue(Tag{3, 4})}});
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
3
src/3rdparty/tinycbor/tests/parser/data.cpp
vendored
3
src/3rdparty/tinycbor/tests/parser/data.cpp
vendored
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
Q_DECLARE_METATYPE(CborError)
|
Q_DECLARE_METATYPE(CborError)
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
template <size_t N> QByteArray raw(const char (&data)[N])
|
template <size_t N> QByteArray raw(const char (&data)[N])
|
||||||
{
|
{
|
||||||
return QByteArray::fromRawData(data, N - 1);
|
return QByteArray::fromRawData(data, N - 1);
|
||||||
@ -605,3 +607,4 @@ void addValidationData(size_t minInvalid = ~size_t(0))
|
|||||||
// This test technically tests the dumper, not the parser.
|
// This test technically tests the dumper, not the parser.
|
||||||
QTest::newRow("string-utf8-chunk-split") << raw("\x81\x7f\x61\xc2\x61\xa0\xff") << 0 << CborErrorInvalidUtf8TextString;
|
QTest::newRow("string-utf8-chunk-split") << raw("\x81\x7f\x61\xc2\x61\xa0\xff") << 0 << CborErrorInvalidUtf8TextString;
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
@ -34,6 +34,7 @@ if(QT_BUILD_MINIMAL_ANDROID_MULTI_ABI_TESTS)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WASM)
|
if(WASM)
|
||||||
|
add_subdirectory(corelib/serialization)
|
||||||
add_subdirectory(corelib/text)
|
add_subdirectory(corelib/text)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
@ -13,6 +13,6 @@ endif()
|
|||||||
if(TARGET Qt::Network)
|
if(TARGET Qt::Network)
|
||||||
add_subdirectory(qtextstream)
|
add_subdirectory(qtextstream)
|
||||||
endif()
|
endif()
|
||||||
if(TARGET Qt::Gui AND TARGET Qt::Network AND TARGET Qt::Xml AND NOT INTEGRITY AND NOT QNX)
|
if(TARGET Qt::Gui AND TARGET Qt::Network AND TARGET Qt::Xml AND NOT INTEGRITY AND NOT QNX AND NOT WASM)
|
||||||
add_subdirectory(qxmlstream)
|
add_subdirectory(qxmlstream)
|
||||||
endif()
|
endif()
|
||||||
|
@ -26,7 +26,6 @@ protected:
|
|||||||
qint64 readData(char *data, qint64 maxlen) override;
|
qint64 readData(char *data, qint64 maxlen) override;
|
||||||
qint64 writeData(const char *, qint64) override { return -1; }
|
qint64 writeData(const char *, qint64) override { return -1; }
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
qint64 LargeIODevice::readData(char *data, qint64 maxlen)
|
qint64 LargeIODevice::readData(char *data, qint64 maxlen)
|
||||||
{
|
{
|
||||||
@ -118,3 +117,4 @@ void addValidationHugeDevice(qsizetype byteArrayInvalid, qsizetype stringInvalid
|
|||||||
addSize("4GB", quint64(1) << 32);
|
addSize("4GB", quint64(1) << 32);
|
||||||
addSize("max", std::numeric_limits<qint64>::max() - sizeof(buf));
|
addSize("max", std::numeric_limits<qint64>::max() - sizeof(buf));
|
||||||
}
|
}
|
||||||
|
} // namespace
|
||||||
|
@ -16,7 +16,7 @@ qt_internal_add_test(tst_qcborstreamreader
|
|||||||
tst_qcborstreamreader.cpp
|
tst_qcborstreamreader.cpp
|
||||||
INCLUDE_DIRECTORIES
|
INCLUDE_DIRECTORIES
|
||||||
../../../../../src/3rdparty/tinycbor/src
|
../../../../../src/3rdparty/tinycbor/src
|
||||||
../../../../../src/3rdparty/tinycbor/tests/parser
|
../../../../../src/3rdparty/tinycbor/tests
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
Qt::CorePrivate
|
Qt::CorePrivate
|
||||||
)
|
)
|
||||||
|
@ -88,7 +88,7 @@ template<> char *toString<QCborStreamReader::Type>(const QCborStreamReader::Type
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
// Get the data from TinyCBOR (see src/3rdparty/tinycbor/tests/parser/data.cpp)
|
// Get the data from TinyCBOR (see src/3rdparty/tinycbor/tests/parser/data.cpp)
|
||||||
#include "data.cpp"
|
#include "parser/data.cpp"
|
||||||
|
|
||||||
void tst_QCborStreamReader::initTestCase_data()
|
void tst_QCborStreamReader::initTestCase_data()
|
||||||
{
|
{
|
||||||
@ -927,6 +927,10 @@ void tst_QCborStreamReader::hugeDeviceValidation()
|
|||||||
QSKIP("This test tries to allocate a huge memory buffer,"
|
QSKIP("This test tries to allocate a huge memory buffer,"
|
||||||
" which Address Sanitizer flags as a problem");
|
" which Address Sanitizer flags as a problem");
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(Q_OS_WASM)
|
||||||
|
QSKIP("This test tries to allocate a huge memory buffer,"
|
||||||
|
" causes problem on WebAssembly platform which has limited resources.");
|
||||||
|
#endif // Q_OS_WASM
|
||||||
|
|
||||||
QFETCH(QSharedPointer<QIODevice>, device);
|
QFETCH(QSharedPointer<QIODevice>, device);
|
||||||
QFETCH(CborError, expectedError);
|
QFETCH(CborError, expectedError);
|
||||||
|
@ -15,5 +15,5 @@ qt_internal_add_test(tst_qcborstreamwriter
|
|||||||
SOURCES
|
SOURCES
|
||||||
tst_qcborstreamwriter.cpp
|
tst_qcborstreamwriter.cpp
|
||||||
INCLUDE_DIRECTORIES
|
INCLUDE_DIRECTORIES
|
||||||
../../../../../src/3rdparty/tinycbor/tests/encoder
|
../../../../../src/3rdparty/tinycbor/tests
|
||||||
)
|
)
|
||||||
|
@ -29,7 +29,7 @@ private Q_SLOTS:
|
|||||||
|
|
||||||
// Get the data from TinyCBOR (see src/3rdparty/tinycbor/tests/encoder/data.cpp)
|
// Get the data from TinyCBOR (see src/3rdparty/tinycbor/tests/encoder/data.cpp)
|
||||||
typedef quint64 CborTag;
|
typedef quint64 CborTag;
|
||||||
#include "data.cpp"
|
#include "encoder/data.cpp"
|
||||||
|
|
||||||
void encodeVariant(QCborStreamWriter &writer, const QVariant &v)
|
void encodeVariant(QCborStreamWriter &writer, const QVariant &v)
|
||||||
{
|
{
|
||||||
|
@ -2399,6 +2399,11 @@ void tst_QCborValue::hugeDeviceValidation_data()
|
|||||||
|
|
||||||
void tst_QCborValue::hugeDeviceValidation()
|
void tst_QCborValue::hugeDeviceValidation()
|
||||||
{
|
{
|
||||||
|
#if defined(Q_OS_WASM)
|
||||||
|
QSKIP("This test tries to allocate a huge memory buffer,"
|
||||||
|
" causes problem on WebAssembly platform which has limited resources.");
|
||||||
|
#endif // Q_OS_WASM
|
||||||
|
|
||||||
QFETCH(QSharedPointer<QIODevice>, device);
|
QFETCH(QSharedPointer<QIODevice>, device);
|
||||||
QFETCH(CborError, expectedError);
|
QFETCH(CborError, expectedError);
|
||||||
QCborError error = { QCborError::Code(expectedError) };
|
QCborError error = { QCborError::Code(expectedError) };
|
||||||
|
@ -3895,5 +3895,6 @@ void tst_QDataStream::typedefQt5Compat()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QDataStream)
|
QTEST_MAIN(tst_QDataStream)
|
||||||
|
|
||||||
#include "tst_qdatastream.moc"
|
#include "tst_qdatastream.moc"
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <QtGui/QPixmap>
|
#include <QtGui/QPixmap>
|
||||||
#include <QtGui/QImage>
|
#include <QtGui/QImage>
|
||||||
|
|
||||||
class tst_QDataStream : public QObject
|
class tst_QDataStreamPixmap : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ private slots:
|
|||||||
void stream_with_pixmap();
|
void stream_with_pixmap();
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QDataStream::stream_with_pixmap()
|
void tst_QDataStreamPixmap::stream_with_pixmap()
|
||||||
{
|
{
|
||||||
// This is a QVariantMap with a 3x3 red QPixmap and two strings inside
|
// This is a QVariantMap with a 3x3 red QPixmap and two strings inside
|
||||||
const QByteArray ba = QByteArray::fromBase64(
|
const QByteArray ba = QByteArray::fromBase64(
|
||||||
@ -37,6 +37,6 @@ void tst_QDataStream::stream_with_pixmap()
|
|||||||
QCOMPARE(map["z"].toString(), QString("there"));
|
QCOMPARE(map["z"].toString(), QString("there"));
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(tst_QDataStream)
|
QTEST_GUILESS_MAIN(tst_QDataStreamPixmap)
|
||||||
|
|
||||||
#include "tst_qdatastream_core_pixmap.moc"
|
#include "tst_qdatastream_core_pixmap.moc"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user