summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-03-31 13:19:07 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-03-31 13:25:26 (GMT)
commit2d13592054d1d6f049ecc1599913cb8c7541ef69 (patch)
tree9641ba999af5df2b09d4159dde924d21a2818a59 /tests
parent9562f4a39ca9ca2c59bd621ac8e33af8b8006043 (diff)
downloadQt-2d13592054d1d6f049ecc1599913cb8c7541ef69.zip
Qt-2d13592054d1d6f049ecc1599913cb8c7541ef69.tar.gz
Qt-2d13592054d1d6f049ecc1599913cb8c7541ef69.tar.bz2
QProcess::start() segfaults on empty program
Handle cases where QProcess::start() and startDetached() are passed a null, empty, or "invalid" program string instead of crashing. Task-number: 247865 Reviewed-by: Andreas Aardal Hanssen
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index f0dae5d..cb2b1bf 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -139,6 +139,8 @@ private slots:
void switchReadChannels();
void setWorkingDirectory();
void startFinishStartFinish();
+ void invalidProgramString_data();
+ void invalidProgramString();
// keep these at the end, since they use lots of processes and sometimes
// caused obscure failures to occur in tests that followed them (esp. on the Mac)
@@ -2000,5 +2002,29 @@ void tst_QProcess::startFinishStartFinish()
}
}
+//-----------------------------------------------------------------------------
+void tst_QProcess::invalidProgramString_data()
+{
+ QTest::addColumn<QString>("programString");
+ QTest::newRow("null string") << QString();
+ QTest::newRow("empty string") << QString("");
+ QTest::newRow("only blank string") << QString(" ");
+}
+
+void tst_QProcess::invalidProgramString()
+{
+ QFETCH(QString, programString);
+ QProcess process;
+
+ qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
+ QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError)));
+
+ process.start(programString);
+ QCOMPARE(process.error(), QProcess::FailedToStart);
+ QCOMPARE(spy.count(), 1);
+
+ QVERIFY(!QProcess::startDetached(programString));
+}
+
QTEST_MAIN(tst_QProcess)
#include "tst_qprocess.moc"