17 #define ZYPP_USE_RESOLVER_INTERNALS
54 using namespace zypp::str;
66 result +=
"<" + tag +
">";
73 result +=
"</" + tag +
">";
78 std::string
helixXML(
const T &obj );
114 str <<
" />" << endl;
123 str <<
"<dep name='packageand("
127 && detail.
lhs().
id() == NAMESPACE_OTHERPROVIDERS) {
128 str <<
"<dep name='otherproviders("
135 detail = detail.rhs().detail();
138 && detail.
lhs().
id() == NAMESPACE_MODALIAS) {
139 str <<
"<dep name='modalias(";
140 if (!packageName.
empty())
141 str << packageName <<
":";
160 for ( ; it != caps.
end(); ++it)
172 CapabilitySet::const_iterator it = caps.begin();
174 for ( ; it != caps.end(); ++it)
186 if ( ! caps.
empty() )
194 str <<
"<" << item.
kind() <<
">" << endl;
198 if ( isKind<Package>( item ) ) {
199 str <<
TAB <<
"<history>" << endl <<
TAB <<
"<update>" << endl;
202 str <<
TAB <<
"</update>" << endl <<
TAB <<
"</history>" << endl;
217 str <<
"</" << item.
kind() <<
">" << endl;
241 std::string filename ()
258 *
file <<
"<channel><subchannel>" << endl;
263 *
file <<
"</subchannel></channel>" << endl;
284 const Arch & systemArchitecture,
286 const std::set<std::string> & multiversionSpec,
287 const std::string & systemPath);
294 *
file <<
"</setup>" << endl <<
"<trial>" << endl;
299 void addTagIf(
const std::string & tag_r,
bool yesno_r =
true )
317 const Arch & systemArchitecture,
319 const std::set<std::string> & multiversionSpec,
320 const std::string & systemPath)
321 :dumpFile (controlPath)
324 file =
new ofstream(controlPath.c_str());
329 *
file <<
"<?xml version=\"1.0\"?>" << endl
330 <<
"<!-- testcase generated by YaST -->" << endl
332 <<
"<setup arch=\"" << systemArchitecture <<
"\">" << endl
333 <<
TAB <<
"<system file=\"" << systemPath <<
"\"/>" << endl << endl;
334 for ( RepositoryTable::const_iterator it = repoTable.begin();
335 it != repoTable.end(); ++it ) {
337 *
file <<
TAB <<
"<!-- " << endl
338 <<
TAB <<
"- alias : " << repo.
alias() << endl;
343 *
file <<
TAB <<
"- url : " << *itUrl << endl;
345 *
file <<
TAB <<
"- path : " << repo.
path() << endl;
346 *
file <<
TAB <<
"- type : " << repo.
type() << endl;
347 *
file <<
TAB <<
"- generated : " << (it->first.generatedTimestamp()).
form(
"%Y-%m-%d %H:%M:%S" ) << endl;
348 *
file <<
TAB <<
"- outdated : " << (it->first.suggestedExpirationTimestamp()).
form(
"%Y-%m-%d %H:%M:%S" ) << endl;
349 *
file <<
TAB <<
" -->" << endl;
352 <<
"-package.xml.gz\" name=\"" << repo.
alias() <<
"\""
353 <<
" priority=\"" << repo.
priority()
354 <<
"\" />" << endl << endl;
365 for (
Locale l : requestedLocales )
367 const char * fate = ( addedLocales.count(l) ?
"\" fate=\"added" :
"" );
368 *
file <<
TAB <<
"<locale name=\"" << l << fate <<
"\" />" << endl;
370 for (
Locale l : removedLocales )
372 *
file <<
TAB <<
"<locale name=\"" << l <<
"\" fate=\"removed\" />" << endl;
383 for_( it, modaliasList.begin(), modaliasList.end() ) {
388 for_( it, multiversionSpec.begin(), multiversionSpec.end() ) {
389 *
file <<
TAB <<
"<multiversion name=\"" << *it
399 *
file <<
"</trial>" << endl
400 <<
"</test>" << endl;
407 <<
" kind=\"" << pi_r.
kind() <<
"\""
408 <<
" name=\"" << pi_r.
name() <<
"\""
409 <<
" arch=\"" << pi_r.
arch() <<
"\""
412 <<
" status=\"" << pi_r.
status() <<
"\""
419 <<
" kind=\"" << pi_r.
kind() <<
"\""
420 <<
" name=\"" << pi_r.
name() <<
"\""
421 <<
" arch=\"" << pi_r.
arch() <<
"\""
424 <<
" status=\"" << pi_r.
status() <<
"\""
431 <<
" kind=\"" << pi_r.
kind() <<
"\""
432 <<
" name=\"" << pi_r.
name() <<
"\""
433 <<
" arch=\"" << pi_r.
arch() <<
"\""
436 <<
" status=\"" << pi_r.
status() <<
"\""
442 *
file <<
"<uninstall kind=\"" << pi_r.
kind() <<
"\""
443 <<
" name=\"" << pi_r.
name() <<
"\""
444 <<
" status=\"" << pi_r.
status() <<
"\""
450 for (CapabilitySet::const_iterator iter = capRequire.begin(); iter != capRequire.end(); iter++) {
451 *
file <<
"<addRequire " <<
" name=\"" << iter->asString() <<
"\"" <<
"/>" << endl;
453 for (CapabilitySet::const_iterator iter = capConflict.begin(); iter != capConflict.end(); iter++) {
454 *
file <<
"<addConflict " <<
" name=\"" << iter->asString() <<
"\"" <<
"/>" << endl;
460 for_( it, upgradeRepos_r.begin(), upgradeRepos_r.end() )
462 *
file <<
"<upgradeRepo name=\"" << it->alias() <<
"\"/>" << endl;
469 :dumpPath(
"/var/log/YaST2/solverTestcase")
472 Testcase::Testcase(
const std::string & path)
476 Testcase::~Testcase()
479 bool Testcase::createTestcase(Resolver & resolver,
bool dumpPool,
bool runSolver)
481 PathInfo path (dumpPath);
483 if ( !path.isExist() ) {
485 ERR <<
"Cannot create directory " << dumpPath << endl;
490 ERR << dumpPath <<
" is not a directory." << endl;
503 resolver.resolvePool();
506 ResPool pool = resolver.pool();
508 PoolItemList items_to_install;
509 PoolItemList items_to_remove;
510 PoolItemList items_locked;
511 PoolItemList items_keep;
512 HelixResolvable_Ptr system = NULL;
515 system =
new HelixResolvable(dumpPath +
"/solver-system.xml.gz");
517 for (
const PoolItem & pi : pool )
519 if ( system && pi.status().isInstalled() ) {
521 system->addResolvable( pi );
524 Repository repo = pi.repository();
526 if (repoTable.find (repo) == repoTable.end()) {
527 repoTable[repo] =
new HelixResolvable(dumpPath +
"/"
529 +
"-package.xml.gz");
531 repoTable[repo]->addResolvable( pi );
535 if ( pi.status().isToBeInstalled()
536 && !(pi.status().isBySolver())) {
537 items_to_install.push_back( pi );
539 if ( pi.status().isKept()
540 && !(pi.status().isBySolver())) {
541 items_keep.push_back( pi );
543 if ( pi.status().isToBeUninstalled()
544 && !(pi.status().isBySolver())) {
545 items_to_remove.push_back( pi );
547 if ( pi.status().isLocked()
548 && !(pi.status().isBySolver())) {
549 items_locked.push_back( pi );
554 HelixControl control (dumpPath +
"/solver-test.xml",
559 "solver-system.xml.gz");
562 control.addTagIf(
"ignorealreadyrecommended", resolver.ignoreAlreadyRecommended() );
563 control.addTagIf(
"onlyRequires", resolver.onlyRequires() );
564 control.addTagIf(
"forceResolve", resolver.forceResolve() );
566 control.addTagIf(
"cleandepsOnRemove", resolver.cleandepsOnRemove() );
568 control.addTagIf(
"allowDowngrade", resolver.allowDowngrade() );
569 control.addTagIf(
"allowNameChange", resolver.allowNameChange() );
570 control.addTagIf(
"allowArchChange", resolver.allowArchChange() );
571 control.addTagIf(
"allowVendorChange", resolver.allowVendorChange() );
573 control.addTagIf(
"dupAllowDowngrade", resolver.dupAllowDowngrade() );
574 control.addTagIf(
"dupAllowNameChange", resolver.dupAllowNameChange() );
575 control.addTagIf(
"dupAllowArchChange", resolver.dupAllowArchChange() );
576 control.addTagIf(
"dupAllowVendorChange", resolver.dupAllowVendorChange() );
578 control.closeSetup();
581 for (
const PoolItem & pi : items_to_install )
582 { control.installResolvable( pi ); }
584 for (
const PoolItem & pi : items_locked )
585 { control.lockResolvable( pi ); }
587 for (
const PoolItem & pi : items_keep )
588 { control.keepResolvable( pi ); }
590 for (
const PoolItem & pi : items_to_remove )
591 { control.deleteResolvable( pi ); }
593 control.addDependencies (resolver.extraRequires(), resolver.extraConflicts());
594 control.addDependencies (SystemCheck::instance().requiredSystemCap(),
595 SystemCheck::instance().conflictSystemCap());
596 control.addUpgradeRepos( resolver.upgradeRepos() );
598 control.addTagIf(
"distupgrade", resolver.isUpgradeMode() );
599 control.addTagIf(
"update", resolver.isUpdateMode() );
600 control.addTagIf(
"verify", resolver.isVerifyingMode() );