35#include <boost/algorithm/string.hpp>
36#include <boost/core/ignore_unused.hpp>
37#include <boost/lexical_cast.hpp>
62 m_doc =
new TiXmlDocument(pFilename.string().c_str());
64 bool loadOkay =
m_doc->LoadFile();
67 "Failed to load test definition file: " + pFilename.string() +
68 "\n" +
string(
m_doc->ErrorDesc()));
75 boost::ignore_unused(pSrc);
87 "Command ID '" + std::to_string(pId) +
"' not found");
103 "Missing 'type' attribute in metric " +
104 boost::lexical_cast<string>(pId) +
").");
105 return boost::to_upper_copy(
string(
m_metrics[pId]->Attribute(
"type")));
126 const char *
id =
m_metrics[pId]->Attribute(
"id");
127 ASSERTL0(
id,
"No ID found for metric!");
128 return boost::lexical_cast<unsigned int>(
id);
158 if (elmt->FirstChildElement(
"executable"))
160 tmp = elmt->FirstChildElement(
"executable");
164 std::string needsPython;
165 tmp->QueryStringAttribute(
"python", &needsPython);
168#if defined(RELWITHDEBINFO)
170#elif !defined(NDEBUG)
176 tmp = elmt->FirstChildElement(
"parameters");
177 ASSERTL0(tmp,
"Cannot find 'parameters' for test.");
184 tmp = elmt->FirstChildElement(
"processes");
200 TiXmlHandle handle(pDoc);
201 TiXmlElement *testElement, *tmp, *metrics, *files;
202 testElement = handle.FirstChildElement(
"test").Element();
203 ASSERTL0(testElement,
"Cannot find 'test' root element.");
206 unsigned int runs = 1;
207 testElement->QueryUnsignedAttribute(
"runs", &runs);
208 ASSERTL0(runs > 0,
"Number of runs must be greater than zero.");
212 tmp = testElement->FirstChildElement(
"description");
213 ASSERTL0(tmp,
"Cannot find 'description' for test.");
223 else if (testElement->FirstChildElement(
"executable"))
227 else if ((tmp = testElement->FirstChildElement(
"segment")))
230 "Test files defining more than one command in segment "
231 "blocks cannot use --executable.");
236 tmp = tmp->NextSiblingElement(
"segment");
241 "No executable / command segments specified for test.");
244 metrics = testElement->FirstChildElement(
"metrics");
245 ASSERTL0(metrics,
"No metrics defined for test.");
247 tmp = metrics->FirstChildElement(
"metric");
251 tmp = tmp->NextSiblingElement(
"metric");
255 files = testElement->FirstChildElement(
"files");
258 tmp = files->FirstChildElement(
"file");
263 if (tmp->Attribute(
"description"))
268 tmp = tmp->NextSiblingElement(
"file");
#define ASSERTL0(condition, msg)
The TestData class is responsible for parsing a test XML file and storing the data.
TestData(const fs::path &pFilename, po::variables_map &pVm)
TestData constructor.
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.
void Parse(TiXmlDocument *pDoc)
Parse the test file and populate member variables for the test.
std::vector< Command > m_commands
unsigned int GetNumDependentFiles() const
Returns the number of dependent files required for the test.
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.
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
The above copyright notice and this permission notice shall be included.
std::string m_description