summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorRolf Eike Beer <eike@sf-mail.de>2013-05-10 18:50:22 (GMT)
committerRolf Eike Beer <eike@sf-mail.de>2013-05-10 18:50:22 (GMT)
commite319e32b8c30d255ceea3ed1e133a7303aea9681 (patch)
treed90b763bae90c28313ac08fd6fdad4c5974ca76a /Source
parentcf4869ba080ead1077bf5f3aa67c5c67a19e1a0d (diff)
downloadCMake-e319e32b8c30d255ceea3ed1e133a7303aea9681.zip
CMake-e319e32b8c30d255ceea3ed1e133a7303aea9681.tar.gz
CMake-e319e32b8c30d255ceea3ed1e133a7303aea9681.tar.bz2
CTest: make sure never to report negative test times (#14132)
Because of clock scew between processors or just because of someone changing the system time the end timestamp may be before the start time. Reporting a negative time doesn't any sense, just report zero there as it already happens for really fast tests.
Diffstat (limited to 'Source')
-rw-r--r--Source/CTest/cmProcess.cxx8
1 files changed, 8 insertions, 0 deletions
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 000bc85..167b992 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -175,6 +175,14 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
// Record exit information.
this->ExitValue = cmsysProcess_GetExitValue(this->Process);
this->TotalTime = cmSystemTools::GetTime() - this->StartTime;
+ // Because of a processor clock scew the runtime may become slightly
+ // negative. If someone changed the system clock while the process was
+ // running this may be even more. Make sure not to report a negative
+ // duration here.
+ if (this->TotalTime <= 0.0)
+ {
+ this->TotalTime = 0.0;
+ }
// std::cerr << "Time to run: " << this->TotalTime << "\n";
return cmsysProcess_Pipe_None;
}