21 #define ZYPP_USE_RESOLVER_INTERNALS 41 xmlDocPtr xml_doc = xmlParseFile ( filename.
c_str() );
42 if (xml_doc == NULL) {
43 if ( err ) *err = (
str::Str() <<
"Can't parse test file '" << filename <<
"'");
50 DBG <<
"Parsing file '" << filename <<
"'" << std::endl;
52 if (!root.equals(
"test")) {
53 if ( err ) *err = (
str::Str() <<
"Node not 'test' in parse_xml_test():" << root.name() <<
"'");
57 bool setupDone =
false;
58 auto node = root.children();
60 if (
node->type() == XML_ELEMENT_NODE) {
61 if (
node->equals(
"setup" )) {
63 if ( err ) *err =
"Multiple setup tags found, this is not supported";
70 }
else if (
node->equals(
"trial" )) {
72 if ( err ) *err =
"Any trials must be preceeded by the setup!";
80 ERR <<
"Unknown tag '" <<
node->name() <<
"' in test" << std::endl;
91 DBG <<
"Parsing file '" << path <<
"'" << std::endl;
93 const auto makeError = [&](
const std::string_view &errStr ){
94 if ( err ) *err = errStr;
100 control = YAML::LoadFile( path.
asString() );
102 if ( control.Type() != YAML::NodeType::Map )
103 return makeError(
"Root node must be of type Map.");
105 const auto &setup = control[
"setup"];
107 return makeError(
"The 'setup' section is required.");
112 const auto &trials = control[
"trials"];
114 return makeError(
"The 'trials' section is required.");
115 if ( trials.Type() != YAML::NodeType::Sequence )
116 return makeError(
"The 'trials' section must be of type Sequence.");
118 for (
const auto &trial : trials ) {
120 if ( !trial[
"trial"] )
121 return makeError(
"Every element in the trials sequence needs to have the 'trial' key.");
125 _trials.push_back( t );
127 }
catch ( YAML::Exception &e ) {
128 if ( err ) *err = e.what();
131 if ( err ) *err =
"Unknown error when parsing the control file";
147 if ( err ) *err =
"Unsopported or no testcase in directory";
153 _pimpl->_setup.globalPath = path;
194 const auto &setup = *
this;
195 if ( !setup.architecture.empty() )
197 MIL <<
"Setting architecture to '" << setup.architecture <<
"'" << std::endl;
199 setenv (
"ZYPP_TESTSUITE_FAKE_ARCH", setup.architecture.c_str(), 1);
202 if ( setup.systemRepo ) {
203 if (!loadRepo( manager, setup, *setup.systemRepo ) )
205 ERR <<
"Can't setup 'system'" << std::endl;
210 if ( !setup.hardwareInfoFile.empty() ) {
211 setenv(
"ZYPP_MODALIAS_SYSFS", setup.hardwareInfoFile.asString().c_str(), 1 );
212 MIL <<
"setting HardwareInfo to: " << setup.hardwareInfoFile.asString() << std::endl;
215 for (
const auto &channel : setup.repos ) {
216 if ( !loadRepo( manager, setup, channel ) )
218 ERR <<
"Can't setup 'channel'" << std::endl;
223 if ( !setup.systemCheck.empty() ) {
224 MIL <<
"setting systemCheck to: " << setup.systemCheck.asString() << std::endl;
225 SystemCheck::instance().setFile( setup.systemCheck );
234 MIL <<
"'" << pathname <<
"'" << std::endl;
242 MIL <<
"Load from Url '" << data.
path <<
"'" << std::endl;
258 ERR <<
"Couldn't load packages from Url '" << data.
path <<
"'" << std::endl;
264 MIL <<
"Load from File '" << pathname <<
"'" << std::endl;
267 if ( data.
alias ==
"@System" ) {
291 ERR <<
"Couldn't load packages from XML file '" << data.
path <<
"'" << std::endl;
Repository reposInsert(const std::string &alias_r)
Return a Repository named alias_r.
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)
static bool loadRepo(zypp::RepoManager &manager, const TestcaseSetup &setup, const RepoData &data)
bool parseTrial(const XmlNode &trial, zypp::misc::testcase::TestcaseTrial &target, std::string *)
std::map< std::string, std::string > properties
void setAutorefresh(bool autorefresh)
enable or disable autorefresh
static ZConfig & instance()
Singleton ctor.
const TestcaseSetup & setupInfo() const
void setPriority(unsigned newval_r)
Set repository priority for solver.
static const std::string helixControlFile
void setEnabled(bool enabled)
enable or disable the repository
void loadFromCache(const RepoInfo &info, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Load resolvables into the pool.
const char * c_str() const
String representation.
void refreshMetadata(const RepoInfo &info, RawMetadataRefreshPolicy policy=RefreshIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local raw cache.
void setAlias(const std::string &alias)
set the repository alias
What is known about a repository.
void setSystemArchitecture(const Arch &arch_r)
Override the zypp system architecture.
bool loadYaml(const Pathname &path, std::string *err)
std::vector< TestcaseTrial > _trials
bool parseSetup(const YAML::Node &setup, zypp::misc::testcase::TestcaseSetup &target, std::string *err)
void addTesttags(const Pathname &file_r)
Load Solvables from a libsolv testtags-file.
bool parseTrial(const YAML::Node &trial, zypp::misc::testcase::TestcaseTrial &target, std::string *err)
Repository systemRepo()
Return the system repository, create it if missing.
static Pool instance()
Singleton ctor.
Url asUrl(const std::string &scheme_r) const
Url representation using scheme_r schema .
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.
void setInfo(const RepoInfo &info_r)
Set RepoInfo for this repository.
bool parseSetup(const XmlNode &setup, zypp::misc::testcase::TestcaseSetup &target, std::string *err)
const std::string & getProp(const std::string &name, const std::string &def=std::string()) const
static const std::string yamlControlFile
void addBaseUrl(const Url &url)
Add a base url.
bool loadHelix(const Pathname &filename, std::string *err)
creates and provides information about known sources.
#define ZYPP_CAUGHT(EXCPT)
Drops a logline telling the Exception was caught (in order to handle it).
void addHelix(const Pathname &file_r)
Load Solvables from a helix-file.
void buildCache(const RepoInfo &info, CacheBuildPolicy policy=BuildIfNeeded, const ProgressData::ReceiverFnc &progressrcv=ProgressData::ReceiverFnc())
Refresh local cache.
Base class for Exception.
std::unique_ptr< Impl > _pimpl
bool applySetup(zypp::RepoManager &manager) const
Wrapper class for ::stat/::lstat.
void setName(const std::string &name)
set the repository name
const std::vector< TestcaseTrial > & trialInfo() const
size_type solvablesSize() const
Number of solvables in Repository.