summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@nokia.com>2012-01-20 13:13:09 (GMT)
committerQt by Nokia <qt-info@nokia.com>2012-01-20 18:02:13 (GMT)
commitf66f2d2a202b32a703e2719e7eb91ee4d681220c (patch)
tree3c90b3cd5f45cbf65e4fd5cd1ad35c96781f7305
parentb3e18be580bc5eceea00594a62759566b1546d4d (diff)
downloadQt-f66f2d2a202b32a703e2719e7eb91ee4d681220c.zip
Qt-f66f2d2a202b32a703e2719e7eb91ee4d681220c.tar.gz
Qt-f66f2d2a202b32a703e2719e7eb91ee4d681220c.tar.bz2
make tst_QProcess::softExitInSlots pass in under 120 seconds
Due to unconditional waits this test always needed 120 seconds to pass. Now we're using QTRY_VERIFY and make sure that we write the data before the process got killed even in the cases 3 and 4. Change-Id: I4718f2a4f3e53921716c639ae8041114234e9086 Reviewed-by: Bill King <bill.king@nokia.com>
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index 97ab85e..978cf0c 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -39,7 +39,7 @@
**
****************************************************************************/
-
+#include "../../shared/util.h"
#include <QtTest/QtTest>
#include <QtCore/QProcess>
#include <QtCore/QDir>
@@ -1117,9 +1117,21 @@ public:
}
}
+ void writeAfterStart(const char *buf, int count)
+ {
+ dataToWrite = QByteArray(buf, count);
+ }
+
+ void start(const QString &program)
+ {
+ QProcess::start(program);
+ writePendingData();
+ }
+
public slots:
void terminateSlot()
{
+ writePendingData(); // In cases 3 and 4 we haven't written the data yet.
if (killing || (n == 4 && state() != Running)) {
// Don't try to kill the process before it is running - that can
// be hazardous, as the actual child process might not be running
@@ -1142,8 +1154,18 @@ public slots:
}
private:
+ void writePendingData()
+ {
+ if (!dataToWrite.isEmpty()) {
+ write(dataToWrite);
+ dataToWrite.clear();
+ }
+ }
+
+private:
int n;
bool killing;
+ QByteArray dataToWrite;
};
//-----------------------------------------------------------------------------
@@ -1177,11 +1199,10 @@ void tst_QProcess::softExitInSlots()
for (int i = 0; i < 5; ++i) {
SoftExitProcess proc(i);
+ proc.writeAfterStart("OLEBOLE", 8); // include the \0
proc.start(appName);
- proc.write("OLEBOLE", 8); // include the \0
- QTestEventLoop::instance().enterLoop(10);
+ QTRY_VERIFY(proc.waitedForFinished);
QCOMPARE(proc.state(), QProcess::NotRunning);
- QVERIFY(proc.waitedForFinished);
}
}