35#include <boost/algorithm/string.hpp>
36#include <boost/core/ignore_unused.hpp>
37#include <boost/lexical_cast.hpp>
66 boost::ignore_unused(pSrc);
78 "Command ID '" + std::to_string(pId) +
"' not found");
94 "Missing 'type' attribute in metric " +
95 boost::lexical_cast<string>(pId) +
").");
96 return boost::to_upper_copy(
string(
m_metrics[pId]->Attribute(
"type")));
117 const char *
id =
m_metrics[pId]->Attribute(
"id");
118 ASSERTL0(
id,
"No ID found for metric!");
119 return boost::lexical_cast<unsigned int>(
id);
147 std::string commandType =
"none";
148 if (elmt->Attribute(
"type"))
150 commandType = elmt->Attribute(
"type");
152 if (commandType ==
"none")
156 else if (commandType ==
"parallel")
160 else if (commandType ==
"sequential")
168 if (elmt->FirstChildElement(
"executable"))
170 tmp = elmt->FirstChildElement(
"executable");
173 std::string needsPython;
174 tmp->QueryStringAttribute(
"python", &needsPython);
177#if defined(RELWITHDEBINFO)
179#elif !defined(NDEBUG)
185 tmp = elmt->FirstChildElement(
"parameters");
186 ASSERTL0(tmp,
"Cannot find 'parameters' for test.");
193 tmp = elmt->FirstChildElement(
"processes");
209 TiXmlElement *tmp, *metrics, *files;
212 unsigned int runs = 1;
213 testElement->QueryUnsignedAttribute(
"runs", &runs);
214 ASSERTL0(runs > 0,
"Number of runs must be greater than zero.");
218 tmp = testElement->FirstChildElement(
"description");
219 ASSERTL0(tmp,
"Cannot find 'description' for test.");
229 else if (testElement->FirstChildElement(
"executable"))
233 else if ((tmp = testElement->FirstChildElement(
"segment")))
236 "Test files defining more than one command in segment "
237 "blocks cannot use --executable.");
242 tmp = tmp->NextSiblingElement(
"segment");
248 "All segment commands should be of the same type.");
253 "No executable / command segments specified for test.");
256 metrics = testElement->FirstChildElement(
"metrics");
257 ASSERTL0(metrics,
"No metrics defined for test.");
259 tmp = metrics->FirstChildElement(
"metric");
263 tmp = tmp->NextSiblingElement(
"metric");
267 files = testElement->FirstChildElement(
"files");
270 tmp = files->FirstChildElement(
"file");
275 if (tmp->Attribute(
"description"))
280 tmp = tmp->NextSiblingElement(
"file");
#define ASSERTL0(condition, msg)
The TestData class is responsible for parsing a test XML file and storing the data.
std::vector< TiXmlElement * > m_metrics
DependentFile GetDependentFile(unsigned int pId) const
unsigned int GetMetricId(unsigned int pId)
Returns the ID of the metric for a given metric ID.
std::vector< Command > m_commands
unsigned int GetNumDependentFiles() const
Returns the number of dependent files required for the test.
TestData(TiXmlElement *pElmt, po::variables_map &pVm)
TestData constructor.
unsigned int GetNumMetrics() const
Returns the number of metrics to be collected for the test.
unsigned int m_runs
The number of times to run the test.
void Parse(TiXmlElement *pElmt)
Parse the test file and populate member variables for the test.
Command ParseCommand(TiXmlElement *pElmt) const
unsigned int GetNumRuns() const
Returns the number of runs to be performed for the test.
TiXmlElement * GetMetric(unsigned int pId)
Returns a pointer to the TiXmlElement object representing the metric for a given metric ID.
unsigned int GetNumCommands() const
const std::string & GetDescription() const
Returns the description of a test.
std::string GetMetricType(unsigned int pId) const
Returns the type of metric to be collected for a given metric ID.
po::variables_map m_cmdoptions
const Command & GetCommand(unsigned int pId) const
std::vector< DependentFile > m_files
std::string m_description
CommandType m_commandType
std::string m_description