BOOST_CHECK(isLocked(*it));
}
}
+
+BOOST_AUTO_TEST_CASE(locks_save_load)
+{
+ cout << "****save/load****" << endl;
+ Pathname src(TESTS_SRC_DIR);
+ src += "zypp/data/Locks/locks";
+ Locks::instance().loadLocks(src);
+ PoolQuery q;
+ q.addString("zypper");
+ for_(it,q.begin(),q.end())
+ {
+ BOOST_CHECK(isLocked(*it));
+ }
+ Locks::instance().unlock(q);
+ for_(it,q.begin(),q.end())
+ {
+ BOOST_CHECK(!isLocked(*it));
+ }
+#if 1
+ filesystem::TmpFile testfile;
+ //Pathname testfile(TESTS_SRC_DIR);
+ // testfile += "/zypp/data/Locks/testlocks";
+ Locks::instance().saveLocks(testfile);
+ Locks::instance().loadLocks(testfile);
+ //still locked
+ for_(it,q.begin(),q.end())
+ {
+ BOOST_CHECK(isLocked(*it));
+ }
+ Locks::instance().unlock(q); //need twice because finded from previous test
+ Locks::instance().saveLocks(testfile);
+ Locks::instance().loadLocks(testfile);
+ //now unlocked - first unlock remove indetical lock from previous test
+ //and next unlock remove lock from lockfile
+ for_(it,q.begin(),q.end())
+ {
+ BOOST_CHECK(!isLocked(*it));
+ }
+#endif
+}
#include "zypp/PoolQueryUtil.tcc"
#include "zypp/ZYppCallbacks.h"
#include "zypp/sat/SolvAttr.h"
+#include "zypp/PathInfo.h"
#undef ZYPP_BASE_LOGGER_LOGGROUP
#define ZYPP_BASE_LOGGER_LOGGROUP "locks"
#include "zypp/Locks.h"
-#include "zypp/PathInfo.h"
using namespace std;
using namespace zypp;
_pimpl->toRemove.end(), query);
if ( i != _pimpl->toRemove.end() )
{
+ DBG << "query removed from toRemove" << endl;
_pimpl->toRemove.erase(i);
}
else
{
+ DBG << "query added as new" << endl;
_pimpl->toAdd.push_back( query );
}
}
_pimpl->toAdd.end(), query);
if ( i != _pimpl->toAdd.end() )
{
+ DBG << "query removed from added" << endl;
_pimpl->toAdd.erase(i);
}
else
{
+ DBG << "needed remove some old lock" << endl;
_pimpl->toRemove.push_back( query );
}
}
{
if (aborted())
return false;
- if( q==query ) //identical
+ if( q==query )
+ {//identical
+ DBG << "identical queries" << endl;
return true;
+ }
SavingLocksReport::ConflictState cs;
switch( contains(q,solvs) )
{
case SavingLocksReport::ABORT:
aborted_ = true;
+ DBG << "abort merging" << endl;
return false;
case SavingLocksReport::DELETE:
+ DBG << "force delete" << endl;
return true;
case SavingLocksReport::IGNORE:
+ DBG << "skip lock" << endl;
return false;
}
WAR << "should not reached, some state is missing" << endl;
report->finish(SavingLocksReport::ABORTED);
return;
}
+ DBG << "writed "<< _pimpl->locks.size() << "locks" << endl;
writePoolQueriesToFile( file, _pimpl->locks.begin(), _pimpl->locks.end() );
report->finish(SavingLocksReport::NO_ERROR);
}