diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-16 23:51:11 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-01-16 23:51:11 +0100 |
commit | e3a10e15ff5a015de28528b5f73316d7aa0de116 (patch) | |
tree | 57e5bae55b627af2fa372b9de4e530305cb43cce /tests/auto/corelib | |
parent | 34572dadc6a4efce87a639f38a989a3117c8ca9f (diff) | |
parent | 7075e291998612a3c0a530bb37a515dd07739e28 (diff) |
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/corelib')
4 files changed, 37 insertions, 13 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp index 61a1fea343..f523225ef1 100644 --- a/tests/auto/corelib/io/qfile/tst_qfile.cpp +++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp @@ -51,6 +51,7 @@ #include <private/qabstractfileengine_p.h> #include <private/qfsfileengine_p.h> +#include <private/qfilesystemengine_p.h> #ifdef Q_OS_WIN QT_BEGIN_NAMESPACE @@ -2418,6 +2419,7 @@ void tst_QFile::rename_data() #endif QTest::newRow("renamefile -> renamedfile") << QString::fromLatin1(renameSourceFile) << QString("renamedfile") << true; QTest::newRow("renamefile -> ..") << QString::fromLatin1(renameSourceFile) << QString("..") << false; + QTest::newRow("renamefile -> rEnAmEfIlE") << QString::fromLatin1(renameSourceFile) << QStringLiteral("rEnAmEfIlE") << true; } void tst_QFile::rename() @@ -2435,7 +2437,8 @@ void tst_QFile::rename() } #endif - QFile sourceFile(QString::fromLatin1(renameSourceFile)); + const QString sourceFileName = QString::fromLatin1(renameSourceFile); + QFile sourceFile(sourceFileName); QVERIFY2(sourceFile.open(QFile::WriteOnly | QFile::Text), qPrintable(sourceFile.errorString())); QVERIFY2(sourceFile.write(content), qPrintable(sourceFile.errorString())); sourceFile.close(); @@ -2445,7 +2448,10 @@ void tst_QFile::rename() if (result) { QVERIFY2(success, qPrintable(file.errorString())); QCOMPARE(file.error(), QFile::NoError); - QVERIFY(!sourceFile.exists()); + // This will report the source file still existing for a rename changing the case + // on Windows, Mac. + if (sourceFileName.compare(destination, Qt::CaseInsensitive)) + QVERIFY(!sourceFile.exists()); QFile destinationFile(destination); QVERIFY2(destinationFile.open(QFile::ReadOnly | QFile::Text), qPrintable(destinationFile.errorString())); QCOMPARE(destinationFile.readAll(), content); diff --git a/tests/auto/corelib/kernel/qsharedmemory/sharedmemoryhelper/main.cpp b/tests/auto/corelib/kernel/qsharedmemory/sharedmemoryhelper/main.cpp index 63f38f43f3..30c9d01e98 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/sharedmemoryhelper/main.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/sharedmemoryhelper/main.cpp @@ -43,6 +43,7 @@ #include <QStringList> #include <QDebug> #include <QTest> +#include <stdio.h> void set(QSharedMemory &sm, int pos, QChar value) { @@ -82,7 +83,10 @@ int producer() return EXIT_FAILURE; } } + // tell parent we're ready //qDebug("producer created and attached"); + puts(""); + fflush(stdout); if (!producer.lock()) { qWarning() << "Could not lock" << producer.key(); @@ -129,9 +133,8 @@ int producer() //qDebug("producer done"); - // Sleep for a bit to let all consumers start, otherwise they will get stuck in the attach loop, - // because at least in Symbian the shared memory will be destroyed if there are no active handles to it. - QTest::qSleep(3000); + // Sleep for a bit to let all consumers exit + getchar(); return EXIT_SUCCESS; } diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp index 5d9b470494..baeb6e1666 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp @@ -177,6 +177,7 @@ void tst_QSharedMemory::cleanup() #include <sys/types.h> #include <sys/ipc.h> #include <sys/shm.h> +#include <errno.h> #endif QString tst_QSharedMemory::helperBinary() @@ -209,9 +210,9 @@ int tst_QSharedMemory::remove(const QString &key) return -3; } - int id = shmget(unix_key, 0, 0660); + int id = shmget(unix_key, 0, 0600); if (-1 == id) { - qDebug() << "shmget failed"; + qDebug() << "shmget failed" << strerror(errno); return -4; } @@ -634,9 +635,8 @@ class Producer : public QThread { public: - void run() + Producer() : producer(QLatin1String("market")) { - QSharedMemory producer(QLatin1String("market")); int size = 1024; if (!producer.create(size)) { // left over from a crash... @@ -646,7 +646,11 @@ public: QVERIFY(producer.create(size)); } } - QVERIFY(producer.isAttached()); + } + + void run() + { + char *memory = (char*)producer.data(); memory[1] = '0'; QTime timer; @@ -671,6 +675,8 @@ public: QVERIFY(producer.unlock()); } + + QSharedMemory producer; private: }; @@ -701,6 +707,7 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer() #endif Producer p; + QVERIFY(p.producer.isAttached()); if (producerIsThread) p.start(); @@ -741,9 +748,10 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() rememberKey("market"); QProcess producer; - producer.setProcessChannelMode(QProcess::ForwardedChannels); producer.start(helperBinary(), QStringList("producer")); QVERIFY2(producer.waitForStarted(), "Could not start helper binary"); + QVERIFY2(producer.waitForReadyRead(), "Helper process failed to create shared memory segment: " + + producer.readAllStandardError()); QList<QProcess*> consumers; unsigned int failedProcesses = 0; @@ -758,8 +766,6 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() ++failedProcesses; } - QVERIFY(producer.waitForFinished(5000)); - bool consumerFailed = false; while (!consumers.isEmpty()) { @@ -773,6 +779,11 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() } QCOMPARE(consumerFailed, false); QCOMPARE(failedProcesses, (unsigned int)(0)); + + // tell the producer to exit now + producer.write("", 1); + producer.waitForBytesWritten(); + QVERIFY(producer.waitForFinished(5000)); } void tst_QSharedMemory::uniqueKey_data() diff --git a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp index 62d6c4f462..f0d2e46b9f 100644 --- a/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp +++ b/tests/auto/corelib/tools/qlocale/tst_qlocale.cpp @@ -1665,6 +1665,10 @@ void tst_QLocale::dateFormat() QCOMPARE(no.dateFormat(QLocale::NarrowFormat), QLatin1String("dd.MM.yy")); QCOMPARE(no.dateFormat(QLocale::ShortFormat), QLatin1String("dd.MM.yy")); QCOMPARE(no.dateFormat(QLocale::LongFormat), QLatin1String("dddd d. MMMM yyyy")); + + const QLocale ca("en_CA"); + QCOMPARE(ca.dateFormat(QLocale::ShortFormat), QLatin1String("M/d/yy")); + QCOMPARE(ca.dateFormat(QLocale::LongFormat), QLatin1String("dddd, MMMM d, yyyy")); } void tst_QLocale::timeFormat() |