diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2010-10-14 13:42:34 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2010-10-19 08:35:20 (GMT) |
commit | a2a748f59a14f71c7f7cd5762ae9d358af2518c3 (patch) | |
tree | 7b8733684e170c1c0de32074b33fbe388de32a7b /tests | |
parent | 9ea66f867c1aeb60dc4e90acefb2258a084740ca (diff) | |
download | Qt-a2a748f59a14f71c7f7cd5762ae9d358af2518c3.zip Qt-a2a748f59a14f71c7f7cd5762ae9d358af2518c3.tar.gz Qt-a2a748f59a14f71c7f7cd5762ae9d358af2518c3.tar.bz2 |
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')
-rw-r--r-- | tests/auto/qprocess/tst_qprocess.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index fd310f4..a497b13 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), |