Nektar++
TestData.h
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: TestData.h
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Encapsulation of test XML file.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#ifndef NEKTAR_TESTER_TESTDATA
36#define NEKTAR_TESTER_TESTDATA
37
38#include <boost/program_options.hpp>
39
40#include <string>
41#include <vector>
42
43#include <tinyxml.h>
44
46
47namespace po = boost::program_options;
48
49namespace Nektar
50{
52{
53 std::string m_description;
54 std::string m_filename;
55};
56
57struct Command
58{
59 fs::path m_executable;
60 std::string m_parameters;
61 unsigned int m_processes;
63};
64
65/**
66 * @brief The TestData class is responsible for parsing a test XML file and
67 * storing the data.
68 */
69
71{
72public:
73 TestData(const fs::path &pFilename, po::variables_map &pVm);
74 TestData(const TestData &pSrc);
75
76 const std::string &GetDescription() const;
77 const Command &GetCommand(unsigned int pId) const;
78 unsigned int GetNumCommands() const;
79
80 std::string GetMetricType(unsigned int pId) const;
81 unsigned int GetNumMetrics() const;
82 TiXmlElement *GetMetric(unsigned int pId);
83 unsigned int GetMetricId(unsigned int pId);
84
85 DependentFile GetDependentFile(unsigned int pId) const;
86 unsigned int GetNumDependentFiles() const;
87
88 unsigned int GetNumRuns() const;
89
90 void SaveFile();
91
92private:
93 po::variables_map m_cmdoptions;
94 std::string m_description;
95 std::vector<Command> m_commands;
96 TiXmlDocument *m_doc;
97 std::vector<TiXmlElement *> m_metrics;
98 std::vector<DependentFile> m_files;
99 /// @brief The number of times to run the test.
100 unsigned int m_runs;
101
102 void Parse(TiXmlDocument *pDoc);
103 Command ParseCommand(TiXmlElement *pElmt) const;
104};
105} // namespace Nektar
106
107#endif
The TestData class is responsible for parsing a test XML file and storing the data.
Definition: TestData.h:71
TestData(const fs::path &pFilename, po::variables_map &pVm)
TestData constructor.
Definition: TestData.cpp:58
std::vector< TiXmlElement * > m_metrics
Definition: TestData.h:97
DependentFile GetDependentFile(unsigned int pId) const
Definition: TestData.cpp:131
unsigned int GetMetricId(unsigned int pId)
Returns the ID of the metric for a given metric ID.
Definition: TestData.cpp:123
void Parse(TiXmlDocument *pDoc)
Parse the test file and populate member variables for the test.
Definition: TestData.cpp:198
std::vector< Command > m_commands
Definition: TestData.h:95
unsigned int GetNumDependentFiles() const
Returns the number of dependent files required for the test.
Definition: TestData.cpp:138
TiXmlDocument * m_doc
Definition: TestData.h:96
unsigned int GetNumMetrics() const
Returns the number of metrics to be collected for the test.
Definition: TestData.cpp:109
unsigned int m_runs
The number of times to run the test.
Definition: TestData.h:100
Command ParseCommand(TiXmlElement *pElmt) const
Definition: TestData.cpp:149
unsigned int GetNumRuns() const
Returns the number of runs to be performed for the test.
Definition: TestData.cpp:144
TiXmlElement * GetMetric(unsigned int pId)
Returns a pointer to the TiXmlElement object representing the metric for a given metric ID.
Definition: TestData.cpp:116
unsigned int GetNumCommands() const
Definition: TestData.cpp:91
const std::string & GetDescription() const
Returns the description of a test.
Definition: TestData.cpp:79
std::string GetMetricType(unsigned int pId) const
Returns the type of metric to be collected for a given metric ID.
Definition: TestData.cpp:97
po::variables_map m_cmdoptions
Definition: TestData.h:93
const Command & GetCommand(unsigned int pId) const
Definition: TestData.cpp:84
std::vector< DependentFile > m_files
Definition: TestData.h:98
std::string m_description
Definition: TestData.h:94
bool m_pythonTest
Definition: TestData.h:62
fs::path m_executable
Definition: TestData.h:59
std::string m_parameters
Definition: TestData.h:60
unsigned int m_processes
Definition: TestData.h:61
std::string m_filename
Definition: TestData.h:54
std::string m_description
Definition: TestData.h:53