summaryrefslogtreecommitdiffstats
path: root/tests/auto/qprocess
diff options
context:
space:
mode:
authorShane Kearns <shane.kearns@accenture.com>2010-10-14 14:42:34 +0100
committerShane Kearns <shane.kearns@accenture.com>2010-10-19 09:35:20 +0100
commita2a748f59a14f71c7f7cd5762ae9d358af2518c3 (patch)
tree7b8733684e170c1c0de32074b33fbe388de32a7b /tests/auto/qprocess
parent9ea66f867c1aeb60dc4e90acefb2258a084740ca (diff)
Fix crashes and hangs in qprocess autotest
The qprocess autotest launches various sub processes and checks their results, but this lacked error handling. Added a QVERIFY when opening files (if fopen returned NULL, the test fails instead of crashing) Added a 10s guard when waiting for a subprocess to create a file - previously this loop did not terminate if the subprocess failed. Reviewed-By: Markus Goetz
Diffstat (limited to 'tests/auto/qprocess')
-rw-r--r--tests/auto/qprocess/tst_qprocess.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp
index fd310f417b..a497b1301a 100644
--- a/tests/auto/qprocess/tst_qprocess.cpp
+++ b/tests/auto/qprocess/tst_qprocess.cpp
@@ -1585,6 +1585,7 @@ void tst_QProcess::spaceArgsTest()
#if defined(Q_OS_SYMBIAN)
// Symbian test outputs to a file, so check that
FILE* file = fopen("c:\\logs\\qprocess_args_test.txt","r");
+ QVERIFY(file);
char buf[256];
fgets(buf, 256, file);
fclose(file);
@@ -1614,6 +1615,7 @@ void tst_QProcess::spaceArgsTest()
#if defined(Q_OS_SYMBIAN)
// Symbian test outputs to a file, so check that
file = fopen("c:\\logs\\qprocess_args_test.txt","r");
+ QVERIFY(file);
fgets(buf, 256, file);
fclose(file);
actual = QString::fromLatin1(buf).split("|");
@@ -1661,6 +1663,7 @@ void tst_QProcess::nativeArguments()
# else
FILE* file = fopen("\\temp\\qprocess_args_test.txt","r");
# endif
+ QVERIFY(file);
char buf[256];
fgets(buf, 256, file);
fclose(file);
@@ -2285,7 +2288,9 @@ void tst_QProcess::detachedWorkingDirectoryAndPid()
QFileInfo fi(infoFile);
fi.setCaching(false);
- while (fi.size() == 0) {
+ //The guard counter ensures the test does not hang if the sub process fails.
+ //Instead, the test will fail when trying to open & verify the sub process output file.
+ for (int guard = 0; guard < 100 && fi.size() == 0; guard++) {
QTest::qSleep(100);
}
@@ -2397,6 +2402,7 @@ void tst_QProcess::startFinishStartFinish()
#if defined(Q_OS_SYMBIAN)
// Symbian test outputs to a file, so check that
FILE* file = fopen("c:\\logs\\qprocess_output_test.txt","r");
+ QVERIFY(file);
char buf[30];
fgets(buf, 30, file);
QCOMPARE(QString::fromLatin1(buf),