15 #include <zypp/PathInfo.h> 16 #include <zypp/base/LogControl.h> 80 if (
_pimpl->properties.find( name) ==
_pimpl->properties.end() )
82 return _pimpl->properties.at( name );
86 {
return _pimpl->properties; }
89 {
return _pimpl->properties; }
92 {
return _pimpl->children; }
95 {
return _pimpl->children; }
99 xmlDocPtr xml_doc = xmlParseFile ( filename.
c_str() );
100 if (xml_doc == NULL) {
101 if ( err ) *err = (
str::Str() <<
"Can't parse test file '" << filename <<
"'");
108 DBG <<
"Parsing file '" << filename <<
"'" << std::endl;
110 if (!root.equals(
"test")) {
111 if ( err ) *err = (
str::Str() <<
"Node not 'test' in parse_xml_test():" << root.name() <<
"'");
115 bool setupDone =
false;
116 auto node = root.children();
118 if (
node->type() == XML_ELEMENT_NODE) {
119 if (
node->equals(
"setup" )) {
121 if ( err ) *err =
"Multiple setup tags found, this is not supported";
128 }
else if (
node->equals(
"trial" )) {
130 if ( err ) *err =
"Any trials must be preceeded by the setup!";
136 _trials.push_back( trial );
138 ERR <<
"Unknown tag '" <<
node->name() <<
"' in test" << std::endl;
143 xmlFreeDoc (xml_doc);
149 DBG <<
"Parsing file '" << path <<
"'" << std::endl;
151 const auto makeError = [&](
const std::string_view &errStr ){
152 if ( err ) *err = errStr;
158 control = YAML::LoadFile( path.
asString() );
160 if ( control.Type() != YAML::NodeType::Map )
161 return makeError(
"Root node must be of type Map.");
163 const auto &setup = control[
"setup"];
165 return makeError(
"The 'setup' section is required.");
170 const auto &trials = control[
"trials"];
172 return makeError(
"The 'trials' section is required.");
173 if ( trials.Type() != YAML::NodeType::Sequence )
174 return makeError(
"The 'trials' section must be of type Sequence.");
176 for (
const auto &trial : trials ) {
178 if ( !trial[
"trial"] )
179 return makeError(
"Every element in the trials sequence needs to have the 'trial' key.");
183 _trials.push_back( t );
185 }
catch ( YAML::Exception &e ) {
186 if ( err ) *err = e.what();
189 if ( err ) *err =
"Unknown error when parsing the control file";
205 if ( err ) *err =
"Unsopported or no testcase in directory";
211 _pimpl->_setup.data().globalPath = path;
std::ostream & node(std::ostream &out_r, const std::string &name_r, Node::Attr attr_r)
bool loadTestcaseAt(const zypp::Pathname &path, std::string *err)
bool parseTrial(const XmlNode &trial, zypp::misc::testcase::TestcaseTrial &target, std::string *)
const TestcaseSetup & setupInfo() const
std::vector< std::shared_ptr< Node > > children
static const std::string helixControlFile
const char * c_str() const
String representation.
bool loadYaml(const Pathname &path, std::string *err)
std::vector< Node > nodes
bool parseSetup(const XmlNode &setup, zypp::misc::testcase::TestcaseSetup &t, std::string *err)
const std::map< std::string, std::string > & properties() const
const std::string & value() const
bool parseTrial(const YAML::Node &trial, zypp::misc::testcase::TestcaseTrial &target, std::string *err)
Convenient building of std::string via std::ostringstream Basically a std::ostringstream autoconverti...
static Type testcaseTypeAt(const zypp::Pathname &path)
const std::string & asString() const
String representation.
const std::string & getProp(const std::string &name, const std::string &def=std::string()) const
static const std::string yamlControlFile
const std::vector< Node > & nodes() const
bool loadHelix(const Pathname &filename, std::string *err)
const std::vector< std::shared_ptr< Node > > & children() const
std::map< std::string, std::string > properties
RWCOW_pointer< Impl > _pimpl
std::unique_ptr< Impl > _pimpl
const std::string & name() const
Wrapper class for ::stat/::lstat.
std::vector< TestcaseTrial > TestcaseTrials
bool parseSetup(const YAML::Node &setup, zypp::misc::testcase::TestcaseSetup &t, std::string *err)
const TestcaseTrials & trialInfo() const