From 09434143e4e959c22956a3efe374d243eb0f5e90 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Tue, 2 May 2006 15:45:54 +0000 Subject: [PATCH] Add resolvable list xml dump and a utility to dump store. --- configure.ac | 1 + testsuite/Makefile.am | 2 +- testsuite/source/tests/Makefile.am | 2 +- testsuite/source/tests/source-read-test.cc | 54 +---------- .../you.suse.de-200604024/resolvables-i586.xml | 4 +- testsuite/utils/Makefile.am | 32 +++++++ testsuite/utils/TestUtils.cc | 105 +++++++++++++++++++++ testsuite/utils/TestUtils.h | 22 +++++ 8 files changed, 167 insertions(+), 55 deletions(-) create mode 100644 testsuite/utils/Makefile.am create mode 100644 testsuite/utils/TestUtils.cc create mode 100644 testsuite/utils/TestUtils.h diff --git a/configure.ac b/configure.ac index 3d1d41e..ba1c7f9 100644 --- a/configure.ac +++ b/configure.ac @@ -208,6 +208,7 @@ AC_OUTPUT( po/Makefile.in\ doc/autodoc/Makefile \ doc/autodoc/Doxyfile \ testsuite/Makefile \ + testsuite/utils/Makefile \ testsuite/zypp/Makefile \ testsuite/zypp/tests/Makefile \ testsuite/solver/Makefile \ diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 296663c..e4d2ba9 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -1,4 +1,4 @@ # # Makefile.am for libzypp/testsuite # -SUBDIRS = zypp target solver source media parser +SUBDIRS = utils zypp target solver source media parser diff --git a/testsuite/source/tests/Makefile.am b/testsuite/source/tests/Makefile.am index d4b4dc8..4dcb865 100644 --- a/testsuite/source/tests/Makefile.am +++ b/testsuite/source/tests/Makefile.am @@ -2,7 +2,7 @@ # Makefile.am for testsuite/source/tests # -LDADD = $(top_srcdir)/zypp/lib@PACKAGE@.la +LDADD = $(top_srcdir)/zypp/lib@PACKAGE@.la $(top_srcdir)/testsuite/utils/lib@PACKAGE@_testsuite_utils.la INCLUDES = \ -DZYPP_BASE_LOGGER_LOGGROUP=\"testsuite\" diff --git a/testsuite/source/tests/source-read-test.cc b/testsuite/source/tests/source-read-test.cc index 8d15e03..65cad99 100644 --- a/testsuite/source/tests/source-read-test.cc +++ b/testsuite/source/tests/source-read-test.cc @@ -26,66 +26,18 @@ #include "zypp/media/MediaManager.h" #include "zypp/Dependencies.h" +#include "testsuite/utils/TestUtils.h" + using namespace std; using namespace zypp; +using namespace zypp::testsuite::utils; bool CustomSort(const std::string &a, const std::string &b) { return a < b; //example comparison. } -static void dumpCapSet( const CapSet &caps, const std::string &deptype) -{ - cout << " " << "<" << deptype << ">" << std::endl; - CapSet::iterator it = caps.begin(); - for ( ; it != caps.end(); ++it) - { - cout << " " << (*it).asString() << "" << std::endl; - } - cout << " " << "" << std::endl; -} - -static void dumpDeps( const Dependencies &deps ) -{ - dumpCapSet( deps[Dep::PROVIDES], "provides" ); - dumpCapSet( deps[Dep::PREREQUIRES], "prerequires" ); - dumpCapSet( deps[Dep::CONFLICTS], "conflicts" ); - dumpCapSet( deps[Dep::OBSOLETES], "obsoletes" ); - dumpCapSet( deps[Dep::FRESHENS], "freshens" ); - dumpCapSet( deps[Dep::REQUIRES], "requires" ); - dumpCapSet( deps[Dep::RECOMMENDS], "recommends" ); - dumpCapSet( deps[Dep::ENHANCES], "enhances" ); - dumpCapSet( deps[Dep::SUPPLEMENTS], "supplements" ); - dumpCapSet( deps[Dep::SUGGESTS], "suggests" ); -} - -static void dump( const ResStore &store ) -{ - std::list resolvables; - cout << "" << std::endl; - cout << "" << std::endl; - for (ResStore::const_iterator it = store.begin(); it != store.end(); it++) - { - //std::string resolvable_line = "[" + (*it)->kind().asString() + "]" + (*it)->name() + " " + (*it)->edition().asString() + " " + (*it)->arch().asString(); - cout << " kind() << "\">" << std::endl; - cout << " " << (*it)->name() << "" << std::endl; - cout << " " << (*it)->edition() << "" << std::endl; - cout << " " << (*it)->arch() << "" << std::endl; - cout << " " << std::endl; - dumpDeps((*it)->deps()); - cout << " " << std::endl; - cout << " " << std::endl; - //std::cout << (**it).deps() << endl; - } - cout << "" << std::endl; - //std::sort( resolvables.begin(), resolvables.end(), CustomSort ); - //for (std::list::const_iterator it = resolvables.begin(); it != resolvables.end(); ++it) - //{ - // cout << *it << std::endl; - //} -} - /****************************************************************** ** diff --git a/testsuite/source/tests/sources/you.suse.de-200604024/resolvables-i586.xml b/testsuite/source/tests/sources/you.suse.de-200604024/resolvables-i586.xml index 20bde14..8128740 100644 --- a/testsuite/source/tests/sources/you.suse.de-200604024/resolvables-i586.xml +++ b/testsuite/source/tests/sources/you.suse.de-200604024/resolvables-i586.xml @@ -1,5 +1,5 @@ - + zypp 1291-0 @@ -23078,4 +23078,4 @@ - + diff --git a/testsuite/utils/Makefile.am b/testsuite/utils/Makefile.am new file mode 100644 index 0000000..70a91c2 --- /dev/null +++ b/testsuite/utils/Makefile.am @@ -0,0 +1,32 @@ +## Process this file with automake to produce Makefile.in +## ################################################## + +SUBDIRS = + +INCLUDES = -DZYPP_BASE_LOGGER_LOGGROUP=\"testsuite_utils\" + +## ################################################## + +##targetincludedir = $(pkgincludedir)/target + +##libtestsuiteinclude_HEADERS = \ +## TestUtils.h + +## ################################################## + +noinst_LTLIBRARIES = lib@PACKAGE@_testsuite_utils.la + +## ################################################## + +lib@PACKAGE@_testsuite_utils_la_SOURCES = \ + TestUtils.cc + +lib@PACKAGE@_testsuite_utils_la_LDFLAGS = @LIBZYPP_VERSION_INFO@ + +##lib@PACKAGE@_target_la_LIBADD = \ +## rpm/lib@PACKAGE@_target_rpm.la \ +## hal/lib@PACKAGE@_target_hal.la \ +## modalias/lib@PACKAGE@_target_modalias.la \ +## store/lib@PACKAGE@_target_store.la + +## ################################################## \ No newline at end of file diff --git a/testsuite/utils/TestUtils.cc b/testsuite/utils/TestUtils.cc new file mode 100644 index 0000000..596d0b5 --- /dev/null +++ b/testsuite/utils/TestUtils.cc @@ -0,0 +1,105 @@ + +#include +#include "zypp/Dependencies.h" +#include "zypp/Capability.h" +#include "zypp/ResObject.h" +#include "zypp/Patch.h" +#include "zypp/ResStore.h" +#include "testsuite/utils/TestUtils.h" + +using namespace std; + +namespace zypp +{ + namespace testsuite + { + namespace utils + { + static void dumpCapSet( const CapSet &caps, const std::string &deptype) + { + cout << " " << "<" << deptype << ">" << std::endl; + CapSet::iterator it = caps.begin(); + for ( ; it != caps.end(); ++it) + { + cout << " " << (*it).asString() << "" << std::endl; + } + cout << " " << "" << std::endl; + } + + static void dumpDeps( const Dependencies &deps ) + { + dumpCapSet( deps[Dep::PROVIDES], "provides" ); + dumpCapSet( deps[Dep::PREREQUIRES], "prerequires" ); + dumpCapSet( deps[Dep::CONFLICTS], "conflicts" ); + dumpCapSet( deps[Dep::OBSOLETES], "obsoletes" ); + dumpCapSet( deps[Dep::FRESHENS], "freshens" ); + dumpCapSet( deps[Dep::REQUIRES], "requires" ); + dumpCapSet( deps[Dep::RECOMMENDS], "recommends" ); + dumpCapSet( deps[Dep::ENHANCES], "enhances" ); + dumpCapSet( deps[Dep::SUPPLEMENTS], "supplements" ); + dumpCapSet( deps[Dep::SUGGESTS], "suggests" ); + } + + static std::string xml_escape( const std::string &s ) + { + return s; + } + + static void dumpResObject( const ResObject::Ptr r, bool descr, bool deps ) + { + std::string resolvable_line = "[" + r->kind().asString() + "]" + r->name() + " " + r->edition().asString() + " " + r->arch().asString(); + cout << " kind() << "\">" << std::endl; + cout << " " << r->name() << "" << std::endl; + cout << " " << r->edition() << "" << std::endl; + cout << " " << r->arch() << "" << std::endl; + if ( descr ) + { + cout << " " << r->summary() << "" << std::endl; + cout << " " << r->description() << "" << std::endl; + } + + if ( deps ) + { + cout << " " << std::endl; + dumpDeps(r->deps()); + cout << " " << std::endl; + } + cout << " " << std::endl; + //std::cout << (**it).deps() << endl; + } + + void dump( const std::list &list, bool descr, bool deps ) + { + std::list resolvables; + cout << "" << std::endl; + cout << "" << std::endl; + for (std::list::const_iterator it = list.begin(); it != list.end(); it++) + { + dumpResObject(*it, descr, deps); + } + cout << "" << std::endl; + } + + void dump( const ResStore &store, bool descr, bool deps ) + { + std::list resolvables; + cout << "" << std::endl; + cout << "" << std::endl; + for (ResStore::const_iterator it = store.begin(); it != store.end(); it++) + { + dumpResObject(*it, descr, deps); + } + cout << "" << std::endl; + //std::sort( resolvables.begin(), resolvables.end(), CustomSort ); + //for (std::list::const_iterator it = resolvables.begin(); it != resolvables.end(); ++it) + //{ + // cout << *it << std::endl; + //} + } + + + + } + } +} + diff --git a/testsuite/utils/TestUtils.h b/testsuite/utils/TestUtils.h new file mode 100644 index 0000000..cf291bb --- /dev/null +++ b/testsuite/utils/TestUtils.h @@ -0,0 +1,22 @@ + +#ifndef ZYPP_TESTSUITE_TESTUTILS +#define ZYPP_TESTSUITE_TESTUTILS + +#include "zypp/Dependencies.h" +#include "zypp/Capability.h" +#include "zypp/ResStore.h" + +namespace zypp +{ + namespace testsuite + { + namespace utils + { + void dump( const ResStore &store, bool descr = false, bool deps = false ); + void dump( const std::list &list, bool descr = false, bool deps = false ); + } + } +} + +#endif + -- 2.7.4