Author: dmacvicar Date: Fri Oct 17 16:10:58 2008 New Revision: 11392 URL: http://svn.opensuse.org/viewcvs/zypp?rev=11392&view=rev Log: Kinda got it working ... :-/ Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/directory.yast trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir1/directory.yast trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir2/directory.yast trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/directory.yast trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir1/directory.yast trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir2/directory.yast trunk/libzypp/tests/zypp/data/Fetcher/remote-site/directory.yast Modified: trunk/libzypp/tests/lib/CMakeLists.txt trunk/libzypp/tests/lib/WebServer.cc trunk/libzypp/tests/lib/WebServer.h trunk/libzypp/tests/zypp/CMakeLists.txt trunk/libzypp/tests/zypp/Fetcher_test.cc Modified: trunk/libzypp/tests/lib/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/lib/CMakeLists.txt?rev=11392&r1=11391&r2=11392&view=diff ============================================================================== --- trunk/libzypp/tests/lib/CMakeLists.txt (original) +++ trunk/libzypp/tests/lib/CMakeLists.txt Fri Oct 17 16:10:58 2008 @@ -7,4 +7,4 @@ WebServer.cc ) -TARGET_LINK_LIBRARIES(zypp_test_utils shttp zypp) +TARGET_LINK_LIBRARIES(zypp_test_utils shttp zypp boost_thread-mt) Modified: trunk/libzypp/tests/lib/WebServer.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/lib/WebServer.cc?rev=11392&r1=11391&r2=11392&view=diff ============================================================================== --- trunk/libzypp/tests/lib/WebServer.cc (original) +++ trunk/libzypp/tests/lib/WebServer.cc Fri Oct 17 16:10:58 2008 @@ -12,24 +12,64 @@ using namespace zypp; #include "shttpd.h" - +#include "boost/bind.hpp" #include "WebServer.h" +#define LISTENING_PORT "8080" + +static shttpd_ctx * do_init_ctx() +{ + static char *argv[] = {"a", "-ports", LISTENING_PORT, NULL}; + static int argc = sizeof(argv) / sizeof(argv[0]) - 1; + shttpd_ctx *ctx; + + ctx = shttpd_init(argc, argv); + return ctx; +} + WebServer::WebServer(const Pathname root, unsigned int port) - : _docroot(root), _port(port) + : _docroot(root), _port(port), _stop(false) { - _ctx = shttpd_init(0, NULL); - shttpd_set_option(_ctx, "root", root.c_str()); - shttpd_set_option(_ctx, "ports", str::numstring(port).c_str()); + // init with a user port + _ctx = do_init_ctx(); + setStrOption("root", root.asString()); + setNumOption("ports", port); +} +void WebServer::start() +{ +// _thrd.reset( new boost::thread(web_thread(_ctx)) ); + _thrd.reset( new boost::thread( boost::bind(&WebServer::worker_thread, this) ) ); } -void WebServer::operator()() +void WebServer::worker_thread() { - for (;;) + while( ! _stop ) shttpd_poll(_ctx, 1000); } + +void WebServer::setStrOption( std::string name, std::string value) +{ + if ( ! shttpd_set_option(_ctx, name.c_str(), + value.c_str() ) ) + ZYPP_THROW(Exception("bad option")); +} + +void WebServer::setNumOption( std::string name, int value) +{ + if ( ! shttpd_set_option(_ctx, name.c_str(), + str::numstring(value).c_str()) ) + ZYPP_THROW(Exception("bad ioption")); +} + +void WebServer::stop() +{ + _stop = true; + _thrd->join(); + _thrd.reset(); +} + WebServer::~WebServer() { shttpd_fini(_ctx); Modified: trunk/libzypp/tests/lib/WebServer.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/lib/WebServer.h?rev=11392&r1=11391&r2=11392&view=diff ============================================================================== --- trunk/libzypp/tests/lib/WebServer.h (original) +++ trunk/libzypp/tests/lib/WebServer.h Fri Oct 17 16:10:58 2008 @@ -2,24 +2,35 @@ #ifndef ZYPP_WEBSERVER_H #define ZYPP_WEBSERVER_H +#include "boost/thread.hpp" +#include "boost/smart_ptr.hpp" + #include "zypp/Pathname.h" +#include "zypp/base/PtrTypes.h" struct shttpd_ctx; class WebServer { public: - WebServer(const zypp::Pathname root, unsigned int port); + WebServer(const zypp::Pathname root, unsigned int port=9099); ~WebServer(); void start(); - - void operator()(); + void stop(); + private: + + void setStrOption( std::string name, std::string value); + void setNumOption( std::string name, int value); + + void worker_thread(); struct shttpd_ctx *_ctx; zypp::Pathname _docroot; unsigned int _port; + zypp::shared_ptrboost::thread _thrd; + bool _stop; }; #endif Modified: trunk/libzypp/tests/zypp/CMakeLists.txt URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/CMakeLists.txt?rev=11392&r1=11391&r2=11392&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/CMakeLists.txt (original) +++ trunk/libzypp/tests/zypp/CMakeLists.txt Fri Oct 17 16:10:58 2008 @@ -32,4 +32,3 @@ Vendor2 ) -#TARGET_LINK_LIBRARIES(Fetcher_test boost_thread-mt) \ No newline at end of file Modified: trunk/libzypp/tests/zypp/Fetcher_test.cc URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/Fetcher_test.cc?rev=11392&r1=11391&r2=11392&view=diff ============================================================================== --- trunk/libzypp/tests/zypp/Fetcher_test.cc (original) +++ trunk/libzypp/tests/zypp/Fetcher_test.cc Fri Oct 17 16:10:58 2008 @@ -78,6 +78,33 @@ //MIL << fetcher; } +BOOST_AUTO_TEST_CASE(fetcher_remove) +{ + // at this point the key is already trusted + { + // add the key as trusted + //getZYpp()->keyRing()->importKey(PublicKey(DATADIR + "/complexdir/subdir1/SHA1SUMS.key"), true); + + WebServer web((Pathname(TESTS_SRC_DIR) + "/zypp/data/Fetcher/remote-site").c_str() ); + web.start(); + + MediaSetAccess media( Url("http://localhost:9099"), "/" ); + Fetcher fetcher; + filesystem::TmpDir dest; + + fetcher.enqueueDir(OnMediaLocation().setFilename("/complexdir"), true); + fetcher.start( dest.path(), media ); + + fetcher.reset(); + + fetcher.enqueueDir(OnMediaLocation().setFilename("/complexdir-broken"), true); + BOOST_CHECK_THROW( fetcher.start( dest.path(), media ), Exception); + + fetcher.reset(); + + web.stop(); + } +} // vim: set ts=2 sts=2 sw=2 ai et: Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/directory.yast URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/directory.yast?rev=11392&view=auto ============================================================================== --- trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/directory.yast (added) +++ trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/directory.yast Fri Oct 17 16:10:58 2008 @@ -0,0 +1,3 @@ +directory.yast +subdir1/ +subdir2/ Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir1/directory.yast URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir1/directory.yast?rev=11392&view=auto ============================================================================== --- trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir1/directory.yast (added) +++ trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir1/directory.yast Fri Oct 17 16:10:58 2008 @@ -0,0 +1,6 @@ +directory.yast +SHA1SUMS +SHA1SUMS.asc +SHA1SUMS.key +subdir1-file1.txt +subdir1-file2.txt Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir2/directory.yast URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir2/directory.yast?rev=11392&view=auto ============================================================================== --- trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir2/directory.yast (added) +++ trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir-broken/subdir2/directory.yast Fri Oct 17 16:10:58 2008 @@ -0,0 +1,5 @@ +directory.yast +SHA1SUMS +SHA1SUMS.asc +SHA1SUMS.key +subdir2-file1.txt Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/directory.yast URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/directory.yast?rev=11392&view=auto ============================================================================== --- trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/directory.yast (added) +++ trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/directory.yast Fri Oct 17 16:10:58 2008 @@ -0,0 +1,2 @@ +subdir1/ +subdir2/ Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir1/directory.yast URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir1/directory.yast?rev=11392&view=auto ============================================================================== --- trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir1/directory.yast (added) +++ trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir1/directory.yast Fri Oct 17 16:10:58 2008 @@ -0,0 +1,6 @@ +directory.yast +SHA1SUMS +SHA1SUMS.asc +SHA1SUMS.key +subdir1-file1.txt +subdir1-file2.txt Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir2/directory.yast URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir2/directory.yast?rev=11392&view=auto ============================================================================== --- trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir2/directory.yast (added) +++ trunk/libzypp/tests/zypp/data/Fetcher/remote-site/complexdir/subdir2/directory.yast Fri Oct 17 16:10:58 2008 @@ -0,0 +1,5 @@ +directory.yast +SHA1SUMS +SHA1SUMS.asc +SHA1SUMS.key +subdir2-file1.txt Added: trunk/libzypp/tests/zypp/data/Fetcher/remote-site/directory.yast URL: http://svn.opensuse.org/viewcvs/zypp/trunk/libzypp/tests/zypp/data/Fetcher/remote-site/directory.yast?rev=11392&view=auto ============================================================================== --- trunk/libzypp/tests/zypp/data/Fetcher/remote-site/directory.yast (added) +++ trunk/libzypp/tests/zypp/data/Fetcher/remote-site/directory.yast Fri Oct 17 16:10:58 2008 @@ -0,0 +1,10 @@ +complexdir/ +complexdir-broken/ +diffs/ +file-1.txt +file-2.txt +file-3.txt +file-4.txt +file-current.txt +file-current.txt.asc +file-current.txt.key -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org