From b5abd9ce36d89b338c1f29beceffa9df5f0dcf11 Mon Sep 17 00:00:00 2001 From: Klaus Kaempf Date: Wed, 8 Feb 2006 21:53:53 +0000 Subject: [PATCH] add parser test --- testsuite/source/tests/Makefile.am | 4 ++- testsuite/source/tests/suseparser.cc | 49 ++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 testsuite/source/tests/suseparser.cc diff --git a/testsuite/source/tests/Makefile.am b/testsuite/source/tests/Makefile.am index ba701f2..f34ff5b 100644 --- a/testsuite/source/tests/Makefile.am +++ b/testsuite/source/tests/Makefile.am @@ -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 index 0000000..610368d --- /dev/null +++ b/testsuite/source/tests/suseparser.cc @@ -0,0 +1,49 @@ +// test for SUSE Source +// + +#include +#include +#include +#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 " << 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; +} -- 2.7.4