diff options
Diffstat (limited to 'tests/auto/corelib/kernel')
-rw-r--r-- | tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp | 20 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp | 25 |
2 files changed, 26 insertions, 19 deletions
diff --git a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp index ce5e83288f..82f0a846bc 100644 --- a/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp +++ b/tests/auto/corelib/kernel/qsharedmemory/test/tst_qsharedmemory.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -114,7 +114,7 @@ private slots: void uniqueKey(); protected: - QString helperBinary(); + static QString helperBinary(); int remove(const QString &key); QString rememberKey(const QString &key) @@ -131,10 +131,14 @@ protected: QStringList keys; QList<QSharedMemory*> jail; QSharedMemory *existingSharedMemory; + +private: + const QString m_helperBinary; }; -tst_QSharedMemory::tst_QSharedMemory() : - existingSharedMemory(0) +tst_QSharedMemory::tst_QSharedMemory() + : existingSharedMemory(0) + , m_helperBinary(tst_QSharedMemory::helperBinary()) { } @@ -144,7 +148,7 @@ tst_QSharedMemory::~tst_QSharedMemory() void tst_QSharedMemory::initTestCase() { - QVERIFY2(!helperBinary().isEmpty(), "Could not find helper binary"); + QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary"); } void tst_QSharedMemory::init() @@ -455,7 +459,7 @@ void tst_QSharedMemory::readOnly() rememberKey("readonly_segfault"); // ### on windows disable the popup somehow QProcess p; - p.start(helperBinary(), QStringList("readonly_segfault")); + p.start(m_helperBinary, QStringList("readonly_segfault")); p.setProcessChannelMode(QProcess::ForwardedChannels); p.waitForFinished(); QCOMPARE(p.error(), QProcess::Crashed); @@ -753,7 +757,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() rememberKey("market"); QProcess producer; - producer.start(helperBinary(), QStringList("producer")); + producer.start(m_helperBinary, QStringList("producer")); QVERIFY2(producer.waitForStarted(), "Could not start helper binary"); QVERIFY2(producer.waitForReadyRead(), "Helper process failed to create shared memory segment: " + producer.readAllStandardError()); @@ -764,7 +768,7 @@ void tst_QSharedMemory::simpleProcessProducerConsumer() for (int i = 0; i < processes; ++i) { QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); - p->start(helperBinary(), consumerArguments); + p->start(m_helperBinary, consumerArguments); if (p->waitForStarted(2000)) consumers.append(p); else diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp index 9e33f56a34..42f2709384 100644 --- a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp +++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies). ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -80,17 +80,20 @@ private slots: #endif // QT_NO_PROCESS private: - QString helperBinary(); + static QString helperBinary(); QSystemSemaphore *existingLock; + + const QString m_helperBinary; }; tst_QSystemSemaphore::tst_QSystemSemaphore() + : m_helperBinary(helperBinary()) { } void tst_QSystemSemaphore::initTestCase() { - QVERIFY2(!helperBinary().isEmpty(), "Could not find helper binary"); + QVERIFY2(!m_helperBinary.isEmpty(), "Could not find helper binary"); } void tst_QSystemSemaphore::init() @@ -193,12 +196,12 @@ void tst_QSystemSemaphore::basicProcesses() QProcess release; release.setProcessChannelMode(QProcess::ForwardedChannels); - acquire.start(helperBinary(), QStringList("acquire")); + acquire.start(m_helperBinary, QStringList("acquire")); QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); acquire.waitForFinished(HELPERWAITTIME); QVERIFY(acquire.state() == QProcess::Running); acquire.kill(); - release.start(helperBinary(), QStringList("release")); + release.start(m_helperBinary, QStringList("release")); QVERIFY2(release.waitForStarted(), "Could not start helper binary"); acquire.waitForFinished(HELPERWAITTIME); release.waitForFinished(HELPERWAITTIME); @@ -227,7 +230,7 @@ void tst_QSystemSemaphore::processes() QProcess *p = new QProcess; p->setProcessChannelMode(QProcess::ForwardedChannels); consumers.append(p); - p->start(helperBinary(), QStringList(scripts.at(i))); + p->start(m_helperBinary, QStringList(scripts.at(i))); } while (!consumers.isEmpty()) { @@ -247,14 +250,14 @@ void tst_QSystemSemaphore::undo() QStringList acquireArguments = QStringList("acquire"); QProcess acquire; acquire.setProcessChannelMode(QProcess::ForwardedChannels); - acquire.start(helperBinary(), acquireArguments); + acquire.start(m_helperBinary, acquireArguments); QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); acquire.waitForFinished(HELPERWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); // At process exit the kernel should auto undo - acquire.start(helperBinary(), acquireArguments); + acquire.start(m_helperBinary, acquireArguments); QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); acquire.waitForFinished(HELPERWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); @@ -273,18 +276,18 @@ void tst_QSystemSemaphore::initialValue() QProcess release; release.setProcessChannelMode(QProcess::ForwardedChannels); - acquire.start(helperBinary(), acquireArguments); + acquire.start(m_helperBinary, acquireArguments); QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); acquire.waitForFinished(HELPERWAITTIME); QVERIFY(acquire.state()== QProcess::NotRunning); - acquire.start(helperBinary(), acquireArguments << QLatin1String("2")); + acquire.start(m_helperBinary, acquireArguments << QLatin1String("2")); QVERIFY2(acquire.waitForStarted(), "Could not start helper binary"); acquire.waitForFinished(HELPERWAITTIME); QVERIFY(acquire.state()== QProcess::Running); acquire.kill(); - release.start(helperBinary(), releaseArguments); + release.start(m_helperBinary, releaseArguments); QVERIFY2(release.waitForStarted(), "Could not start helper binary"); acquire.waitForFinished(HELPERWAITTIME); release.waitForFinished(HELPERWAITTIME); |