diff options
Diffstat (limited to 'tests/auto/qsharedmemory')
-rw-r--r-- | tests/auto/qsharedmemory/lackey/lackey.pro | 2 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/lackey/main.cpp | 30 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/lackey/scripts/producer.js | 8 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/qsystemlock/qsystemlock.pro | 6 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp | 56 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/src/qsystemlock.cpp | 30 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/src/qsystemlock.h | 30 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/src/qsystemlock_p.h | 33 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/src/qsystemlock_unix.cpp | 54 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/src/qsystemlock_win.cpp | 30 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/test/test.pro | 12 | ||||
-rw-r--r-- | tests/auto/qsharedmemory/tst_qsharedmemory.cpp | 86 |
12 files changed, 239 insertions, 138 deletions
diff --git a/tests/auto/qsharedmemory/lackey/lackey.pro b/tests/auto/qsharedmemory/lackey/lackey.pro index 9d2fcad5c..d25a50a91 100644 --- a/tests/auto/qsharedmemory/lackey/lackey.pro +++ b/tests/auto/qsharedmemory/lackey/lackey.pro @@ -9,6 +9,8 @@ DESTDIR = ./ win32: CONFIG += console mac:CONFIG -= app_bundle +requires(contains(QT_CONFIG,script)) + DEFINES += QSHAREDMEMORY_DEBUG DEFINES += QSYSTEMSEMAPHORE_DEBUG diff --git a/tests/auto/qsharedmemory/lackey/main.cpp b/tests/auto/qsharedmemory/lackey/main.cpp index b5effcb8e..cb75d8975 100644 --- a/tests/auto/qsharedmemory/lackey/main.cpp +++ b/tests/auto/qsharedmemory/lackey/main.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$ ** ****************************************************************************/ diff --git a/tests/auto/qsharedmemory/lackey/scripts/producer.js b/tests/auto/qsharedmemory/lackey/scripts/producer.js index 88b2b8090..e02cd8b7b 100644 --- a/tests/auto/qsharedmemory/lackey/scripts/producer.js +++ b/tests/auto/qsharedmemory/lackey/scripts/producer.js @@ -15,6 +15,10 @@ if (!producer.create(size)) { } //print ("producer created and attached"); +QVERIFY(producer.lock()); +producer.set(0, 'Q'); +QVERIFY(producer.unlock()); + var i = 0; while(i < 5) { QVERIFY(producer.lock(), "lock"); @@ -34,3 +38,7 @@ producer.set(0, 'E'); QVERIFY(producer.unlock()); //print ("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. +producer.sleep(3000);
\ No newline at end of file diff --git a/tests/auto/qsharedmemory/qsystemlock/qsystemlock.pro b/tests/auto/qsharedmemory/qsystemlock/qsystemlock.pro index 042ab3fa6..e232443a3 100644 --- a/tests/auto/qsharedmemory/qsystemlock/qsystemlock.pro +++ b/tests/auto/qsharedmemory/qsystemlock/qsystemlock.pro @@ -5,6 +5,12 @@ include(../src/src.pri) win32: CONFIG += console mac:CONFIG -= app_bundle +wince* { + DEFINES += SRCDIR=\\\"\\\" +} else:!symbian { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + DESTDIR = ./ DEFINES += QSHAREDMEMORY_DEBUG diff --git a/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp b/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp index 75e90d645..518cdbfa0 100644 --- a/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.cpp +++ b/tests/auto/qsharedmemory/qsystemlock/tst_qsystemlock.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$ ** ****************************************************************************/ @@ -46,6 +46,13 @@ //TESTED_CLASS= //TESTED_FILES= +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// And underlying Open C have application private dir in default search path +#define SRCDIR "" +#endif + + #define EXISTING_SHARE "existing" class tst_QSystemLock : public QObject @@ -195,26 +202,35 @@ void tst_QSystemLock::processes() QStringList scripts; for (int i = 0; i < readOnly; ++i) - scripts.append("../lackey/scripts/systemlock_read.js"); + scripts.append(QFileInfo(SRCDIR "/../lackey/scripts/systemlock_read.js").absoluteFilePath() ); for (int i = 0; i < readWrite; ++i) - scripts.append("../lackey/scripts/systemlock_readwrite.js"); + scripts.append(QFileInfo(SRCDIR "/../lackey/scripts/systemlock_readwrite.js").absoluteFilePath()); QList<QProcess*> consumers; + unsigned int failedProcesses = 0; for (int i = 0; i < scripts.count(); ++i) { + QStringList arguments = QStringList() << scripts.at(i); QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); - consumers.append(p); - p->start("../lackey/lackey", arguments); + + p->start("../lackey/lackey", arguments); + // test, if the process could be started. + + if (p->waitForStarted(2000)) + consumers.append(p); + else + ++failedProcesses; } while (!consumers.isEmpty()) { consumers.first()->waitForFinished(3000); - consumers.first()->kill(); + consumers.first()->kill(); QCOMPARE(consumers.first()->exitStatus(), QProcess::NormalExit); QCOMPARE(consumers.first()->exitCode(), 0); delete consumers.takeFirst(); } + QCOMPARE(failedProcesses, (unsigned int)(0)); } QTEST_MAIN(tst_QSystemLock) diff --git a/tests/auto/qsharedmemory/src/qsystemlock.cpp b/tests/auto/qsharedmemory/src/qsystemlock.cpp index 1fd2cd1c6..3068b9301 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock.cpp +++ b/tests/auto/qsharedmemory/src/qsystemlock.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$ ** ****************************************************************************/ diff --git a/tests/auto/qsharedmemory/src/qsystemlock.h b/tests/auto/qsharedmemory/src/qsystemlock.h index 839ee3ccd..76f3e7886 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock.h +++ b/tests/auto/qsharedmemory/src/qsystemlock.h @@ -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$ ** ****************************************************************************/ diff --git a/tests/auto/qsharedmemory/src/qsystemlock_p.h b/tests/auto/qsharedmemory/src/qsystemlock_p.h index 66df4567c..2d4405134 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock_p.h +++ b/tests/auto/qsharedmemory/src/qsystemlock_p.h @@ -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$ ** ****************************************************************************/ @@ -47,6 +47,9 @@ #include "qsystemlock.h" #include "private/qsharedmemory_p.h" +#ifndef Q_OS_WINCE +#include <sys/types.h> +#endif #define MAX_LOCKS 64 diff --git a/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp b/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp index 1f91e0c63..333f55dc3 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock_unix.cpp +++ b/tests/auto/qsharedmemory/src/qsystemlock_unix.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$ ** ****************************************************************************/ @@ -51,6 +51,7 @@ #include <fcntl.h> #include <errno.h> #include <sys/shm.h> +#include <unistd.h> #include <sys/sem.h> // We have to define this as on some sem.h will have it @@ -62,6 +63,25 @@ union qt_semun { #define tr(x) QT_TRANSLATE_NOOP(QLatin1String("QSystemLock"), (x)) +#if defined(Q_OS_SYMBIAN) +int createUnixKeyFile(const QString &fileName) +{ + if (QFile::exists(fileName)) + return 0; + + int fd = open(QFile::encodeName(fileName).constData(), + O_EXCL | O_CREAT | O_RDWR, 0640); + if (-1 == fd) { + if (errno == EEXIST) + return 0; + return -1; + } else { + close(fd); + } + return 1; +} +#endif + QSystemLockPrivate::QSystemLockPrivate() : semaphore(-1), lockCount(0), error(QSystemLock::NoError), unix_key(-1), createdFile(false), createdSemaphore(false) @@ -105,7 +125,11 @@ key_t QSystemLockPrivate::handle() } // Create the file needed for ftok +#if defined(Q_OS_SYMBIAN) + int built = createUnixKeyFile(fileName); +#else int built = QSharedMemoryPrivate::createUnixKeyFile(fileName); +#endif if (-1 == built) return -1; createdFile = (1 == built); diff --git a/tests/auto/qsharedmemory/src/qsystemlock_win.cpp b/tests/auto/qsharedmemory/src/qsystemlock_win.cpp index 28f371b30..fa393a026 100644 --- a/tests/auto/qsharedmemory/src/qsystemlock_win.cpp +++ b/tests/auto/qsharedmemory/src/qsystemlock_win.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$ ** ****************************************************************************/ diff --git a/tests/auto/qsharedmemory/test/test.pro b/tests/auto/qsharedmemory/test/test.pro index e294a756b..c9f4fecc0 100644 --- a/tests/auto/qsharedmemory/test/test.pro +++ b/tests/auto/qsharedmemory/test/test.pro @@ -17,13 +17,21 @@ TARGET = ../tst_qsharedmemory } } -wince*: { +wince*:{ +requires(contains(QT_CONFIG,script)) QT += gui script addFiles.sources = ../lackey/lackey.exe ../lackey/scripts addFiles.path = lackey DEPLOYMENT += addFiles DEFINES += SRCDIR=\\\"\\\" +}else:symbian*{ +requires(contains(QT_CONFIG,script)) +QT += gui script +addFiles.sources = ../lackey/scripts +addFiles.path = /data/qsharedmemorytemp/lackey +addBin.sources = lackey.exe +addBin.path = /sys/bin +DEPLOYMENT += addFiles addBin } else { DEFINES += SRCDIR=\\\"$$PWD/../\\\" } - 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) |