diff options
Diffstat (limited to 'tests')
8 files changed, 207 insertions, 2 deletions
diff --git a/tests/auto/processmanager/processmanager.pro b/tests/auto/processmanager/processmanager.pro index 2049057..6d0389d 100644 --- a/tests/auto/processmanager/processmanager.pro +++ b/tests/auto/processmanager/processmanager.pro @@ -1,3 +1,11 @@ TEMPLATE = subdirs -SUBDIRS = testClient testPrelaunch testPipeLauncher testSocketLauncher testForkLauncher test +SUBDIRS = \ + testClient \ + testPrelaunch \ + testPipeLauncher \ + testSocketLauncher \ + testForkLauncher \ + testPreforkLauncher \ + testPrefork \ + test diff --git a/tests/auto/processmanager/testForkLauncher/main.cpp b/tests/auto/processmanager/testForkLauncher/main.cpp index 1ac4caf..f3da36d 100644 --- a/tests/auto/processmanager/testForkLauncher/main.cpp +++ b/tests/auto/processmanager/testForkLauncher/main.cpp @@ -131,7 +131,7 @@ private: QByteArray m_inbuf, m_outbuf; }; -int +extern "C" Q_DECL_EXPORT int main(int argc, char **argv) { forklauncher(&argc, &argv); diff --git a/tests/auto/processmanager/testForkLauncher/testForkLauncher.pro b/tests/auto/processmanager/testForkLauncher/testForkLauncher.pro index b8333ea..3198b00 100644 --- a/tests/auto/processmanager/testForkLauncher/testForkLauncher.pro +++ b/tests/auto/processmanager/testForkLauncher/testForkLauncher.pro @@ -8,5 +8,9 @@ DESTDIR = ./ SOURCES += main.cpp TARGET = testForkLauncher +# Position-independent code and export symbols +QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden +QMAKE_LFLAGS += -pie -rdynamic + target.path = $$[QT_INSTALL_TESTS]/$$TESTCASE_NAME/testForkLauncher INSTALLS += target diff --git a/tests/auto/processmanager/testPrefork/testPrefork.cpp b/tests/auto/processmanager/testPrefork/testPrefork.cpp new file mode 100644 index 0000000..da4a00b --- /dev/null +++ b/tests/auto/processmanager/testPrefork/testPrefork.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/* This should be called "Frigg" */ + +#include "prefork.h" +#include <QDebug> + +QT_USE_NAMESPACE_PROCESSMANAGER + +int main(int argc, char **argv) +{ + Prefork *prefork = Prefork::instance(); + prefork->execute(&argc, &argv); // This function never returns +} diff --git a/tests/auto/processmanager/testPrefork/testPrefork.pro b/tests/auto/processmanager/testPrefork/testPrefork.pro new file mode 100644 index 0000000..05c79dc --- /dev/null +++ b/tests/auto/processmanager/testPrefork/testPrefork.pro @@ -0,0 +1,12 @@ +CONFIG -= app_bundle +QT += processmanager jsonstream +QT -= gui + +include(../processmanager.pri) + +DESTDIR = ./ +SOURCES += testPrefork.cpp +TARGET = testPrefork + +target.path = $$[QT_INSTALL_TESTS]/$$TESTCASE_NAME/testPrefork +INSTALLS += target diff --git a/tests/auto/processmanager/testPreforkLauncher/main.cpp b/tests/auto/processmanager/testPreforkLauncher/main.cpp new file mode 100644 index 0000000..ace2c05 --- /dev/null +++ b/tests/auto/processmanager/testPreforkLauncher/main.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QCoreApplication> +#include <QDebug> + +#include <jsonserver.h> +#include <schemavalidator.h> + +#include "socketlauncher.h" +#include "preforkprocessbackendfactory.h" + +QT_USE_NAMESPACE_PROCESSMANAGER + +extern "C" Q_DECL_EXPORT int main(int argc, char **argv) +{ + QtAddOn::JsonStream::JsonServer::ValidatorFlags flags(QtAddOn::JsonStream::JsonServer::NoValidation); + QString indir, outdir; + + QCoreApplication app(argc, argv); + QStringList args = QCoreApplication::arguments(); + QString progname = args.takeFirst(); + + SocketLauncher launcher; + PreforkProcessBackendFactory *factory = new PreforkProcessBackendFactory; + factory->setIndex(0); + launcher.addFactory(factory); + + launcher.listen(args[0]); + return app.exec(); +} diff --git a/tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.pro b/tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.pro new file mode 100644 index 0000000..6813981 --- /dev/null +++ b/tests/auto/processmanager/testPreforkLauncher/testPreforkLauncher.pro @@ -0,0 +1,16 @@ +CONFIG -= app_bundle +QT += processmanager jsonstream +QT -= gui + +include(../processmanager.pri) + +DESTDIR = ./ +SOURCES += main.cpp +TARGET = testPreforkLauncher + +# Position-independent code and export symbols +QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden +QMAKE_LFLAGS += -pie -rdynamic + +target.path = $$[QT_INSTALL_TESTS]/$$TESTCASE_NAME/testPreforkLauncher +INSTALLS += target diff --git a/tests/auto/processmanager/tst_processmanager.cpp b/tests/auto/processmanager/tst_processmanager.cpp index 3cc2cf2..cd1a3a4 100644 --- a/tests/auto/processmanager/tst_processmanager.cpp +++ b/tests/auto/processmanager/tst_processmanager.cpp @@ -814,6 +814,42 @@ static void forkLauncherTest( clientFunc func, infoFunc infoFixup=0 ) #endif } +static void preforkLauncherTest( clientFunc func, infoFunc infoFixup=0 ) +{ +#if defined(Q_OS_LINUX) + QProcess *remote = new QProcess; + QString socketName = QLatin1String("/tmp/preforklauncher"); + remote->setProcessChannelMode(QProcess::ForwardedChannels); + QStringList args; + args << "--" << "testPreforkLauncher/testPreforkLauncher" << socketName + << "--" << "testForkLauncher/testForkLauncher"; + qDebug() << "Trying to run: testPrefork/testPrefork" << args; + remote->start("testPrefork/testPrefork", args); + QVERIFY(remote->waitForStarted()); + waitForSocket(socketName); + + ProcessBackendManager *manager = new ProcessBackendManager; + SocketProcessBackendFactory *factory = new SocketProcessBackendFactory; + factory->setSocketName(socketName); + manager->addFactory(factory); + + ProcessInfo info; + info.setValue("program", "testClient/testClient"); + if (infoFixup) + infoFixup(info); + fixUidGid(info); + func(manager, info, writeLine); + + delete manager; + delete remote; +#else + Q_UNUSED(func); + Q_UNUSED(infoFixup); +#endif +} + + + @@ -905,6 +941,17 @@ private slots: void forkLauncherOomChangeBefore() { forkLauncherTest(oomChangeBeforeClient); } void forkLauncherOomChangeAfter() { forkLauncherTest(oomChangeAfterClient); } + void preforkLauncherStartAndStop() { preforkLauncherTest(startAndStopClient); } + void preforkLauncherStartAndStopMultiple() { preforkLauncherTest(startAndStopMultiple); } + void preforkLauncherStartAndKill() { preforkLauncherTest(startAndKillClient); } + void preforkLauncherStartAndKillTough() { preforkLauncherTest(startAndKillClient, makeTough); } + void preforkLauncherStartAndCrash() { preforkLauncherTest(startAndCrashClient); } + void preforkLauncherEcho() { preforkLauncherTest(echoClient); } + void preforkLauncherPriorityChangeBefore() { preforkLauncherTest(priorityChangeBeforeClient); } + void preforkLauncherPriorityChangeAfter() { preforkLauncherTest(priorityChangeAfterClient); } + void preforkLauncherOomChangeBefore() { preforkLauncherTest(oomChangeBeforeClient); } + void preforkLauncherOomChangeAfter() { preforkLauncherTest(oomChangeAfterClient); } + void prelaunchChildAbort(); void frontend(); |