add store dump in xml
authorDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 2 May 2006 16:09:07 +0000 (16:09 +0000)
committerDuncan Mac-Vicar P <dmacvicar@suse.de>
Tue, 2 May 2006 16:09:07 +0000 (16:09 +0000)
testsuite/target/tests/Makefile.am
testsuite/target/tests/dumpstore.cc [new file with mode: 0644]

index dcd24f0..aae0023 100644 (file)
@@ -2,9 +2,9 @@
 # Makefile.am for testsuite/target/tests
 #
 
-LDADD =        $(top_srcdir)/zypp/lib@PACKAGE@.la
+LDADD =        $(top_srcdir)/zypp/lib@PACKAGE@.la $(top_srcdir)/testsuite/utils/lib@PACKAGE@_testsuite_utils.la
 
-noinst_PROGRAMS = hal librpmDb RpmDb storagetargettest import_old_sources_test
+noinst_PROGRAMS = hal librpmDb RpmDb storagetargettest import_old_sources_test dumpstore
 
 hal_SOURCES = hal.cc
 
@@ -12,5 +12,6 @@ librpmDb_SOURCES = librpmDb.cc
 RpmDb_SOURCES = RpmDb.cc
 
 storagetargettest_SOURCES = storagetargettest.cc Benchmark.cc Benchmark.h
+dumpstore_SOURCES = dumpstore.cc
 
 import_old_sources_test_SOURCES = import_old_sources_test.cc
\ No newline at end of file
diff --git a/testsuite/target/tests/dumpstore.cc b/testsuite/target/tests/dumpstore.cc
new file mode 100644 (file)
index 0000000..b2e409a
--- /dev/null
@@ -0,0 +1,73 @@
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <streambuf>
+
+#include "boost/filesystem/operations.hpp" // includes boost/filesystem/path.hpp
+#include "boost/filesystem/fstream.hpp"    // ditto
+
+#include <boost/iostreams/device/file_descriptor.hpp>
+
+#include "zypp/SourceFactory.h"
+
+#include "zypp/base/Logger.h"
+#include "zypp/base/Exception.h"
+///////////////////////////////////////////////////////////////////
+
+#include "zypp/target/store/PersistentStorage.h"
+#include "zypp/base/Logger.h"
+#include "testsuite/utils/TestUtils.h"
+
+#include "Benchmark.h"
+
+using namespace zypp::detail;
+using namespace std;
+using namespace zypp;
+using namespace zypp::storage;
+using namespace zypp::source;
+
+using namespace boost::filesystem;
+
+using namespace zypp::testsuite::utils;
+
+#define PATCH_FILE "../../../devel/devel.jsrain/repodata/patch.xml"
+
+typedef std::list<ResObject::Ptr> ResObjectPtrList;
+
+int main( int argc, char * argv[])
+{
+  bool descr = false;
+  bool deps = false;
+  
+  int argpos = 1;
+
+  while ( argpos  < argc )
+  {
+    if ((strcmp( argv[argpos], "-h") == 0) || (strcmp( argv[argpos], "--help") == 0)) {
+      cerr << "Usage: dumpstore [--descr] [--deps]" << endl;
+      exit (1);
+    }
+    if (strcmp( argv[argpos], "--descr") == 0) {
+      descr = true;
+    }
+    if (strcmp( argv[argpos], "--deps") == 0) {
+      deps = true;     
+    }
+    ++argpos;
+  }
+  
+  try { 
+    //getZYpp()->initTarget("/", false);
+    PersistentStorage *_backend = new PersistentStorage();
+    _backend->init("/");
+    ResObjectPtrList objs = _backend->storedObjects();
+    dump(objs, descr, deps);
+    return 0;
+  }
+  catch ( std::exception &e )
+  {
+    ERR << "store read failed" << std::endl;
+    return 1;
+  }
+  return 1;
+}