Mailinglist Archive: zypp-commit (266 mails)

< Previous Next >
[zypp-commit] r11630 - in /trunk/libzypp: tests/sat/LookupAttr_test.cc zypp/sat/LookupAttr.cc zypp/sat/LookupAttr.h
  • From: mlandres@xxxxxxxxxxxxxxxx
  • Date: Fri, 07 Nov 2008 16:58:56 -0000
  • Message-id: <20081107165856.3A6DC345D4@xxxxxxxxxxxxxxxx>
Author: mlandres
Date: Fri Nov 7 17:58:55 2008
New Revision: 11630

URL: http://svn.opensuse.org/viewcvs/zypp?rev=11630&view=rev
Log:
Add stream output operator for debuging.

Modified:
trunk/libzypp/tests/sat/LookupAttr_test.cc
trunk/libzypp/zypp/sat/LookupAttr.cc
trunk/libzypp/zypp/sat/LookupAttr.h

Modified: trunk/libzypp/tests/sat/LookupAttr_test.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/sat/LookupAttr_test.cc?rev=11630&r1=11629&r2=11630&view=diff
==============================================================================
--- trunk/libzypp/tests/sat/LookupAttr_test.cc (original)
+++ trunk/libzypp/tests/sat/LookupAttr_test.cc Fri Nov 7 17:58:55 2008
@@ -1,5 +1,8 @@
#include "TestSetup.h"
#include <zypp/sat/LookupAttr.h>
+#include <zypp/ResObjects.h>
+
+#include <zypp/sat/detail/PoolImpl.h>

#define LABELED(V) #V << ":\t" << V

@@ -55,22 +58,158 @@
BOOST_CHECK_NE( q.begin(), q.end() );
}

-BOOST_AUTO_TEST_CASE(LookupAttr_)
+BOOST_AUTO_TEST_CASE(LookupAttr_iterate_solvables)
+{
+ // sat::SolvAttr::name query should visit each solvable once.
+ // So query size and containersize are to be equal if we query
+ // pool/repo/solvable. Quick check whether the iterators
+ // position info matches the result.
+
+ sat::Pool satpool( test.satpool() );
+
+ {
+ // iterate all:
+ sat::LookupAttr q( sat::SolvAttr::name );
+ BOOST_CHECK_EQUAL( q.size(), satpool.solvablesSize() );
+ // quick test whether iterator positions actually matches the result:
+ for_( res, q.begin(), q.end() )
+ {
+ BOOST_CHECK_EQUAL( res.inRepo(), res.inSolvable().repository() );
+ BOOST_CHECK_EQUAL( res.inSolvAttr(), sat::SolvAttr::name );
+ }
+ }
+ {
+ unsigned total = 0;
+ for_( it, satpool.reposBegin(), satpool.reposEnd() )
+ {
+ // iterate one repo:
+ sat::LookupAttr q( sat::SolvAttr::name, *it );
+ BOOST_CHECK_EQUAL( q.size(), it->solvablesSize() );
+ total += q.size();
+ // test result actually matches the repo:
+ for_( res, q.begin(), q.end() )
+ {
+ BOOST_CHECK_EQUAL( res.inRepo(), *it );
+ BOOST_CHECK_EQUAL( res.inRepo(), res.inSolvable().repository() );
+ BOOST_CHECK_EQUAL( res.inSolvAttr(), sat::SolvAttr::name );
+ }
+ }
+ BOOST_CHECK_EQUAL( total, satpool.solvablesSize() );
+ }
+ {
+ unsigned total = 0;
+ for_( it, satpool.solvablesBegin(), satpool.solvablesEnd() )
+ {
+ // iterate one solvable:
+ sat::LookupAttr q( sat::SolvAttr::name, *it );
+ BOOST_CHECK_EQUAL( q.size(), 1 );
+ total += q.size();
+ // test result actually matches the solvable:
+ for_( res, q.begin(), q.end() )
+ {
+ BOOST_CHECK_EQUAL( res.inSolvable(), *it );
+ BOOST_CHECK_EQUAL( res.inRepo(), res.inSolvable().repository() );
+ BOOST_CHECK_EQUAL( res.inSolvAttr(), sat::SolvAttr::name );
+ }
+ }
+ BOOST_CHECK_EQUAL( total, satpool.solvablesSize() );
+ }
+}
+
+BOOST_AUTO_TEST_CASE(LookupAttr_itetate_all_attributes)
+{
+ sat::Pool satpool( test.satpool() );
+
+ // iterate all:
+ sat::LookupAttr all( sat::SolvAttr::allAttr );
+
+ {
+ unsigned total = 0;
+ for_( it, satpool.reposBegin(), satpool.reposEnd() )
+ {
+ // iterate one repo:
+ sat::LookupAttr q( sat::SolvAttr::allAttr, *it );
+ total += q.size();
+ }
+ BOOST_CHECK_EQUAL( total, all.size() );
+ }
+ {
+ unsigned total = 0;
+ for_( it, satpool.solvablesBegin(), satpool.solvablesEnd() )
+ {
+ // iterate one solvable:
+ sat::LookupAttr q( sat::SolvAttr::allAttr, *it );
+ total += q.size();
+ }
+ BOOST_CHECK_EQUAL( total, all.size() );
+ }
+}
+
+BOOST_AUTO_TEST_CASE(LookupAttr_solvable_attribute_types)
{
base::LogControl::TmpLineWriter shutUp( new log::FileLineWriter( "/tmp/YLOG"
) );
MIL << "GO" << endl;

- sat::Pool satpool( test.satpool() );
- for_( it, satpool.reposBegin(), satpool.reposEnd() )
+ ResPool pool( test.pool() );
+ for_( it, pool.byKindBegin<Patch>(), pool.byKindEnd<Patch>() )
{
- SEC << endl;
- sat::LookupAttr q( sat::SolvAttr::name, *it );
- BOOST_CHECK_EQUAL( q.size(), it->solvablesSize() );
- MIL << q << ' ' << q.size() << " in " << *it << endl;
- DBG << q << endl;
+ Patch::constPtr p( (*it)->asKind<Patch>() );
+ USR << p << endl;
+
+ sat::LookupAttr q( sat::SolvAttr::allAttr, p->satSolvable() );
+ //sat::LookupAttr q( sat::SolvAttr("update:reference") );
+ for_( res, q.begin(), q.end() )
+ {
+ if ( //res.inSolvAttr() == sat::SolvAttr("update:reference") &&
+ res.solvAttrType() == IdString("repokey:type:flexarray").id() )
+ {
+ MIL << res << endl;
+ DBG << *res << endl;
+ ::_Dataiterator * dip = res.get();
+ INT << dip << endl;
+
+ ::dataiterator_setpos( dip );
+
+ ::Dataiterator di2;
+ ::dataiterator_init( &di2
+ , sat::Pool::instance().get()
+ , 0
+ , SOLVID_POS
+ , 0
+ , 0
+ , 0 );
+
+ while ( ::dataiterator_step( &di2 ) )
+ {
+ DBG << di2 << endl;
+ }
+ }
+ }
+ break;
}
- return;
- sat::LookupAttr q( sat::SolvAttr::name );
- BOOST_CHECK_EQUAL( q.size(), satpool.solvablesSize() );
- MIL << q << ' ' << q.size() << " in ALL" << endl;
+
+ {
+ sat::LookupAttr q( sat::SolvAttr("update:reference") );
+ USR << q << " " << q.size() << endl;
+ }
+ {
+ sat::LookupAttr q( sat::SolvAttr("update:reference:href") );
+ USR << q << " " << q.size() << endl;
+ }
+
+
}
+
+
+BOOST_AUTO_TEST_CASE(LookupAttr_)
+{
+ base::LogControl::TmpLineWriter shutUp( new log::FileLineWriter( "/tmp/YLOG"
) );
+ MIL << "GO" << endl;
+}
+
+
+
+
+
+
+

Modified: trunk/libzypp/zypp/sat/LookupAttr.cc
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.cc?rev=11630&r1=11629&r2=11630&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.cc (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.cc Fri Nov 7 17:58:55 2008
@@ -123,30 +123,6 @@
//
///////////////////////////////////////////////////////////////////

- std::ostream & operator<<( std::ostream & str, const ::_Dataiterator * obj
)
- {
- str << "::_Dataiterator(";
- if ( ! obj )
- {
- str << "NULL";
- }
- else
- {
- str << "|" << obj->pool;
- str << "|" << Repository(obj->repo);
- str << "|" << obj->key;
- str << "|" << obj->keyname;
- str << "|" << obj->repodataid;
- str << "|" << Solvable(obj->solvid);
- str << "|" << obj->repoid;
- }
- return str << ")";
- }
- std::ostream & operator<<( std::ostream & str, const scoped_ptr<
::_Dataiterator> & obj )
- {
- return str << obj.get();
- }
-
///////////////////////////////////////////////////////////////////
// position and moving
///////////////////////////////////////////////////////////////////
@@ -446,3 +422,24 @@
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+
+std::ostream & operator<<( std::ostream & str, const ::_Dataiterator * obj )
+{
+ str << "::_Dataiterator(";
+ if ( ! obj )
+ {
+ str << "NULL";
+ }
+ else
+ {
+ str << "|" << zypp::Repository(obj->repo);
+ str << "|" << zypp::sat::Solvable(obj->solvid);
+ str << "|" << zypp::IdString(obj->key->name);
+ str << "|" << zypp::IdString(obj->key->type);
+ str << "|" << obj->repodataid;
+ str << "|" << obj->repoid;
+ }
+ return str << ")";
+}
+
+///////////////////////////////////////////////////////////////////

Modified: trunk/libzypp/zypp/sat/LookupAttr.h
URL:
http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/zypp/sat/LookupAttr.h?rev=11630&r1=11629&r2=11630&view=diff
==============================================================================
--- trunk/libzypp/zypp/sat/LookupAttr.h (original)
+++ trunk/libzypp/zypp/sat/LookupAttr.h Fri Nov 7 17:58:55 2008
@@ -522,4 +522,12 @@
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+
+/** \relates LookupAttr::iterator Stream output of the underlying iterator for
debug. */
+std::ostream & operator<<( std::ostream & str, const ::_Dataiterator * obj );
+
+/** \relates LookupAttr::iterator Stream output of the underlying iterator for
debug. */
+inline std::ostream & operator<<( std::ostream & str, const ::_Dataiterator &
obj )
+{ return str << &obj; }
+
#endif // ZYPP_SAT_LOOKUPATTR_H

--
To unsubscribe, e-mail: zypp-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: zypp-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages