From 71a36d0b6576b2174b708a714f92bbbe1b309d05 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 10 Mar 2016 14:34:45 +0100 Subject: Disable tests requiring shared build when compiling statically Change-Id: I06ec53e46d2f61f1685899b0f8a4d385051095d6 Reviewed-by: Oliver Wolff --- tests/auto/corelib/plugin/plugin.pro | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/plugin/plugin.pro b/tests/auto/corelib/plugin/plugin.pro index 506f6abaeb..e132d9da1a 100644 --- a/tests/auto/corelib/plugin/plugin.pro +++ b/tests/auto/corelib/plugin/plugin.pro @@ -5,3 +5,9 @@ SUBDIRS=\ qplugin \ qpluginloader \ quuid + +contains(CONFIG, static) { + message(Disabling tests requiring shared build of Qt) + SUBDIRS -= qfactoryloader \ + qpluginloader +} -- cgit v1.2.3 From a8c72b7671637d18b1915d7e46fc601e8ffde2d7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 10 Mar 2016 16:35:53 +0100 Subject: tst_QTextStream::textModeOnEmptyRead(): Create file in temporary directory. A test should not write to its directory. Amends change d0b54cede8d8ea0b8431c64abb51d0cd1a71327b. Task-number: QTBUG-47176 Change-Id: If15258b4aed199792fab422b7ac1d74e22a9e322 Reviewed-by: Maurice Kalinowski --- tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index a0348f3c54..24dd05223f 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -3049,12 +3049,10 @@ void tst_QTextStream::int_write_with_locale() void tst_QTextStream::textModeOnEmptyRead() { - const QString filename("textmodetest.txt"); - QFile::remove(filename); // Remove file if exists - + const QString filename(tempDir.path() + QLatin1String("/textmodetest.txt")); QFile file(filename); - QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Text)); + QVERIFY2(file.open(QIODevice::ReadWrite | QIODevice::Text), qPrintable(file.errorString())); QTextStream stream(&file); QVERIFY(file.isTextModeEnabled()); QString emptyLine = stream.readLine(); // Text mode flag cleared here -- cgit v1.2.3 From 5784c064a9c89ceb1e6dc9857e2c1ed6edf9a7b8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 14 Mar 2016 14:51:45 +0100 Subject: tst_QRect: drop a test that depends on int overflow The compiler can statically check that this is undefined behavior: tst_qrect.cpp:3173:52: warning: integer overflow in expression [-Woverflow] << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN))); ~^~ tst_qrect.cpp:3173:72: warning: integer overflow in expression [-Woverflow] << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN))); ~^~ Fix by skipping the test (like most of the others are in the block). Change-Id: I359a5e16db6c660c9f11d7dd8fbb40730bd63887 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qrect/tst_qrect.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp index 585cf5d4d0..c6907dcac2 100644 --- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp +++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp @@ -3171,8 +3171,7 @@ void tst_QRect::newMoveTopLeft_data() } { - QTest::newRow("LargestCoordQRect_NullQPoint") << getQRectCase(LargestCoordQRect) << getQPointCase(NullQPoint) - << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN))); + // QTest::newRow("LargestCoordQRect_NullQPoint") -- Not tested as it would cause an overflow QTest::newRow("LargestCoordQRect_SmallestCoordQPoint") << getQRectCase(LargestCoordQRect) << getQPointCase(SmallestCoordQPoint) << QRect(QPoint(INT_MIN,INT_MIN), QPoint(INT_MAX,INT_MAX)); // QTest::newRow("LargestCoordQRect_MiddleNegCoordQPoint") -- Not tested as it would cause an overflow -- cgit v1.2.3 From e4c6d73f925671a9c96558293472ed213861239c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 14 Mar 2016 15:18:11 +0100 Subject: QRect: fix UB (int overflow) in center() QRect::center() should be defined for any QRect(x1,y1,x2,x2), INT_MIN <= x1, x2, y1, y2 <= INT_MAX because the average of two signed integers is always representable as a signed integer. But not when it's calculated as (x1+x2)/2, since that expression overflows when x1 > INT_MAX - x2. Instead of playing games with Hacker's Delight-style expressions, or use Google's patented algorithm, which requires two divisions, take advantage of the fact that int is not intmax_t and perform the calculation in the qint64 domain. The cast back to int is always well- defined since, as mentioned, the result is always representable in an int. Fix a test-case that expected a nonsensical result due to overflow. [ChangeLog][QtCore][QRect] Fixed integer overflow in center(). This fixes the result for some corner-cases like a 1x1 rectangle at (INT_MIN, INT_MIN), for which the previous implementation could return anything (due to invoking undefined behavior), but commonly returned (0, 0). Change-Id: I1a885ca6dff770327dd31655c3eb473fcfeb8878 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qrect/tst_qrect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp index c6907dcac2..1377e801a7 100644 --- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp +++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp @@ -2349,7 +2349,7 @@ void tst_QRect::center_data() QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << QPoint(1,1); QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << QPoint(0,0); QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << QPoint(INT_MAX/2,INT_MAX/2); - QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << QPoint(0,0); + QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << QPoint(INT_MIN, INT_MIN); QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << QPoint(0,0); QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << QPoint(105,207); QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << QPoint(-4,-4); -- cgit v1.2.3 From eef3afaa978a25743af7efdda169052b67cc744a Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 11 Mar 2016 11:14:49 +0100 Subject: QTextStream test: Change current directory For platforms with builtin testdata/sandboxed platforms we need to change the current directory to be able to create files. Change-Id: I440205c95dd6df1308c6bf24b1b0f67fd697feab Reviewed-by: Oliver Wolff --- tests/auto/corelib/io/qtextstream/test/test.pro | 4 ++++ tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/io/qtextstream/test/test.pro b/tests/auto/corelib/io/qtextstream/test/test.pro index 39d181344f..073aecdfba 100644 --- a/tests/auto/corelib/io/qtextstream/test/test.pro +++ b/tests/auto/corelib/io/qtextstream/test/test.pro @@ -21,3 +21,7 @@ TESTDATA += \ ../tst_qtextstream.cpp \ ../resources DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +builtin_testdata { + DEFINES += BUILTIN_TESTDATA +} diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 24dd05223f..13be58a1f1 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -65,6 +65,7 @@ public: public slots: void initTestCase(); void cleanup(); + void cleanupTestCase(); private slots: void getSetCheck(); @@ -241,6 +242,9 @@ private: QTemporaryDir tempDir; QString testFileName; +#ifdef BUILTIN_TESTDATA + QSharedPointer m_dataDir; +#endif const QString m_rfc3261FilePath; const QString m_shiftJisFilePath; }; @@ -267,9 +271,14 @@ void tst_QTextStream::initTestCase() testFileName = tempDir.path() + "/testfile"; +#ifdef BUILTIN_TESTDATA + m_dataDir = QEXTRACTTESTDATA("/"); + QVERIFY2(QDir::setCurrent(m_dataDir->path()), qPrintable("Could not chdir to " + m_dataDir->path())); +#else // chdir into the testdata dir and refer to our helper apps with relative paths QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); +#endif } // Testing get/set functions @@ -392,6 +401,13 @@ void tst_QTextStream::cleanup() QCoreApplication::instance()->processEvents(); } +void tst_QTextStream::cleanupTestCase() +{ +#ifdef BUILTIN_TESTDATA + QDir::setCurrent(QCoreApplication::applicationDirPath()); +#endif +} + // ------------------------------------------------------------------------------ void tst_QTextStream::construction() { -- cgit v1.2.3 From e830fa8fc251f697ffee2c215c0121028eeef8ca Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 11 Mar 2016 11:12:40 +0100 Subject: tst_QXmlStream::writerHangs(): Create file in temporary directory A test should not write to its directory. Change-Id: I34dfc36387cf5a637b325be29c8a19ff51d9b9c3 Reviewed-by: Oliver Wolff --- tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index 341b169113..1da29ac3bd 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -905,7 +905,8 @@ void tst_QXmlStream::testFalsePrematureError() const // Regression test for crash due to using empty QStack. void tst_QXmlStream::writerHangs() const { - QFile file("test.xml"); + QTemporaryDir dir(QDir::tempPath() + QLatin1String("/tst_qxmlstream.XXXXXX")); + QFile file(dir.path() + "/test.xml"); QVERIFY(file.open(QIODevice::WriteOnly)); -- cgit v1.2.3 From e7cd32274e144144c1630d65d09d24a1ae0af2d7 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 15 Mar 2016 13:04:50 +0100 Subject: WinRT: Fix QTimeZone transitions by switching backend Previously WinRT was using the UTC backend which fails on all platforms for some QDateTime autotests related to timezone items. Hence switch to the Windows implementation for WinRT as well. However, the windows backend does query the registry heavily, which is not supported on WinRT. Instead use the API version provided by the SDK. Long-term we might want to switch to this version on desktop windows as well, as direct registry access would not be required and we could harmonize the codepaths for both platforms. Change-Id: I620b614e9994aa77b531e5c34c9be1da7e272a30 Reviewed-by: Oliver Wolff --- tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/auto/corelib') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index b511abf670..32bb2aa394 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -898,7 +898,7 @@ void tst_QTimeZone::macTest() void tst_QTimeZone::winTest() { -#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) // Known datetimes qint64 std = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); qint64 dst = QDateTime(QDate(2012, 6, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); -- cgit v1.2.3