Author: schubi2 Date: Mon Jan 21 13:02:58 2008 New Revision: 8332 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8332&view=rev Log: splitted generating testcases into different tasks Modified: trunk/libzypp/zypp/solver/detail/Testcase.cc trunk/libzypp/zypp/solver/detail/Testcase.h Modified: trunk/libzypp/zypp/solver/detail/Testcase.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Testcase.cc?rev=8332&r1=8331&r2=8332&view=diff ============================================================================== --- trunk/libzypp/zypp/solver/detail/Testcase.cc (original) +++ trunk/libzypp/zypp/solver/detail/Testcase.cc Mon Jan 21 13:02:58 2008 @@ -204,7 +204,7 @@ { } -bool Testcase::createTestcase(Resolver & resolver) +bool Testcase::createTestcasePool(const ResPool &pool) { PathInfo path (dumpPath); @@ -222,13 +222,60 @@ zypp::filesystem::clean_dir (dumpPath); } - zypp::base::LogControl::instance().logfile( dumpPath +"/y2log" ); - zypp::base::LogControl::TmpExcessive excessive; + RepositoryTable repoTable; + HelixResolvable system (dumpPath + "/solver-system.xml"); + + for ( ResPool::const_iterator it = pool.begin(); it != pool.end(); ++it ) + { + Resolvable::constPtr res = it->resolvable(); + + if ( it->status().isInstalled() ) { + // system channel + system.addResolvable (*it); + } else { + // repo channels + ResObject::constPtr repoItem = it->resolvable(); + Repository repo = repoItem->repository(); + if (repoTable.find (repo) == repoTable.end()) { + repoTable[repo] = new HelixResolvable(dumpPath + "/" + + numstring(repo.numericId()) + + "-package.xml"); + } + repoTable[repo]->addResolvable (*it); + } + } + return true; +} + + +bool Testcase::createTestcase (Resolver & resolver, bool dumpPool, bool runSolver) +{ + PathInfo path (dumpPath); - resolver.reset(true); // true = resetting all valid solverresults - resolver.resolvePool(); + if ( !path.isExist() ) { + if (zypp::filesystem::mkdir (dumpPath)!=0) { + ERR << "Cannot create directory " << dumpPath << endl; + return false; + } + } else { + if (!path.isDir()) { + ERR << dumpPath << " is not a directory." << endl; + return false; + } + // remove old stuff if pool will be dump + if (dumpPool) + zypp::filesystem::clean_dir (dumpPath); + } + + if (runSolver) { + zypp::base::LogControl::instance().logfile( dumpPath +"/y2log" ); + zypp::base::LogControl::TmpExcessive excessive; - zypp::base::LogControl::instance().logfile( "/var/log/YaST2/y2log" ); + resolver.reset(true); // true = resetting all valid solverresults + resolver.resolvePool(); + + zypp::base::LogControl::instance().logfile( "/var/log/YaST2/y2log" ); + } ResPool pool = resolver.pool(); RepositoryTable repoTable; @@ -237,7 +284,10 @@ PoolItemList items_locked; PoolItemList items_keep; PoolItemList language; - HelixResolvable system (dumpPath + "/solver-system.xml"); + HelixResolvable_Ptr system = NULL; + + if (dumpPool) + system = new HelixResolvable(dumpPath + "/solver-system.xml"); for ( ResPool::const_iterator it = pool.begin(); it != pool.end(); ++it ) { @@ -249,19 +299,21 @@ language.push_back (*it); } } else { - if ( it->status().isInstalled() ) { + if ( system && it->status().isInstalled() ) { // system channel - system.addResolvable (*it); + system->addResolvable (*it); } else { // repo channels ResObject::constPtr repoItem = it->resolvable(); Repository repo = repoItem->repository(); - if (repoTable.find (repo) == repoTable.end()) { - repoTable[repo] = new HelixResolvable(dumpPath + "/" - + numstring(repo.numericId()) - + "-package.xml"); + if (dumpPool) { + if (repoTable.find (repo) == repoTable.end()) { + repoTable[repo] = new HelixResolvable(dumpPath + "/" + + numstring(repo.numericId()) + + "-package.xml"); + } + repoTable[repo]->addResolvable (*it); } - repoTable[repo]->addResolvable (*it); } if ( it->status().isToBeInstalled() @@ -281,7 +333,6 @@ && !isKind<SystemResObject>(res)) { items_locked.push_back (*it); } - } } Modified: trunk/libzypp/zypp/solver/detail/Testcase.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/solver/detail/Testcase.h?rev=8332&r1=8331&r2=8332&view=diff ============================================================================== --- trunk/libzypp/zypp/solver/detail/Testcase.h (original) +++ trunk/libzypp/zypp/solver/detail/Testcase.h Mon Jan 21 13:02:58 2008 @@ -128,7 +128,8 @@ Testcase (); ~Testcase (); - bool createTestcase (Resolver & resolver); + bool createTestcase (Resolver & resolver, bool dumpPool = true, bool runSolver = true); + bool createTestcasePool(const ResPool &pool); }; -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org