add parser test
authorKlaus Kaempf <kkaempf@suse.de>
Wed, 8 Feb 2006 21:53:53 +0000 (21:53 +0000)
committerKlaus Kaempf <kkaempf@suse.de>
Wed, 8 Feb 2006 21:53:53 +0000 (21:53 +0000)
testsuite/source/tests/Makefile.am
testsuite/source/tests/suseparser.cc [new file with mode: 0644]

index ba701f2..f34ff5b 100644 (file)
@@ -8,9 +8,11 @@ noinst_PROGRAMS = \
        selectiontagparsertest  \
        patterntagparsertest    \
        producttagparsertest    \
-       mediatagparsertest
+       mediatagparsertest      \
+       suseparser
        
 selectiontagparsertest_SOURCES = SelectionTagParserTest.cc
 patterntagparsertest_SOURCES = PatternTagParserTest.cc
 producttagparsertest_SOURCES = ProductMetadataParserTest.cc
 mediatagparsertest_SOURCES = MediaMetadataParserTest.cc
+suseparser_SOURCES = suseparser.cc
diff --git a/testsuite/source/tests/suseparser.cc b/testsuite/source/tests/suseparser.cc
new file mode 100644 (file)
index 0000000..610368d
--- /dev/null
@@ -0,0 +1,49 @@
+// test for SUSE Source
+//
+
+#include <iostream>
+#include <fstream>
+#include <map>
+#include "zypp/base/Logger.h"
+#include "zypp/SourceFactory.h"
+#include "zypp/Source.h"
+#include "zypp/source/SourceImpl.h"
+#include "zypp/media/MediaManager.h"
+
+using namespace std;
+using namespace zypp;
+
+/******************************************************************
+**
+**
+**     FUNCTION NAME : main
+**     FUNCTION TYPE : int
+**
+**     DESCRIPTION :
+*/
+int main( int argc, char * argv[] )
+{
+    if (argc < 2) {
+       cerr << "Usage: suseparse <susedir>" << endl;
+       exit (1);
+    }
+
+    INT << "===[START]==========================================" << endl;
+
+    Pathname p;
+    Url url(argv[1]);
+    string alias("suseparse");
+    Locale lang( "en" );
+
+    Pathname cache_dir("");
+    Source_Ref src( SourceFactory().createFrom(url, p, alias, cache_dir) );
+
+    ResStore store = src.resolvables();
+    INT << "Found " << store.size() << " packages" << endl;
+    if (store.size() > 0) {
+       ResStore::iterator it = store.begin();
+       MIL << "First " << (*it)->name() << ":" << (*it)->summary() << endl << (*it)->description() << endl;
+    }
+    INT << "===[END]============================================" << endl;
+    return 0;
+}