Add resolvable list xml dump and a utility to dump store.
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 2 May 2006 15:45:54 +0000 (15:45 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 2 May 2006 15:45:54 +0000 (15:45 +0000)
configure.ac
testsuite/Makefile.am
testsuite/source/tests/Makefile.am
testsuite/source/tests/source-read-test.cc
testsuite/source/tests/sources/you.suse.de-200604024/resolvables-i586.xml
testsuite/utils/Makefile.am [new file with mode: 0644]
testsuite/utils/TestUtils.cc [new file with mode: 0644]
testsuite/utils/TestUtils.h [new file with mode: 0644]

index 3d1d41e..ba1c7f9 100644 (file)
@@ -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       \
index 296663c..e4d2ba9 100644 (file)
@@ -1,4 +1,4 @@
 #
 # Makefile.am for libzypp/testsuite
 #
-SUBDIRS = zypp target solver source media parser
+SUBDIRS = utils zypp target solver source media parser
index d4b4dc8..4dcb865 100644 (file)
@@ -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\"
index 8d15e03..65cad99 100644 (file)
 #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 << "    <capability kind=\"" << (*it).kind() << "\" refers=\"" << (*it).refers() << "\">" << (*it).asString() << "</capability>" << std::endl;
-  }
-  cout << "   " << "</" << deptype << ">" << 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<std::string> resolvables;
-  cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
-  cout << "<source xmlns=\"http://www.novell.com/zypp/testcases/source\">" << 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 << " <resolvable kind=\"" << (*it)->kind() << "\">" << std::endl;
-    cout <<  "  <name>" << (*it)->name() << "</name>" << std::endl;
-    cout <<  "  <edition>" << (*it)->edition() << "</edition>" << std::endl;
-    cout <<  "  <arch>" << (*it)->arch() << "</arch>" << std::endl;
-    cout <<  "  <dependencies>" << std::endl;
-    dumpDeps((*it)->deps());
-    cout <<  "  </dependencies>" << std::endl;
-    cout << "  </resolvable>" << std::endl;
-    //std::cout << (**it).deps() << endl;
-  }
-  cout << "</source>" << std::endl;
-  //std::sort( resolvables.begin(), resolvables.end(), CustomSort );
-  //for (std::list<std::string>::const_iterator it = resolvables.begin(); it != resolvables.end(); ++it)
-  //{
- //   cout << *it << std::endl;
-  //}
-}
-
 
 /******************************************************************
 **
index 20bde14..8128740 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<source xmlns="http://www.novell.com/zypp/testcases/source">
+<resolvable-list xmlns="http://www.novell.com/zypp/testcases/resolvable-list">
  <resolvable kind="patch">
   <name>zypp</name>
   <edition>1291-0</edition>
    </suggests>
   </dependencies>
   </resolvable>
-</source>
+</resolvable-list>
diff --git a/testsuite/utils/Makefile.am b/testsuite/utils/Makefile.am
new file mode 100644 (file)
index 0000000..70a91c2
--- /dev/null
@@ -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 (file)
index 0000000..596d0b5
--- /dev/null
@@ -0,0 +1,105 @@
+
+#include <iostream>
+#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 << "    <capability kind=\"" << (*it).kind() << "\" refers=\"" << (*it).refers() << "\">" << (*it).asString() << "</capability>" << std::endl;
+        }
+        cout << "   " << "</" << deptype << ">" << 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 << " <resolvable kind=\"" << r->kind() << "\">" << std::endl;
+          cout <<  "  <name>" << r->name() << "</name>" << std::endl;
+          cout <<  "  <edition>" << r->edition() << "</edition>" << std::endl;
+          cout <<  "  <arch>" << r->arch() << "</arch>" << std::endl;
+          if ( descr )
+          {
+            cout <<  "  <summary>" << r->summary() << "</summary>" << std::endl;
+            cout <<  "  <description>" << r->description() << "</description>" << std::endl;
+          }
+          
+          if ( deps )
+          {
+            cout <<  "  <dependencies>" << std::endl;
+            dumpDeps(r->deps());
+            cout <<  "  </dependencies>" << std::endl;
+          }
+          cout << "  </resolvable>" << std::endl;
+    //std::cout << (**it).deps() << endl;
+      }
+      
+      void dump( const std::list<ResObject::Ptr> &list, bool descr, bool deps )
+      {
+        std::list<std::string> resolvables;
+        cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
+        cout << "<resolvable-list xmlns=\"http://www.novell.com/zypp/testcases/resolvable-list\">" << std::endl;
+        for (std::list<ResObject::Ptr>::const_iterator it = list.begin(); it != list.end(); it++)
+        {
+          dumpResObject(*it, descr, deps);
+        }
+        cout << "</resolvable-list>" << std::endl;
+      }
+      
+      void dump( const ResStore &store, bool descr, bool deps )
+      {
+        std::list<std::string> resolvables;
+        cout << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
+        cout << "<resolvable-list xmlns=\"http://www.novell.com/zypp/testcases/resolvable-list\">" << std::endl;
+        for (ResStore::const_iterator it = store.begin(); it != store.end(); it++)
+        {
+          dumpResObject(*it, descr, deps);
+        }
+        cout << "</resolvable-list>" << std::endl;
+  //std::sort( resolvables.begin(), resolvables.end(), CustomSort );
+  //for (std::list<std::string>::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 (file)
index 0000000..cf291bb
--- /dev/null
@@ -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<ResObject::Ptr> &list, bool descr = false, bool deps = false );  
+    }  
+  }
+}
+
+#endif
+