Commit e60a7a69 authored by Christian Stenger's avatar Christian Stenger
Browse files

Avoid possible race condition



Change-Id: I12988ad9583740b2c72d8e40e68414a7cba08364
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 3b423602
......@@ -180,8 +180,13 @@ static void performTestRun(QFutureInterface<TestResult *> &futureInterface,
bool ok = testProcess.waitForStarted();
QTime executionTimer;
executionTimer.start();
bool canceledByTimeout = false;
if (ok) {
while (testProcess.state() == QProcess::Running && executionTimer.elapsed() < timeout) {
while (testProcess.state() == QProcess::Running) {
if (executionTimer.elapsed() >= timeout) {
canceledByTimeout = true;
break;
}
if (futureInterface.isCanceled()) {
testProcess.kill();
testProcess.waitForFinished();
......@@ -191,13 +196,13 @@ static void performTestRun(QFutureInterface<TestResult *> &futureInterface,
}
}
if (executionTimer.elapsed() >= timeout) {
if (canceledByTimeout) {
if (testProcess.state() != QProcess::NotRunning) {
testProcess.kill();
testProcess.waitForFinished();
futureInterface.reportResult(new FaultyTestResult(Result::MessageFatal, QObject::tr(
"Test case canceled due to timeout. \nMaybe raise the timeout?")));
}
futureInterface.reportResult(new FaultyTestResult(Result::MessageFatal, QObject::tr(
"Test case canceled due to timeout. \nMaybe raise the timeout?")));
}
}
futureInterface.setProgressValue(testCaseCount);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment