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
58{
62};
63
64struct Command
65{
66 fs::path m_executable;
67 std::string m_parameters;
68 unsigned int m_processes;
71};
72
73/**
74 * @brief The TestData class is responsible for parsing a test XML file and
75 * storing the data.
76 */
77
79{
80public:
81 TestData(const fs::path &pFilename, po::variables_map &pVm);
82 TestData(const TestData &pSrc);
83
84 const std::string &GetDescription() const;
85 const Command &GetCommand(unsigned int pId) const;
86 unsigned int GetNumCommands() const;
87
88 std::string GetMetricType(unsigned int pId) const;
89 unsigned int GetNumMetrics() const;
90 TiXmlElement *GetMetric(unsigned int pId);
91 unsigned int GetMetricId(unsigned int pId);
92
93 DependentFile GetDependentFile(unsigned int pId) const;
94 unsigned int GetNumDependentFiles() const;
95
96 unsigned int GetNumRuns() const;
97
98 void SaveFile();
99
100private:
101 po::variables_map m_cmdoptions;
102 std::string m_description;
103 std::vector<Command> m_commands;
104 TiXmlDocument *m_doc;
105 std::vector<TiXmlElement *> m_metrics;
106 std::vector<DependentFile> m_files;
107 /// @brief The number of times to run the test.
108 unsigned int m_runs;
109
110 void Parse(TiXmlDocument *pDoc);
111 Command ParseCommand(TiXmlElement *pElmt) const;
112};
113} // namespace Nektar
114
115#endif
The TestData class is responsible for parsing a test XML file and storing the data.
Definition: TestData.h:79
TestData(const fs::path &pFilename, po::variables_map &pVm)
TestData constructor.
Definition: TestData.cpp:58
std::vector< TiXmlElement * > m_metrics
Definition: TestData.h:105
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:216
std::vector< Command > m_commands
Definition: TestData.h:103
unsigned int GetNumDependentFiles() const
Returns the number of dependent files required for the test.
Definition: TestData.cpp:138
TiXmlDocument * m_doc
Definition: TestData.h:104
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:108
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:101
const Command & GetCommand(unsigned int pId) const
Definition: TestData.cpp:84
std::vector< DependentFile > m_files
Definition: TestData.h:106
std::string m_description
Definition: TestData.h:102
CommandType
Definition: TestData.h:58
@ eSequential
Definition: TestData.h:60
@ eParallel
Definition: TestData.h:61
@ eNone
Definition: TestData.h:59
bool m_pythonTest
Definition: TestData.h:69
fs::path m_executable
Definition: TestData.h:66
std::string m_parameters
Definition: TestData.h:67
CommandType m_commandType
Definition: TestData.h:70
unsigned int m_processes
Definition: TestData.h:68
std::string m_filename
Definition: TestData.h:54
std::string m_description
Definition: TestData.h:53