ref: refs/heads/master
commit 2b092bd3b11a2243ea0fce4034ef5d8ab6829a24
Author: Duncan Mac-Vicar P
Date: Thu Feb 5 15:49:25 2009 +0100
finally testcases pass.
add ruby to build requires, as we are using webrick for webserver
testcases for now
---
libzypp.spec.cmake | 3 ++
tests/lib/WebServer.cc | 50 ++++++++++---------------------------------
tests/zypp/Fetcher_test.cc | 6 ++--
3 files changed, 18 insertions(+), 41 deletions(-)
diff --git a/libzypp.spec.cmake b/libzypp.spec.cmake
index 3e28637..159c123 100644
--- a/libzypp.spec.cmake
+++ b/libzypp.spec.cmake
@@ -28,6 +28,9 @@ BuildRequires: cmake
BuildRequires: libsatsolver-devel >= 0.13.0 openssl-devel
BuildRequires: boost-devel curl-devel dejagnu doxygen gcc-c++ gettext-devel graphviz hal-devel libxml2-devel
+# required for testsuite, webrick
+BuildRequires: ruby
+
%if 0%{?suse_version}
BuildRequires: libexpat-devel
%else
diff --git a/tests/lib/WebServer.cc b/tests/lib/WebServer.cc
index 4d05eb8..426b08e 100644
--- a/tests/lib/WebServer.cc
+++ b/tests/lib/WebServer.cc
@@ -1,6 +1,4 @@
-//#include "zypp/ZYpp.h"
-
#include <sstream>
#include <string>
#include "boost/bind.hpp"
@@ -16,7 +14,7 @@
using namespace zypp;
using namespace std;
-#define WEBRICK 0
+#define WEBRICK 1
class WebServer::Impl
{
@@ -81,18 +79,8 @@ public:
_stopped = false;
- while ( _stop );
+ while ( ! _stop );
- /*
- for(line = prog.receiveLine();
- !line.empty();
- line = prog.receiveLine() )
- {
- strlog << line;
- if ( _stop )
- break;
- }
- */
MIL << "Thread end requested" << endl;
//prog.close();
if ( prog.running() )
@@ -133,34 +121,29 @@ class WebServerMongooseImpl : public WebServer::Impl
public:
WebServerMongooseImpl(const Pathname &root, unsigned int port)
: _ctx(0L), _docroot(root)
- , _port(port), _stop(false)
+ , _port(port)
, _stopped(true)
{
}
~WebServerMongooseImpl()
{
+ MIL << "Destroying web server" << endl;
+
if ( ! _stopped )
stop();
}
- virtual void worker_thread()
+ virtual void start()
{
+ MIL << "Starting shttpd (mongoose)" << endl;
_log.clear();
_ctx = mg_start();
if ( ! mg_set_option(_ctx, "ports", str::form("%d", _port).c_str()) )
ZYPP_THROW(Exception("Failed to set port"));
mg_set_option(_ctx, "root", _docroot.c_str());
- stringstream strlog(_log);
-
- while ( !_stop )
- {
- // loop
- }
- MIL << "Thread end requested, shutting down shttpd" << endl;
- mg_stop(_ctx);
- _ctx = 0;
+ _stopped = false;
}
virtual string log() const
@@ -170,25 +153,16 @@ public:
virtual void stop()
{
- MIL << "Waiting for shttpd thread to finish" << endl;
- _stop = true;
- _thrd->join();
- MIL << "shttpd thread to finished" << endl;
- _thrd.reset();
+ MIL << "Stopping shttpd" << endl;
+ mg_stop(_ctx);
+ MIL << "shttpd finished" << endl;
+ _ctx = 0;
_stopped = true;
}
- virtual void start()
- {
- MIL << "Starting shttpd (mongoose) thread" << endl;
- _thrd.reset( new boost::thread( boost::bind(&WebServerMongooseImpl::worker_thread, this) ) );
- }
-
mg_context *_ctx;
zypp::Pathname _docroot;
unsigned int _port;
- zypp::shared_ptrboost::thread _thrd;
- bool _stop;
bool _stopped;
std::string _log;
};
diff --git a/tests/zypp/Fetcher_test.cc b/tests/zypp/Fetcher_test.cc
index a00ece2..c663c11 100644
--- a/tests/zypp/Fetcher_test.cc
+++ b/tests/zypp/Fetcher_test.cc
@@ -328,7 +328,7 @@ BOOST_AUTO_TEST_CASE(enqueuedir_http)
WebServer web((Pathname(TESTS_SRC_DIR) + "/zypp/data/Fetcher/remote-site").c_str(), 10001);
web.start();
- MediaSetAccess media( Url("http://127.0.0.1:10001"), "/" );
+ MediaSetAccess media( Url("http://localhost:10001"), "/" );
Fetcher fetcher;
filesystem::TmpDir dest;
@@ -355,10 +355,10 @@ BOOST_AUTO_TEST_CASE(enqueuedir_http_broken)
// 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() , 10002 );
+ WebServer web((Pathname(TESTS_SRC_DIR) + "/zypp/data/Fetcher/remote-site").c_str() , 10001 );
web.start();
- MediaSetAccess media( Url("http://127.0.0.1:10002"), "/" );
+ MediaSetAccess media( Url("http://localhost:10001"), "/" );
Fetcher fetcher;
filesystem::TmpDir dest;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org