summaryrefslogtreecommitdiffstats
path: root/tests/auto/qsharedmemory/tst_qsharedmemory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qsharedmemory/tst_qsharedmemory.cpp')
-rw-r--r--tests/auto/qsharedmemory/tst_qsharedmemory.cpp86
1 files changed, 60 insertions, 26 deletions
diff --git a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp
index 1aa1ebb03..f72b6f7c7 100644
--- a/tests/auto/qsharedmemory/tst_qsharedmemory.cpp
+++ b/tests/auto/qsharedmemory/tst_qsharedmemory.cpp
@@ -1,6 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the test suite of the Qt Toolkit.
@@ -9,8 +10,8 @@
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
+** contained in the Technology Preview License Agreement accompanying
+** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
@@ -20,21 +21,20 @@
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://qt.nokia.com/contact.
** $QT_END_LICENSE$
**
****************************************************************************/
@@ -49,8 +49,11 @@
#define EXISTING_SHARE "existing"
#define EXISTING_SIZE 1024
-Q_DECLARE_METATYPE(QSharedMemory::SharedMemoryError);
-Q_DECLARE_METATYPE(QSharedMemory::AccessMode);
+#ifdef Q_OS_SYMBIAN
+#define SRCDIR "c:/data/qsharedmemorytemp/"
+#endif
+Q_DECLARE_METATYPE(QSharedMemory::SharedMemoryError)
+Q_DECLARE_METATYPE(QSharedMemory::AccessMode)
class tst_QSharedMemory : public QObject
{
@@ -405,6 +408,9 @@ void tst_QSharedMemory::readOnly()
#ifdef Q_OS_WIN
QSKIP("This test opens a crash dialog on Windows", SkipSingle);
#endif
+#if defined (Q_OS_SYMBIAN)
+ QSKIP("Readonly shared memory is not supported in symbian", SkipAll);
+#endif
QString program = "./lackey/lackey";
QStringList arguments;
rememberKey("readonly_segfault");
@@ -527,7 +533,9 @@ void tst_QSharedMemory::simpleProducerConsumer()
char *get = (char*)consumer.data();
// On Windows CE you always have ReadWrite access. Thus
// ViewMapOfFile returns the same pointer
-#ifndef Q_OS_WINCE
+ // On Symbian, the address will always be same, as
+ // write protection of chunks is not currently supported by Symbian
+#if !defined(Q_OS_WINCE) && !defined(Q_OS_SYMBIAN)
QVERIFY(put != get);
#endif
for (int i = 0; i < size; ++i) {
@@ -629,6 +637,11 @@ public:
QVERIFY(producer.lock());
memory[0] = 'E';
QVERIFY(producer.unlock());
+
+#if defined(Q_OS_SYMBIAN)
+ // Sleep a while to ensure that consumers start properly
+ QTest::qSleep(1000);
+#endif
}
private:
@@ -660,12 +673,25 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer()
#endif
Producer p;
+#if defined(Q_OS_SYMBIAN)
+ enum
+ {
+ /**
+ * The maximum stack size.
+ */
+ SymbianStackSize = 0x14000
+ };
+ p.setStackSize(SymbianStackSize);
+#endif
if (producerIsThread)
p.start();
QList<Consumer*> consumers;
for (int i = 0; i < threads; ++i) {
consumers.append(new Consumer());
+#if defined(Q_OS_SYMBIAN)
+ consumers.last()->setStackSize(SymbianStackSize);
+#endif
consumers.last()->start();
}
@@ -682,10 +708,7 @@ void tst_QSharedMemory::simpleThreadedProducerConsumer()
void tst_QSharedMemory::simpleProcessProducerConsumer_data()
{
QTest::addColumn<int>("processes");
- int tries = 10;
-#ifdef Q_OS_WIN
- tries = 5;
-#endif
+ int tries = 5;
for (int i = 0; i < tries; ++i) {
QTest::newRow("1 process") << 1;
QTest::newRow("5 processes") << 5;
@@ -697,6 +720,9 @@ void tst_QSharedMemory::simpleProcessProducerConsumer_data()
*/
void tst_QSharedMemory::simpleProcessProducerConsumer()
{
+#if defined (Q_OS_SYMBIAN) && defined(Q_CC_NOKIAX86)
+ QSKIP("Cannot launch multiple Qt processes in Symbian emulator", SkipAll);
+#endif
QFETCH(int, processes);
rememberKey("market");
@@ -708,10 +734,12 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
#endif
QProcess producer;
producer.setProcessChannelMode(QProcess::ForwardedChannels);
- producer.start("./lackey/lackey", arguments);
+ producer.start( "./lackey/lackey", arguments);
producer.waitForStarted();
+ QVERIFY(producer.error() != QProcess::FailedToStart);
QList<QProcess*> consumers;
+ unsigned int failedProcesses = 0;
for (int i = 0; i < processes; ++i) {
#ifndef Q_OS_WINCE
QStringList arguments = QStringList() << SRCDIR "lackey/scripts/consumer.js";
@@ -720,8 +748,12 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
#endif
QProcess *p = new QProcess;
p->setProcessChannelMode(QProcess::ForwardedChannels);
- consumers.append(p);
p->start("./lackey/lackey", arguments);
+
+ if (p->waitForStarted(2000))
+ consumers.append(p);
+ else
+ ++failedProcesses;
}
producer.waitForFinished(5000);
@@ -729,14 +761,16 @@ void tst_QSharedMemory::simpleProcessProducerConsumer()
bool consumerFailed = false;
while (!consumers.isEmpty()) {
- consumers.first()->waitForFinished(1000);
- if (consumers.first()->exitStatus() != QProcess::NormalExit ||
+ consumers.first()->waitForFinished(2000);
+ if (consumers.first()->state() == QProcess::Running ||
+ consumers.first()->exitStatus() != QProcess::NormalExit ||
consumers.first()->exitCode() != 0) {
consumerFailed = true;
}
delete consumers.takeFirst();
}
QCOMPARE(consumerFailed, false);
+ QCOMPARE(failedProcesses, (unsigned int)(0));
}
QTEST_MAIN(tst_QSharedMemory)