mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-21 06:00:51 -06:00
CTest: use std::chrono::steady_clock for time keeping
It was reported in issue #17345 that CTest does not use monotonic time to report test duration. Monotonic clocks are not affected by large NTP adjustments or things like daylight savings time. As CMake 3.10 requires C++11, which introduced std::chrono, this commit moves the time keeping in CTest from cmSystemTools::GetTime() to std::chrono::steady_clock. Fixes: #17345
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include "cmake.h"
|
#include "cmake.h"
|
||||||
|
|
||||||
#include "cmsys/Process.h"
|
#include "cmsys/Process.h"
|
||||||
|
#include <chrono>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
|
cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
|
||||||
@@ -192,7 +193,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
|||||||
|
|
||||||
// we need to honor the timeout specified, the timeout include cmake, build
|
// we need to honor the timeout specified, the timeout include cmake, build
|
||||||
// and test time
|
// and test time
|
||||||
double clock_start = cmSystemTools::GetTime();
|
auto clock_start = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
// make sure the binary dir is there
|
// make sure the binary dir is there
|
||||||
out << "Internal cmake changing into directory: " << this->BinaryDir
|
out << "Internal cmake changing into directory: " << this->BinaryDir
|
||||||
@@ -222,10 +223,12 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
|||||||
this->BuildTargets.push_back("");
|
this->BuildTargets.push_back("");
|
||||||
}
|
}
|
||||||
for (std::string const& tar : this->BuildTargets) {
|
for (std::string const& tar : this->BuildTargets) {
|
||||||
double remainingTime = 0;
|
std::chrono::duration<double> remainingTime = std::chrono::seconds(0);
|
||||||
if (this->Timeout > 0) {
|
if (this->Timeout > 0) {
|
||||||
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
|
remainingTime = std::chrono::duration<double>(this->Timeout) -
|
||||||
if (remainingTime <= 0) {
|
std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
|
std::chrono::steady_clock::now() - clock_start);
|
||||||
|
if (remainingTime <= std::chrono::seconds(0)) {
|
||||||
if (outstring) {
|
if (outstring) {
|
||||||
*outstring = "--build-and-test timeout exceeded. ";
|
*outstring = "--build-and-test timeout exceeded. ";
|
||||||
}
|
}
|
||||||
@@ -248,7 +251,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
|||||||
int retVal = cm.GetGlobalGenerator()->Build(
|
int retVal = cm.GetGlobalGenerator()->Build(
|
||||||
this->SourceDir, this->BinaryDir, this->BuildProject, tar, output,
|
this->SourceDir, this->BinaryDir, this->BuildProject, tar, output,
|
||||||
this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
|
this->BuildMakeProgram, config, !this->BuildNoClean, false, false,
|
||||||
remainingTime);
|
remainingTime.count());
|
||||||
out << output;
|
out << output;
|
||||||
// if the build failed then return
|
// if the build failed then return
|
||||||
if (retVal) {
|
if (retVal) {
|
||||||
@@ -320,10 +323,12 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
|||||||
out << "\n";
|
out << "\n";
|
||||||
|
|
||||||
// how much time is remaining
|
// how much time is remaining
|
||||||
double remainingTime = 0;
|
std::chrono::duration<double> remainingTime = std::chrono::seconds(0);
|
||||||
if (this->Timeout > 0) {
|
if (this->Timeout > 0) {
|
||||||
remainingTime = this->Timeout - cmSystemTools::GetTime() + clock_start;
|
remainingTime = std::chrono::duration<double>(this->Timeout) -
|
||||||
if (remainingTime <= 0) {
|
std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
|
std::chrono::steady_clock::now() - clock_start);
|
||||||
|
if (remainingTime <= std::chrono::seconds(0)) {
|
||||||
if (outstring) {
|
if (outstring) {
|
||||||
*outstring = "--build-and-test timeout exceeded. ";
|
*outstring = "--build-and-test timeout exceeded. ";
|
||||||
}
|
}
|
||||||
@@ -332,7 +337,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, nullptr,
|
int runTestRes = this->CTest->RunTest(testCommand, &outs, &retval, nullptr,
|
||||||
remainingTime, nullptr);
|
remainingTime.count(), nullptr);
|
||||||
|
|
||||||
if (runTestRes != cmsysProcess_State_Exited || retval != 0) {
|
if (runTestRes != cmsysProcess_State_Exited || retval != 0) {
|
||||||
out << "Test command failed: " << testCommand[0] << "\n";
|
out << "Test command failed: " << testCommand[0] << "\n";
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
static const char* cmCTestErrorMatches[] = {
|
static const char* cmCTestErrorMatches[] = {
|
||||||
"^[Bb]us [Ee]rror",
|
"^[Bb]us [Ee]rror",
|
||||||
@@ -327,7 +328,7 @@ int cmCTestBuildHandler::ProcessHandler()
|
|||||||
|
|
||||||
// Create a last build log
|
// Create a last build log
|
||||||
cmGeneratedFileStream ofs;
|
cmGeneratedFileStream ofs;
|
||||||
double elapsed_time_start = cmSystemTools::GetTime();
|
auto elapsed_time_start = std::chrono::steady_clock::now();
|
||||||
if (!this->StartLogFile("Build", ofs)) {
|
if (!this->StartLogFile("Build", ofs)) {
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file"
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create build log file"
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
@@ -421,7 +422,8 @@ int cmCTestBuildHandler::ProcessHandler()
|
|||||||
// Remember end build time and calculate elapsed time
|
// Remember end build time and calculate elapsed time
|
||||||
this->EndBuild = this->CTest->CurrentTime();
|
this->EndBuild = this->CTest->CurrentTime();
|
||||||
this->EndBuildTime = cmSystemTools::GetTime();
|
this->EndBuildTime = cmSystemTools::GetTime();
|
||||||
double elapsed_build_time = cmSystemTools::GetTime() - elapsed_time_start;
|
auto elapsed_build_time =
|
||||||
|
std::chrono::steady_clock::now() - elapsed_time_start;
|
||||||
|
|
||||||
// Cleanups strings in the errors and warnings list.
|
// Cleanups strings in the errors and warnings list.
|
||||||
if (!this->SimplifySourceDir.empty()) {
|
if (!this->SimplifySourceDir.empty()) {
|
||||||
@@ -633,8 +635,8 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(cmXMLWriter& xml)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
|
void cmCTestBuildHandler::GenerateXMLFooter(
|
||||||
double elapsed_build_time)
|
cmXMLWriter& xml, std::chrono::duration<double> elapsed_build_time)
|
||||||
{
|
{
|
||||||
xml.StartElement("Log");
|
xml.StartElement("Log");
|
||||||
xml.Attribute("Encoding", "base64");
|
xml.Attribute("Encoding", "base64");
|
||||||
@@ -643,8 +645,10 @@ void cmCTestBuildHandler::GenerateXMLFooter(cmXMLWriter& xml,
|
|||||||
|
|
||||||
xml.Element("EndDateTime", this->EndBuild);
|
xml.Element("EndDateTime", this->EndBuild);
|
||||||
xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime));
|
xml.Element("EndBuildTime", static_cast<unsigned int>(this->EndBuildTime));
|
||||||
xml.Element("ElapsedMinutes",
|
xml.Element(
|
||||||
static_cast<int>(elapsed_build_time / 6) / 10.0);
|
"ElapsedMinutes",
|
||||||
|
std::chrono::duration_cast<std::chrono::minutes>(elapsed_build_time)
|
||||||
|
.count());
|
||||||
xml.EndElement(); // Build
|
xml.EndElement(); // Build
|
||||||
this->CTest->EndXML(xml);
|
this->CTest->EndXML(xml);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include "cmProcessOutput.h"
|
#include "cmProcessOutput.h"
|
||||||
#include "cmsys/RegularExpression.hxx"
|
#include "cmsys/RegularExpression.hxx"
|
||||||
|
#include <chrono>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@@ -86,7 +87,8 @@ private:
|
|||||||
void GenerateXMLHeader(cmXMLWriter& xml);
|
void GenerateXMLHeader(cmXMLWriter& xml);
|
||||||
void GenerateXMLLaunched(cmXMLWriter& xml);
|
void GenerateXMLLaunched(cmXMLWriter& xml);
|
||||||
void GenerateXMLLogScraped(cmXMLWriter& xml);
|
void GenerateXMLLogScraped(cmXMLWriter& xml);
|
||||||
void GenerateXMLFooter(cmXMLWriter& xml, double elapsed_build_time);
|
void GenerateXMLFooter(cmXMLWriter& xml,
|
||||||
|
std::chrono::duration<double> elapsed_build_time);
|
||||||
bool IsLaunchedErrorFile(const char* fname);
|
bool IsLaunchedErrorFile(const char* fname);
|
||||||
bool IsLaunchedWarningFile(const char* fname);
|
bool IsLaunchedWarningFile(const char* fname);
|
||||||
|
|
||||||
|
|||||||
@@ -7,8 +7,10 @@
|
|||||||
#include "cmSystemTools.h"
|
#include "cmSystemTools.h"
|
||||||
#include "cmXMLWriter.h"
|
#include "cmXMLWriter.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
cmCTestConfigureHandler::cmCTestConfigureHandler()
|
cmCTestConfigureHandler::cmCTestConfigureHandler()
|
||||||
{
|
{
|
||||||
@@ -43,7 +45,7 @@ int cmCTestConfigureHandler::ProcessHandler()
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double elapsed_time_start = cmSystemTools::GetTime();
|
auto elapsed_time_start = std::chrono::steady_clock::now();
|
||||||
std::string output;
|
std::string output;
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
@@ -84,10 +86,10 @@ int cmCTestConfigureHandler::ProcessHandler()
|
|||||||
xml.Element("EndDateTime", this->CTest->CurrentTime());
|
xml.Element("EndDateTime", this->CTest->CurrentTime());
|
||||||
xml.Element("EndConfigureTime",
|
xml.Element("EndConfigureTime",
|
||||||
static_cast<unsigned int>(cmSystemTools::GetTime()));
|
static_cast<unsigned int>(cmSystemTools::GetTime()));
|
||||||
xml.Element(
|
xml.Element("ElapsedMinutes",
|
||||||
"ElapsedMinutes",
|
std::chrono::duration_cast<std::chrono::minutes>(
|
||||||
static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
|
std::chrono::steady_clock::now() - elapsed_time_start)
|
||||||
10.0);
|
.count());
|
||||||
xml.EndElement(); // Configure
|
xml.EndElement(); // Configure
|
||||||
this->CTest->EndXML(xml);
|
this->CTest->EndXML(xml);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,11 +21,13 @@
|
|||||||
#include "cmsys/Process.h"
|
#include "cmsys/Process.h"
|
||||||
#include "cmsys/RegularExpression.hxx"
|
#include "cmsys/RegularExpression.hxx"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
class cmMakefile;
|
class cmMakefile;
|
||||||
@@ -290,13 +292,14 @@ int cmCTestCoverageHandler::ProcessHandler()
|
|||||||
this->LoadLabels();
|
this->LoadLabels();
|
||||||
|
|
||||||
cmGeneratedFileStream ofs;
|
cmGeneratedFileStream ofs;
|
||||||
double elapsed_time_start = cmSystemTools::GetTime();
|
auto elapsed_time_start = std::chrono::steady_clock::now();
|
||||||
if (!this->StartLogFile("Coverage", ofs)) {
|
if (!this->StartLogFile("Coverage", ofs)) {
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||||
"Cannot create LastCoverage.log file" << std::endl);
|
"Cannot create LastCoverage.log file" << std::endl);
|
||||||
}
|
}
|
||||||
|
|
||||||
ofs << "Performing coverage: " << elapsed_time_start << std::endl;
|
ofs << "Performing coverage: "
|
||||||
|
<< elapsed_time_start.time_since_epoch().count() << std::endl;
|
||||||
this->CleanCoverageLogFiles(ofs);
|
this->CleanCoverageLogFiles(ofs);
|
||||||
|
|
||||||
cmSystemTools::ConvertToUnixSlashes(sourceDir);
|
cmSystemTools::ConvertToUnixSlashes(sourceDir);
|
||||||
@@ -621,10 +624,10 @@ int cmCTestCoverageHandler::ProcessHandler()
|
|||||||
covSumXML.Element("EndDateTime", end_time);
|
covSumXML.Element("EndDateTime", end_time);
|
||||||
covSumXML.Element("EndTime",
|
covSumXML.Element("EndTime",
|
||||||
static_cast<unsigned int>(cmSystemTools::GetTime()));
|
static_cast<unsigned int>(cmSystemTools::GetTime()));
|
||||||
covSumXML.Element(
|
covSumXML.Element("ElapsedMinutes",
|
||||||
"ElapsedMinutes",
|
std::chrono::duration_cast<std::chrono::minutes>(
|
||||||
static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
|
std::chrono::steady_clock::now() - elapsed_time_start)
|
||||||
10.0);
|
.count());
|
||||||
covSumXML.EndElement(); // Coverage
|
covSumXML.EndElement(); // Coverage
|
||||||
this->CTest->EndXML(covSumXML);
|
this->CTest->EndXML(covSumXML);
|
||||||
|
|
||||||
@@ -1963,7 +1966,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
this->CTest->StartXML(xml, this->AppendXML);
|
this->CTest->StartXML(xml, this->AppendXML);
|
||||||
double elapsed_time_start = cmSystemTools::GetTime();
|
auto elapsed_time_start = std::chrono::steady_clock::now();
|
||||||
std::string coverage_start_time = this->CTest->CurrentTime();
|
std::string coverage_start_time = this->CTest->CurrentTime();
|
||||||
xml.StartElement("Coverage");
|
xml.StartElement("Coverage");
|
||||||
xml.Element("StartDateTime", coverage_start_time);
|
xml.Element("StartDateTime", coverage_start_time);
|
||||||
@@ -2090,10 +2093,10 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
|
|||||||
xml.Element("PercentCoverage", SAFEDIV(percent_coverage, number_files));
|
xml.Element("PercentCoverage", SAFEDIV(percent_coverage, number_files));
|
||||||
xml.Element("EndDateTime", end_time);
|
xml.Element("EndDateTime", end_time);
|
||||||
xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
|
xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
|
||||||
xml.Element(
|
xml.Element("ElapsedMinutes",
|
||||||
"ElapsedMinutes",
|
std::chrono::duration_cast<std::chrono::minutes>(
|
||||||
static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
|
std::chrono::steady_clock::now() - elapsed_time_start)
|
||||||
10.0);
|
.count());
|
||||||
xml.EndElement(); // Coverage
|
xml.EndElement(); // Coverage
|
||||||
this->CTest->EndXML(xml);
|
this->CTest->EndXML(xml);
|
||||||
|
|
||||||
|
|||||||
@@ -10,9 +10,11 @@
|
|||||||
#include "cmsys/FStream.hxx"
|
#include "cmsys/FStream.hxx"
|
||||||
#include "cmsys/Glob.hxx"
|
#include "cmsys/Glob.hxx"
|
||||||
#include "cmsys/RegularExpression.hxx"
|
#include "cmsys/RegularExpression.hxx"
|
||||||
|
#include <chrono>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
struct CatToErrorType
|
struct CatToErrorType
|
||||||
{
|
{
|
||||||
@@ -408,8 +410,10 @@ void cmCTestMemCheckHandler::GenerateDartOutput(cmXMLWriter& xml)
|
|||||||
|
|
||||||
xml.Element("EndDateTime", this->EndTest);
|
xml.Element("EndDateTime", this->EndTest);
|
||||||
xml.Element("EndTestTime", this->EndTestTime);
|
xml.Element("EndTestTime", this->EndTestTime);
|
||||||
xml.Element("ElapsedMinutes",
|
xml.Element(
|
||||||
static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
|
"ElapsedMinutes",
|
||||||
|
std::chrono::duration_cast<std::chrono::minutes>(this->ElapsedTestingTime)
|
||||||
|
.count());
|
||||||
|
|
||||||
xml.EndElement(); // DynamicAnalysis
|
xml.EndElement(); // DynamicAnalysis
|
||||||
this->CTest->EndXML(xml);
|
this->CTest->EndXML(xml);
|
||||||
@@ -844,7 +848,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
|
|||||||
cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
|
cmsys::RegularExpression vgABR("== .*pthread_mutex_unlock: mutex is "
|
||||||
"locked by a different thread");
|
"locked by a different thread");
|
||||||
std::vector<std::string::size_type> nonValGrindOutput;
|
std::vector<std::string::size_type> nonValGrindOutput;
|
||||||
double sttime = cmSystemTools::GetTime();
|
auto sttime = std::chrono::steady_clock::now();
|
||||||
cmCTestOptionalLog(this->CTest, DEBUG,
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
||||||
"Start test: " << lines.size() << std::endl, this->Quiet);
|
"Start test: " << lines.size() << std::endl, this->Quiet);
|
||||||
std::string::size_type totalOutputSize = 0;
|
std::string::size_type totalOutputSize = 0;
|
||||||
@@ -918,7 +922,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
|
cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
|
||||||
<< (cmSystemTools::GetTime() - sttime) << std::endl,
|
<< std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
|
std::chrono::steady_clock::now() - sttime)
|
||||||
|
.count()
|
||||||
|
<< "s)" << std::endl,
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
log = ostr.str();
|
log = ostr.str();
|
||||||
this->DefectCount += defects;
|
this->DefectCount += defects;
|
||||||
@@ -929,7 +936,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
|
|||||||
const std::string& str, std::string& log, std::vector<int>& results)
|
const std::string& str, std::string& log, std::vector<int>& results)
|
||||||
{
|
{
|
||||||
log.clear();
|
log.clear();
|
||||||
double sttime = cmSystemTools::GetTime();
|
auto sttime = std::chrono::steady_clock::now();
|
||||||
std::vector<std::string> lines;
|
std::vector<std::string> lines;
|
||||||
cmSystemTools::Split(str.c_str(), lines);
|
cmSystemTools::Split(str.c_str(), lines);
|
||||||
cmCTestOptionalLog(this->CTest, DEBUG,
|
cmCTestOptionalLog(this->CTest, DEBUG,
|
||||||
@@ -961,7 +968,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
|
|||||||
defects++;
|
defects++;
|
||||||
}
|
}
|
||||||
cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
|
cmCTestOptionalLog(this->CTest, DEBUG, "End test (elapsed: "
|
||||||
<< (cmSystemTools::GetTime() - sttime) << std::endl,
|
<< std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
|
std::chrono::steady_clock::now() - sttime)
|
||||||
|
.count()
|
||||||
|
<< "s)" << std::endl,
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
if (defects) {
|
if (defects) {
|
||||||
// only put the output of Bounds Checker if there were
|
// only put the output of Bounds Checker if there were
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "cmsys/Base64.h"
|
#include "cmsys/Base64.h"
|
||||||
#include "cmsys/Process.h"
|
#include "cmsys/Process.h"
|
||||||
#include "cmsys/RegularExpression.hxx"
|
#include "cmsys/RegularExpression.hxx"
|
||||||
|
#include <chrono>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -46,11 +47,12 @@ cmCTestRunTest::~cmCTestRunTest()
|
|||||||
bool cmCTestRunTest::CheckOutput()
|
bool cmCTestRunTest::CheckOutput()
|
||||||
{
|
{
|
||||||
// Read lines for up to 0.1 seconds of total time.
|
// Read lines for up to 0.1 seconds of total time.
|
||||||
double timeout = 0.1;
|
std::chrono::duration<double> timeout = std::chrono::milliseconds(100);
|
||||||
double timeEnd = cmSystemTools::GetTime() + timeout;
|
auto timeEnd = std::chrono::steady_clock::now() + timeout;
|
||||||
std::string line;
|
std::string line;
|
||||||
while ((timeout = timeEnd - cmSystemTools::GetTime(), timeout > 0)) {
|
while ((timeout = timeEnd - std::chrono::steady_clock::now(),
|
||||||
int p = this->TestProcess->GetNextOutputLine(line, timeout);
|
timeout > std::chrono::seconds(0))) {
|
||||||
|
int p = this->TestProcess->GetNextOutputLine(line, timeout.count());
|
||||||
if (p == cmsysProcess_Pipe_None) {
|
if (p == cmsysProcess_Pipe_None) {
|
||||||
// Process has terminated and all output read.
|
// Process has terminated and all output read.
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -5,10 +5,12 @@
|
|||||||
#include "cmsys/Directory.hxx"
|
#include "cmsys/Directory.hxx"
|
||||||
#include "cmsys/Process.h"
|
#include "cmsys/Process.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <ratio>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "cmCTest.h"
|
#include "cmCTest.h"
|
||||||
@@ -79,7 +81,7 @@ cmCTestScriptHandler::cmCTestScriptHandler()
|
|||||||
this->CMake = nullptr;
|
this->CMake = nullptr;
|
||||||
this->GlobalGenerator = nullptr;
|
this->GlobalGenerator = nullptr;
|
||||||
|
|
||||||
this->ScriptStartTime = 0;
|
this->ScriptStartTime = std::chrono::steady_clock::time_point();
|
||||||
|
|
||||||
// the *60 is because the settings are in minutes but GetTime is seconds
|
// the *60 is because the settings are in minutes but GetTime is seconds
|
||||||
this->MinimumInterval = 30 * 60;
|
this->MinimumInterval = 30 * 60;
|
||||||
@@ -111,7 +113,7 @@ void cmCTestScriptHandler::Initialize()
|
|||||||
this->ContinuousDuration = -1;
|
this->ContinuousDuration = -1;
|
||||||
|
|
||||||
// what time in seconds did this script start running
|
// what time in seconds did this script start running
|
||||||
this->ScriptStartTime = 0;
|
this->ScriptStartTime = std::chrono::steady_clock::time_point();
|
||||||
|
|
||||||
delete this->Makefile;
|
delete this->Makefile;
|
||||||
this->Makefile = nullptr;
|
this->Makefile = nullptr;
|
||||||
@@ -158,11 +160,10 @@ void cmCTestScriptHandler::UpdateElapsedTime()
|
|||||||
{
|
{
|
||||||
if (this->Makefile) {
|
if (this->Makefile) {
|
||||||
// set the current elapsed time
|
// set the current elapsed time
|
||||||
char timeString[20];
|
auto itime = std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
int itime = static_cast<unsigned int>(cmSystemTools::GetTime() -
|
std::chrono::steady_clock::now() - this->ScriptStartTime);
|
||||||
this->ScriptStartTime);
|
auto timeString = std::to_string(itime.count());
|
||||||
sprintf(timeString, "%i", itime);
|
this->Makefile->AddDefinition("CTEST_ELAPSED_TIME", timeString.c_str());
|
||||||
this->Makefile->AddDefinition("CTEST_ELAPSED_TIME", timeString);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,7 +508,7 @@ int cmCTestScriptHandler::RunConfigurationScript(
|
|||||||
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
this->ScriptStartTime = cmSystemTools::GetTime();
|
this->ScriptStartTime = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
// read in the script
|
// read in the script
|
||||||
if (pscope) {
|
if (pscope) {
|
||||||
@@ -558,22 +559,27 @@ int cmCTestScriptHandler::RunCurrentScript()
|
|||||||
// for a continuous, do we ned to run it more than once?
|
// for a continuous, do we ned to run it more than once?
|
||||||
if (this->ContinuousDuration >= 0) {
|
if (this->ContinuousDuration >= 0) {
|
||||||
this->UpdateElapsedTime();
|
this->UpdateElapsedTime();
|
||||||
double ending_time = cmSystemTools::GetTime() + this->ContinuousDuration;
|
auto ending_time = std::chrono::steady_clock::now() +
|
||||||
|
std::chrono::duration<double>(this->ContinuousDuration);
|
||||||
if (this->EmptyBinDirOnce) {
|
if (this->EmptyBinDirOnce) {
|
||||||
this->EmptyBinDir = true;
|
this->EmptyBinDir = true;
|
||||||
}
|
}
|
||||||
do {
|
do {
|
||||||
double interval = cmSystemTools::GetTime();
|
auto startOfInterval = std::chrono::steady_clock::now();
|
||||||
result = this->RunConfigurationDashboard();
|
result = this->RunConfigurationDashboard();
|
||||||
interval = cmSystemTools::GetTime() - interval;
|
auto interval = std::chrono::steady_clock::now() - startOfInterval;
|
||||||
if (interval < this->MinimumInterval) {
|
auto minimumInterval =
|
||||||
this->SleepInSeconds(
|
std::chrono::duration<double>(this->MinimumInterval);
|
||||||
static_cast<unsigned int>(this->MinimumInterval - interval));
|
if (interval < minimumInterval) {
|
||||||
|
auto sleepTime = std::chrono::duration_cast<std::chrono::seconds>(
|
||||||
|
minimumInterval - interval)
|
||||||
|
.count();
|
||||||
|
this->SleepInSeconds(static_cast<unsigned int>(sleepTime));
|
||||||
}
|
}
|
||||||
if (this->EmptyBinDirOnce) {
|
if (this->EmptyBinDirOnce) {
|
||||||
this->EmptyBinDir = false;
|
this->EmptyBinDir = false;
|
||||||
}
|
}
|
||||||
} while (cmSystemTools::GetTime() < ending_time);
|
} while (std::chrono::steady_clock::now() < ending_time);
|
||||||
}
|
}
|
||||||
// otherwise just run it once
|
// otherwise just run it once
|
||||||
else {
|
else {
|
||||||
@@ -967,7 +973,9 @@ double cmCTestScriptHandler::GetRemainingTimeAllowed()
|
|||||||
return 1.0e7;
|
return 1.0e7;
|
||||||
}
|
}
|
||||||
|
|
||||||
double timelimit = atof(timelimitS);
|
auto timelimit = std::chrono::duration<double>(atof(timelimitS));
|
||||||
|
|
||||||
return timelimit - cmSystemTools::GetTime() + this->ScriptStartTime;
|
auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(
|
||||||
|
std::chrono::steady_clock::now() - this->ScriptStartTime);
|
||||||
|
return (timelimit - duration).count();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "cmCTestGenericHandler.h"
|
#include "cmCTestGenericHandler.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ public:
|
|||||||
|
|
||||||
void CreateCMake();
|
void CreateCMake();
|
||||||
cmake* GetCMake() { return this->CMake; }
|
cmake* GetCMake() { return this->CMake; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// reads in a script
|
// reads in a script
|
||||||
int ReadInScript(const std::string& total_script_arg);
|
int ReadInScript(const std::string& total_script_arg);
|
||||||
@@ -156,7 +158,7 @@ private:
|
|||||||
double ContinuousDuration;
|
double ContinuousDuration;
|
||||||
|
|
||||||
// what time in seconds did this script start running
|
// what time in seconds did this script start running
|
||||||
double ScriptStartTime;
|
std::chrono::steady_clock::time_point ScriptStartTime;
|
||||||
|
|
||||||
cmMakefile* Makefile;
|
cmMakefile* Makefile;
|
||||||
cmGlobalGenerator* GlobalGenerator;
|
cmGlobalGenerator* GlobalGenerator;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "cm_jsoncpp_reader.h"
|
#include "cm_jsoncpp_reader.h"
|
||||||
#include "cm_jsoncpp_value.h"
|
#include "cm_jsoncpp_value.h"
|
||||||
#include "cmsys/Process.h"
|
#include "cmsys/Process.h"
|
||||||
|
#include <chrono>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -496,10 +497,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
|
|||||||
? ""
|
? ""
|
||||||
: this->GetOption("RetryCount");
|
: this->GetOption("RetryCount");
|
||||||
|
|
||||||
int delay = retryDelay.empty()
|
auto delay = std::chrono::duration<double>(
|
||||||
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
|
retryDelay.empty()
|
||||||
.c_str())
|
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryDelay")
|
||||||
: atoi(retryDelay.c_str());
|
.c_str())
|
||||||
|
: atoi(retryDelay.c_str()));
|
||||||
int count = retryCount.empty()
|
int count = retryCount.empty()
|
||||||
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
|
? atoi(this->CTest->GetCTestConfiguration("CTestSubmitRetryCount")
|
||||||
.c_str())
|
.c_str())
|
||||||
@@ -507,12 +509,12 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
|
|||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
||||||
" Submit failed, waiting " << delay
|
" Submit failed, waiting " << delay.count()
|
||||||
<< " seconds...\n",
|
<< " seconds...\n",
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
|
|
||||||
double stop = cmSystemTools::GetTime() + delay;
|
auto stop = std::chrono::steady_clock::now() + delay;
|
||||||
while (cmSystemTools::GetTime() < stop) {
|
while (std::chrono::steady_clock::now() < stop) {
|
||||||
cmSystemTools::Delay(100);
|
cmSystemTools::Delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1031,11 +1033,15 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
|
|||||||
std::string retryCountString = this->GetOption("RetryCount") == nullptr
|
std::string retryCountString = this->GetOption("RetryCount") == nullptr
|
||||||
? ""
|
? ""
|
||||||
: this->GetOption("RetryCount");
|
: this->GetOption("RetryCount");
|
||||||
unsigned long retryDelay = 0;
|
auto retryDelay = std::chrono::seconds(0);
|
||||||
if (!retryDelayString.empty()) {
|
if (!retryDelayString.empty()) {
|
||||||
if (!cmSystemTools::StringToULong(retryDelayString.c_str(), &retryDelay)) {
|
unsigned long retryDelayValue = 0;
|
||||||
|
if (!cmSystemTools::StringToULong(retryDelayString.c_str(),
|
||||||
|
&retryDelayValue)) {
|
||||||
cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
|
cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : "
|
||||||
<< retryDelayString << std::endl);
|
<< retryDelayString << std::endl);
|
||||||
|
} else {
|
||||||
|
retryDelay = std::chrono::seconds(retryDelayValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unsigned long retryCount = 0;
|
unsigned long retryCount = 0;
|
||||||
@@ -1087,12 +1093,12 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
|
|||||||
// If request failed, wait and retry.
|
// If request failed, wait and retry.
|
||||||
for (unsigned long i = 0; i < retryCount; i++) {
|
for (unsigned long i = 0; i < retryCount; i++) {
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
||||||
" Request failed, waiting " << retryDelay
|
" Request failed, waiting " << retryDelay.count()
|
||||||
<< " seconds...\n",
|
<< " seconds...\n",
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
|
|
||||||
double stop = cmSystemTools::GetTime() + static_cast<double>(retryDelay);
|
auto stop = std::chrono::steady_clock::now() + retryDelay;
|
||||||
while (cmSystemTools::GetTime() < stop) {
|
while (std::chrono::steady_clock::now() < stop) {
|
||||||
cmSystemTools::Delay(100);
|
cmSystemTools::Delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1161,12 +1167,12 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
|
|||||||
// If upload failed, wait and retry.
|
// If upload failed, wait and retry.
|
||||||
for (unsigned long i = 0; i < retryCount; i++) {
|
for (unsigned long i = 0; i < retryCount; i++) {
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
||||||
" Upload failed, waiting " << retryDelay
|
" Upload failed, waiting " << retryDelay.count()
|
||||||
<< " seconds...\n",
|
<< " seconds...\n",
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
|
|
||||||
double stop = cmSystemTools::GetTime() + static_cast<double>(retryDelay);
|
auto stop = std::chrono::steady_clock::now() + retryDelay;
|
||||||
while (cmSystemTools::GetTime() < stop) {
|
while (std::chrono::steady_clock::now() < stop) {
|
||||||
cmSystemTools::Delay(100);
|
cmSystemTools::Delay(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
#include "cmCTestTestHandler.h"
|
#include "cmCTestTestHandler.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
#include <cmsys/Base64.h>
|
#include <cmsys/Base64.h>
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
#include <cmsys/RegularExpression.hxx>
|
#include <cmsys/RegularExpression.hxx>
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
#include "cmAlgorithms.h"
|
#include "cmAlgorithms.h"
|
||||||
#include "cmCTest.h"
|
#include "cmCTest.h"
|
||||||
@@ -346,7 +348,7 @@ void cmCTestTestHandler::Initialize()
|
|||||||
{
|
{
|
||||||
this->Superclass::Initialize();
|
this->Superclass::Initialize();
|
||||||
|
|
||||||
this->ElapsedTestingTime = -1;
|
this->ElapsedTestingTime = std::chrono::duration<double>();
|
||||||
|
|
||||||
this->TestResults.clear();
|
this->TestResults.clear();
|
||||||
|
|
||||||
@@ -484,12 +486,11 @@ int cmCTestTestHandler::ProcessHandler()
|
|||||||
int total;
|
int total;
|
||||||
|
|
||||||
// start the real time clock
|
// start the real time clock
|
||||||
double clock_start, clock_finish;
|
auto clock_start = std::chrono::steady_clock::now();
|
||||||
clock_start = cmSystemTools::GetTime();
|
|
||||||
|
|
||||||
this->ProcessDirectory(passed, failed);
|
this->ProcessDirectory(passed, failed);
|
||||||
|
|
||||||
clock_finish = cmSystemTools::GetTime();
|
auto clock_finish = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
total = int(passed.size()) + int(failed.size());
|
total = int(passed.size()) + int(failed.size());
|
||||||
|
|
||||||
@@ -540,7 +541,10 @@ int cmCTestTestHandler::ProcessHandler()
|
|||||||
this->PrintLabelOrSubprojectSummary(false);
|
this->PrintLabelOrSubprojectSummary(false);
|
||||||
}
|
}
|
||||||
char realBuf[1024];
|
char realBuf[1024];
|
||||||
sprintf(realBuf, "%6.2f sec", clock_finish - clock_start);
|
auto durationInMs = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
clock_finish - clock_start)
|
||||||
|
.count();
|
||||||
|
sprintf(realBuf, "%6.2f sec", static_cast<double>(durationInMs) / 1000.0);
|
||||||
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
||||||
"\nTotal Test time (real) = " << realBuf << "\n",
|
"\nTotal Test time (real) = " << realBuf << "\n",
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
@@ -1201,7 +1205,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
|
|||||||
this->ComputeTestList();
|
this->ComputeTestList();
|
||||||
this->StartTest = this->CTest->CurrentTime();
|
this->StartTest = this->CTest->CurrentTime();
|
||||||
this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
|
this->StartTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
|
||||||
double elapsed_time_start = cmSystemTools::GetTime();
|
auto elapsed_time_start = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs()
|
cmCTestMultiProcessHandler* parallel = this->CTest->GetBatchJobs()
|
||||||
? new cmCTestBatchTestHandler
|
? new cmCTestBatchTestHandler
|
||||||
@@ -1268,7 +1272,8 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string>& passed,
|
|||||||
delete parallel;
|
delete parallel;
|
||||||
this->EndTest = this->CTest->CurrentTime();
|
this->EndTest = this->CTest->CurrentTime();
|
||||||
this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
|
this->EndTestTime = static_cast<unsigned int>(cmSystemTools::GetTime());
|
||||||
this->ElapsedTestingTime = cmSystemTools::GetTime() - elapsed_time_start;
|
this->ElapsedTestingTime =
|
||||||
|
std::chrono::steady_clock::now() - elapsed_time_start;
|
||||||
*this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl;
|
*this->LogFile << "End testing: " << this->CTest->CurrentTime() << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1373,8 +1378,10 @@ void cmCTestTestHandler::GenerateDartOutput(cmXMLWriter& xml)
|
|||||||
|
|
||||||
xml.Element("EndDateTime", this->EndTest);
|
xml.Element("EndDateTime", this->EndTest);
|
||||||
xml.Element("EndTestTime", this->EndTestTime);
|
xml.Element("EndTestTime", this->EndTestTime);
|
||||||
xml.Element("ElapsedMinutes",
|
xml.Element(
|
||||||
static_cast<int>(this->ElapsedTestingTime / 6) / 10.0);
|
"ElapsedMinutes",
|
||||||
|
std::chrono::duration_cast<std::chrono::minutes>(this->ElapsedTestingTime)
|
||||||
|
.count());
|
||||||
xml.EndElement(); // Testing
|
xml.EndElement(); // Testing
|
||||||
this->CTest->EndXML(xml);
|
this->CTest->EndXML(xml);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "cmCTestGenericHandler.h"
|
#include "cmCTestGenericHandler.h"
|
||||||
|
|
||||||
#include "cmsys/RegularExpression.hxx"
|
#include "cmsys/RegularExpression.hxx"
|
||||||
|
#include <chrono>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
@@ -198,7 +199,7 @@ protected:
|
|||||||
//! Clean test output to specified length
|
//! Clean test output to specified length
|
||||||
bool CleanTestOutput(std::string& output, size_t length);
|
bool CleanTestOutput(std::string& output, size_t length);
|
||||||
|
|
||||||
double ElapsedTestingTime;
|
std::chrono::duration<double> ElapsedTestingTime;
|
||||||
|
|
||||||
typedef std::vector<cmCTestTestResult> TestResultsVector;
|
typedef std::vector<cmCTestTestResult> TestResultsVector;
|
||||||
TestResultsVector TestResults;
|
TestResultsVector TestResults;
|
||||||
|
|||||||
@@ -17,8 +17,10 @@
|
|||||||
#include "cmVersion.h"
|
#include "cmVersion.h"
|
||||||
#include "cmXMLWriter.h"
|
#include "cmXMLWriter.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <memory> // IWYU pragma: keep
|
#include <memory> // IWYU pragma: keep
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
static const char* cmCTestUpdateHandlerUpdateStrings[] = {
|
static const char* cmCTestUpdateHandlerUpdateStrings[] = {
|
||||||
"Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
|
"Unknown", "CVS", "SVN", "BZR", "GIT", "HG", "P4"
|
||||||
@@ -177,7 +179,7 @@ int cmCTestUpdateHandler::ProcessHandler()
|
|||||||
std::string start_time = this->CTest->CurrentTime();
|
std::string start_time = this->CTest->CurrentTime();
|
||||||
unsigned int start_time_time =
|
unsigned int start_time_time =
|
||||||
static_cast<unsigned int>(cmSystemTools::GetTime());
|
static_cast<unsigned int>(cmSystemTools::GetTime());
|
||||||
double elapsed_time_start = cmSystemTools::GetTime();
|
auto elapsed_time_start = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
bool updated = vc->Update();
|
bool updated = vc->Update();
|
||||||
std::string buildname =
|
std::string buildname =
|
||||||
@@ -225,10 +227,10 @@ int cmCTestUpdateHandler::ProcessHandler()
|
|||||||
std::string end_time = this->CTest->CurrentTime();
|
std::string end_time = this->CTest->CurrentTime();
|
||||||
xml.Element("EndDateTime", end_time);
|
xml.Element("EndDateTime", end_time);
|
||||||
xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
|
xml.Element("EndTime", static_cast<unsigned int>(cmSystemTools::GetTime()));
|
||||||
xml.Element(
|
xml.Element("ElapsedMinutes",
|
||||||
"ElapsedMinutes",
|
std::chrono::duration_cast<std::chrono::minutes>(
|
||||||
static_cast<int>((cmSystemTools::GetTime() - elapsed_time_start) / 6) /
|
std::chrono::steady_clock::now() - elapsed_time_start)
|
||||||
10.0);
|
.count());
|
||||||
|
|
||||||
xml.StartElement("UpdateReturnStatus");
|
xml.StartElement("UpdateReturnStatus");
|
||||||
if (localModifications) {
|
if (localModifications) {
|
||||||
|
|||||||
@@ -3,8 +3,8 @@
|
|||||||
#include "cmProcess.h"
|
#include "cmProcess.h"
|
||||||
|
|
||||||
#include "cmProcessOutput.h"
|
#include "cmProcessOutput.h"
|
||||||
#include "cmSystemTools.h"
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
cmProcess::cmProcess()
|
cmProcess::cmProcess()
|
||||||
{
|
{
|
||||||
@@ -13,7 +13,7 @@ cmProcess::cmProcess()
|
|||||||
this->TotalTime = 0;
|
this->TotalTime = 0;
|
||||||
this->ExitValue = 0;
|
this->ExitValue = 0;
|
||||||
this->Id = 0;
|
this->Id = 0;
|
||||||
this->StartTime = 0;
|
this->StartTime = std::chrono::steady_clock::time_point();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmProcess::~cmProcess()
|
cmProcess::~cmProcess()
|
||||||
@@ -35,7 +35,7 @@ bool cmProcess::StartProcess()
|
|||||||
if (this->Command.empty()) {
|
if (this->Command.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this->StartTime = cmSystemTools::GetTime();
|
this->StartTime = std::chrono::steady_clock::now();
|
||||||
this->ProcessArgs.clear();
|
this->ProcessArgs.clear();
|
||||||
// put the command as arg0
|
// put the command as arg0
|
||||||
this->ProcessArgs.push_back(this->Command.c_str());
|
this->ProcessArgs.push_back(this->Command.c_str());
|
||||||
@@ -143,7 +143,11 @@ int cmProcess::GetNextOutputLine(std::string& line, double timeout)
|
|||||||
|
|
||||||
// Record exit information.
|
// Record exit information.
|
||||||
this->ExitValue = cmsysProcess_GetExitValue(this->Process);
|
this->ExitValue = cmsysProcess_GetExitValue(this->Process);
|
||||||
this->TotalTime = cmSystemTools::GetTime() - this->StartTime;
|
this->TotalTime =
|
||||||
|
static_cast<double>(std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
std::chrono::steady_clock::now() - this->StartTime)
|
||||||
|
.count()) /
|
||||||
|
1000.0;
|
||||||
// Because of a processor clock scew the runtime may become slightly
|
// Because of a processor clock scew the runtime may become slightly
|
||||||
// negative. If someone changed the system clock while the process was
|
// negative. If someone changed the system clock while the process was
|
||||||
// running this may be even more. Make sure not to report a negative
|
// running this may be even more. Make sure not to report a negative
|
||||||
@@ -231,7 +235,7 @@ void cmProcess::ChangeTimeout(double t)
|
|||||||
void cmProcess::ResetStartTime()
|
void cmProcess::ResetStartTime()
|
||||||
{
|
{
|
||||||
cmsysProcess_ResetStartTime(this->Process);
|
cmsysProcess_ResetStartTime(this->Process);
|
||||||
this->StartTime = cmSystemTools::GetTime();
|
this->StartTime = std::chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
|
|
||||||
int cmProcess::GetExitException()
|
int cmProcess::GetExitException()
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include "cmsys/Process.h"
|
#include "cmsys/Process.h"
|
||||||
|
#include <chrono>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
double Timeout;
|
double Timeout;
|
||||||
double StartTime;
|
std::chrono::steady_clock::time_point StartTime;
|
||||||
double TotalTime;
|
double TotalTime;
|
||||||
cmsysProcess* Process;
|
cmsysProcess* Process;
|
||||||
class Buffer : public std::vector<char>
|
class Buffer : public std::vector<char>
|
||||||
|
|||||||
Reference in New Issue
Block a user