diff options
author | Joerg Bornemann <joerg.bornemann@nokia.com> | 2012-01-20 14:13:09 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-20 14:20:51 +0100 |
commit | 06abf7934b4491f36d9542c024d031d27378b423 (patch) | |
tree | fd2d7c86df568b7cb41bb5d8a86aff0dd1720e83 /tests | |
parent | 91fa4b7043f85e6eb0a665f42fddccbf1d48689c (diff) |
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.
On my machine this test now takes 8 seconds.
Change-Id: I606a8b43ba4c97704be5202a6c5d8d1c75337f9c
Reviewed-by: Bill King <bill.king@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index e16e00de91..2d5b879c41 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -1000,9 +1000,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 @@ -1025,8 +1037,18 @@ public slots: } private: + void writePendingData() + { + if (!dataToWrite.isEmpty()) { + write(dataToWrite); + dataToWrite.clear(); + } + } + +private: int n; bool killing; + QByteArray dataToWrite; }; //----------------------------------------------------------------------------- @@ -1049,11 +1071,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); } } |