Process test: Adjust timeouts to minimize a chance for flakiness

The flakiness happened on mac inside recursiveBlockingProcess test.

Change-Id: I4d461fcdae1ecbf29f89bfdb4ad7ba017724f14b
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
Jarek Kobus
2023-11-03 11:45:08 +01:00
parent 0b322ef178
commit f915a18a9e
2 changed files with 9 additions and 6 deletions

View File

@@ -245,7 +245,7 @@ int ProcessTestApp::RecursiveBlockingProcess::main()
std::cout << s_leafProcessStarted << std::flush; std::cout << s_leafProcessStarted << std::flush;
while (true) { while (true) {
// TODO: make it configurable so that we could test the reaper timeout // TODO: make it configurable so that we could test the reaper timeout
QThread::msleep(100); QThread::msleep(10);
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
if (s_terminate.load()) { if (s_terminate.load()) {
std::cout << s_leafProcessTerminated << std::flush; std::cout << s_leafProcessTerminated << std::flush;
@@ -260,7 +260,7 @@ int ProcessTestApp::RecursiveBlockingProcess::main()
process.setProcessChannelMode(QProcess::ForwardedChannels); process.setProcessChannelMode(QProcess::ForwardedChannels);
process.start(); process.start();
while (true) { while (true) {
if (process.waitForFinished(1000)) if (process.waitForFinished(10))
return 0; return 0;
#ifndef Q_OS_WIN #ifndef Q_OS_WIN
if (s_terminate.load()) { if (s_terminate.load()) {

View File

@@ -1370,14 +1370,17 @@ void tst_Process::recursiveBlockingProcess()
subConfig.setupSubProcess(&process); subConfig.setupSubProcess(&process);
process.start(); process.start();
QVERIFY(process.waitForStarted(1000)); QVERIFY(process.waitForStarted(1000));
QVERIFY(process.waitForReadyRead(1000)); // The readyRead() is generated from the innermost nested process, so it means
// we need to give enough time for all nested processes to start their
// process launchers successfully.
QVERIFY(process.waitForReadyRead(2000));
QCOMPARE(process.readAllRawStandardOutput(), s_leafProcessStarted); QCOMPARE(process.readAllRawStandardOutput(), s_leafProcessStarted);
QCOMPARE(runningTestProcessCount(), recursionDepth); QCOMPARE(runningTestProcessCount(), recursionDepth);
QVERIFY(!process.waitForFinished(1000)); QVERIFY(!process.waitForFinished(10));
process.terminate(); process.terminate();
QVERIFY(process.waitForReadyRead()); QVERIFY(process.waitForReadyRead(1000));
QCOMPARE(process.readAllRawStandardOutput(), s_leafProcessTerminated); QCOMPARE(process.readAllRawStandardOutput(), s_leafProcessTerminated);
QVERIFY(process.waitForFinished()); QVERIFY(process.waitForFinished(1000));
QCOMPARE(process.exitStatus(), QProcess::NormalExit); QCOMPARE(process.exitStatus(), QProcess::NormalExit);
QCOMPARE(process.exitCode(), s_crashCode); QCOMPARE(process.exitCode(), s_crashCode);
} }