summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2015-05-24 00:00:16 +0200
committerBrad King <brad.king@kitware.com>2015-05-26 11:09:20 -0400
commit18825bafd99c6a9c8ec1fb4e7b22a8059c680572 (patch)
tree0ef7900e223d754b0f427e2d9236948e2b0a148d
parentf6413400a00362cf307d0fbb85daf96265091686 (diff)
downloadcmake-18825bafd99c6a9c8ec1fb4e7b22a8059c680572.tar.gz
cmCTest: Port to cmXMLWriter
Re-implement StartXML, EndXML, and AddSiteProperties using cmXMLWriter. Leave the old overloads behind for use by CTest/* until they are ported.
-rw-r--r--Source/cmCTest.cxx117
-rw-r--r--Source/cmCTest.h4
2 files changed, 121 insertions, 0 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 211c83c536..48a7ec7410 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -28,6 +28,7 @@
#include "cmCTestStartCommand.h"
#include "cmAlgorithms.h"
#include "cmState.h"
+#include "cmXMLWriter.h"
#include "cmCTestBuildHandler.h"
#include "cmCTestBuildAndTestHandler.h"
@@ -1548,6 +1549,67 @@ void cmCTest::StartXML(std::ostream& ostr, bool append)
}
//----------------------------------------------------------------------
+void cmCTest::StartXML(cmXMLWriter& xml, bool append)
+{
+ if(this->CurrentTag.empty())
+ {
+ cmCTestLog(this, ERROR_MESSAGE,
+ "Current Tag empty, this may mean"
+ " NightlStartTime was not set correctly." << std::endl);
+ cmSystemTools::SetFatalErrorOccured();
+ }
+
+ // find out about the system
+ cmsys::SystemInformation info;
+ info.RunCPUCheck();
+ info.RunOSCheck();
+ info.RunMemoryCheck();
+
+ std::string buildname = cmCTest::SafeBuildIdField(
+ this->GetCTestConfiguration("BuildName"));
+ std::string stamp = cmCTest::SafeBuildIdField(
+ this->CurrentTag + "-" + this->GetTestModelString());
+ std::string site = cmCTest::SafeBuildIdField(
+ this->GetCTestConfiguration("Site"));
+
+ xml.StartDocument();
+ xml.StartElement("Site");
+ xml.Attribute("BuildName", buildname);
+ xml.BreakAttributes();
+ xml.Attribute("BuildStamp", stamp);
+ xml.Attribute("Name", site);
+ xml.Attribute("Generator",
+ std::string("ctest-") + cmVersion::GetCMakeVersion());
+ if(append)
+ {
+ xml.Attribute("Append", "true");
+ }
+ xml.Attribute("CompilerName", this->GetCTestConfiguration("Compiler"));
+#ifdef _COMPILER_VERSION
+ xml.Attribute("CompilerVersion", _COMPILER_VERSION);
+#endif
+ xml.Attribute("OSName", info.GetOSName());
+ xml.Attribute("Hostname", info.GetHostname());
+ xml.Attribute("OSRelease", info.GetOSRelease());
+ xml.Attribute("OSVersion", info.GetOSVersion());
+ xml.Attribute("OSPlatform", info.GetOSPlatform());
+ xml.Attribute("Is64Bits", info.Is64Bits());
+ xml.Attribute("VendorString", info.GetVendorString());
+ xml.Attribute("VendorID", info.GetVendorID());
+ xml.Attribute("FamilyID", info.GetFamilyID());
+ xml.Attribute("ModelID", info.GetModelID());
+ xml.Attribute("ProcessorCacheSize", info.GetProcessorCacheSize());
+ xml.Attribute("NumberOfLogicalCPU", info.GetNumberOfLogicalCPU());
+ xml.Attribute("NumberOfPhysicalCPU", info.GetNumberOfPhysicalCPU());
+ xml.Attribute("TotalVirtualMemory", info.GetTotalVirtualMemory());
+ xml.Attribute("TotalPhysicalMemory", info.GetTotalPhysicalMemory());
+ xml.Attribute("LogicalProcessorsPerPhysical",
+ info.GetLogicalProcessorsPerPhysical());
+ xml.Attribute("ProcessorClockFrequency", info.GetProcessorClockFrequency());
+ this->AddSiteProperties(xml);
+}
+
+//----------------------------------------------------------------------
void cmCTest::AddSiteProperties(std::ostream& ostr)
{
cmCTestScriptHandler* ch =
@@ -1594,6 +1656,54 @@ void cmCTest::AddSiteProperties(std::ostream& ostr)
}
}
+//----------------------------------------------------------------------
+void cmCTest::AddSiteProperties(cmXMLWriter& xml)
+{
+ cmCTestScriptHandler* ch =
+ static_cast<cmCTestScriptHandler*>(this->GetHandler("script"));
+ cmake* cm = ch->GetCMake();
+ // if no CMake then this is the old style script and props like
+ // this will not work anyway.
+ if(!cm)
+ {
+ return;
+ }
+ // This code should go when cdash is changed to use labels only
+ const char* subproject = cm->GetState()
+ ->GetGlobalProperty("SubProject");
+ if(subproject)
+ {
+ xml.StartElement("Subproject");
+ xml.Attribute("name", subproject);
+ const char* labels =
+ ch->GetCMake()->GetState()
+ ->GetGlobalProperty("SubProjectLabels");
+ if(labels)
+ {
+ xml.StartElement("Labels");
+ std::string l = labels;
+ std::vector<std::string> args;
+ cmSystemTools::ExpandListArgument(l, args);
+ for(std::vector<std::string>::iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ xml.Element("Label", *i);
+ }
+ xml.EndElement();
+ }
+ xml.EndElement();
+ }
+
+ // This code should stay when cdash only does label based sub-projects
+ const char* label = cm->GetState()->GetGlobalProperty("Label");
+ if(label)
+ {
+ xml.StartElement("Labels");
+ xml.Element("Label", label);
+ xml.EndElement();
+ }
+}
+
//----------------------------------------------------------------------
void cmCTest::EndXML(std::ostream& ostr)
@@ -1602,6 +1712,13 @@ void cmCTest::EndXML(std::ostream& ostr)
}
//----------------------------------------------------------------------
+void cmCTest::EndXML(cmXMLWriter& xml)
+{
+ xml.EndElement(); // Site
+ xml.EndDocument();
+}
+
+//----------------------------------------------------------------------
int cmCTest::GenerateCTestNotesOutput(std::ostream& os,
const cmCTest::VectorOfStrings& files)
{
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 3f033d9e3c..47c337a73a 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -24,6 +24,7 @@ class cmGeneratedFileStream;
class cmCTestCommand;
class cmCTestScriptHandler;
class cmCTestStartCommand;
+class cmXMLWriter;
#define cmCTestLog(ctSelf, logType, msg) \
do { \
@@ -274,9 +275,11 @@ public:
//! Start CTest XML output file
void StartXML(std::ostream& ostr, bool append);
+ void StartXML(cmXMLWriter& xml, bool append);
//! End CTest XML output file
void EndXML(std::ostream& ostr);
+ void EndXML(cmXMLWriter& xml);
//! Run command specialized for make and configure. Returns process status
// and retVal is return value or exception.
@@ -421,6 +424,7 @@ public:
void SetStreams(std::ostream* out, std::ostream* err)
{ this->StreamOut = out; this->StreamErr = err; }
void AddSiteProperties(std::ostream& );
+ void AddSiteProperties(cmXMLWriter& xml);
bool GetLabelSummary() { return this->LabelSummary;}
std::string GetCostDataFile();