BOOST_CHECK_EQUAL( pi2->data().size(), 1u );
BOOST_CHECK_EQUAL( pi2b->data().size(), 2u );
- BOOST_CHECK_EQUAL( pi1->data().size(), pi1->nextPacketRange()->size() );
+ BOOST_CHECK_EQUAL( pi1->data().size(), unsigned(pi1->nextPacketRange()->size()) );
pi1->append(pi2b);
BOOST_CHECK_EQUAL( pi1->data().size(), 2u );
BOOST_REQUIRE( pi1->next() );
senf::PacketInterpreterBase::ptr p2 (p->parseNextAs(factory));
BOOST_CHECK( p2->is<OtherPacket>() );
BOOST_CHECK( ! p2->is<VoidPacket>() );
- BOOST_CHECK_EQUAL( boost::size(*p2->nextPacketRange()), 4u );
+ BOOST_CHECK_EQUAL( unsigned(boost::size(*p2->nextPacketRange())), 4u );
}
}
#include "../../Utils/senfassert.hh"
#include "../../Utils/Range.hh"
#include "../../Utils/String.hh"
+#include "../../Utils/range.hh"
//#include "Executor.mpp"
#define prefix_
{
if (! dir.hasChild(name)) {
DirectoryNode::ChildrenRange completions (dir.completions(name));
- if (completions.size() == 1)
+ if (has_one_elt(completions))
return completions.begin()->first;
}
return name;
#include "Node.hh"
#include "Node.ih"
+#include "../../Utils/range.hh"
// Custom includes
else if (elt_ != "" && elt_ != ".") {
if (! dir_->hasChild(elt_) && autocomplete_) {
DirectoryNode::ChildrenRange completions (dir_->completions(elt_));
- if (completions.size() == 1)
+ if (has_one_elt(completions))
elt_ = completions.begin()->first;
}
// Why does g++ give an error on this line ???? :
if (elt_ != "" && elt_ != ".") {
if (! dir_->hasChild(elt_) && autocomplete_) {
DirectoryNode::ChildrenRange completions (dir_->completions(elt_));
- if (completions.size() == 1)
+ if (has_one_elt(completions))
elt_ = completions.begin()->first;
}
return dir_->get(elt_);
senf::console::root().remove("dir2");
senf::console::root().remove("fn");
- BOOST_CHECK_EQUAL( senf::console::root().children().size(), 1u );
+ BOOST_CHECK_EQUAL( std::distance(senf::console::root().children().begin(),
+ senf::console::root().children().end()), 1 );
}
BOOST_AUTO_UNIT_TEST(linkNode)
BOOST_CHECK_EQUAL_COLLECTIONS( info.commandPath().begin(), info.commandPath().end(),
path, path + sizeof(path)/sizeof(path[0]) );
- BOOST_CHECK_EQUAL( info.tokens().size(), 15u );
+ BOOST_CHECK_EQUAL( unsigned(info.tokens().size()), 15u );
char const * tokens[] = { "arg",
"flab::blub",
senf::console::ParseCommandInfo::argument_iterator args (info.arguments().begin());
BOOST_REQUIRE( args != info.arguments().end() );
- BOOST_REQUIRE_EQUAL( args->size(), 1u );
+ BOOST_REQUIRE_EQUAL( unsigned(args->size()), 1u );
BOOST_CHECK_EQUAL( args->begin()->value(), tokens[0] );
++ args;
{
// We NEED to know the number of arguments beforehand so we can assign default values
// correctly ... hrmpf ...
- unsigned nArgs ( command.arguments().size() );
+ unsigned nArgs ( std::distance(command.arguments().begin(), command.arguments().end()) );
if ( nArgs > BOOST_PP_ITERATION() )
throw SyntaxErrorException("invalid number of arguments");
int nDefaults ( BOOST_PP_ITERATION() - nArgs );
+ (void) nDefaults;
- typedef typename boost::range_const_reverse_iterator<ParseCommandInfo::ArgumentsRange>::type
+ typedef typename boost::range_reverse_iterator<const ParseCommandInfo::ArgumentsRange>::type
riterator;
riterator i (boost::rbegin(command.arguments()));
riterator const i_end (boost::rend(command.arguments()));
{
// We NEED to know the number of arguments beforehand so we can assign default values
// correctly ... hrmpf ...
- unsigned nArgs ( command.arguments().size() );
+ unsigned nArgs ( std::distance(command.arguments().begin(), command.arguments().end()) );
if ( nArgs > BOOST_PP_ITERATION() )
throw SyntaxErrorException("invalid number of arguments");
int nDefaults ( BOOST_PP_ITERATION() - nArgs );
+ (void) nDefaults;
- typedef typename boost::range_const_reverse_iterator<ParseCommandInfo::ArgumentsRange>::type
+ typedef typename boost::range_reverse_iterator<const ParseCommandInfo::ArgumentsRange>::type
riterator;
riterator i (boost::rbegin(command.arguments()));
riterator const i_end (boost::rend(command.arguments()));
// Custom includes
#include <boost/algorithm/string/predicate.hpp>
#include <boost/format.hpp>
+#include "../../Utils/range.hh"
//#include "ProgramOptions.mpp"
#define prefix_
std::string key (name.substr(b,e-b));
if (! cwd->hasChild(key)) {
DirectoryNode::ChildrenRange completions (cwd->completions(key));
- if (completions.size() == 1)
+ if (has_one_elt(completions))
key = completions.begin()->first;
else
continue;
unlink(SOCK_PATH);
int pid = fork();
if (pid == 0) {
+ signal(SIGCHLD, SIG_IGN);
server();
_exit(0);
}
error("fork");
return 0;
}
+ signal(SIGCHLD, SIG_DFL);
sleep(1); // Wait for the server socket to be opened
return pid;
unlink(SOCK_PATH);
int pid = fork();
if (pid == 0) {
+ signal(SIGCHLD, SIG_IGN);
server();
_exit(0);
}
error("fork");
return 0;
}
+ signal(SIGCHLD, SIG_DFL);
sleep(1); // Wait for the server socket to be opened
return pid;
server_pid = ::fork();
if (server_pid < 0) BOOST_FAIL("fork()");
if (server_pid == 0) {
+ signal(SIGCHLD, SIG_IGN);
(*fn)();
_exit(0);
}
+ signal(SIGCHLD, SIG_DFL);
::sleep(1);
}
BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
- BOOST_CHECK_NO_THROW( sock.write("TEST-WRITE") );
- BOOST_CHECK_EQUAL( sock.read(), "TEST-WRITE" );
+ BOOST_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
+ BOOST_CHECK_EQUAL( sock.read(), std::string("TEST-WRITE") );
BOOST_CHECK( !sock.eof() );
- sock.write("QUIT");
+ sock.write(std::string("QUIT"));
sleep(1);
stop();
sleep(1);
BOOST_CHECK_EQUAL( sock.protocol().rcvbuf(), 2048u );
BOOST_CHECK_NO_THROW( sock.protocol().sndbuf(2048) );
BOOST_CHECK_EQUAL( sock.protocol().sndbuf(), 2048u );
- BOOST_CHECK_NO_THROW( sock.write("TEST-WRITE") );
- BOOST_CHECK_EQUAL( sock.read(), "TEST-WRITE" );
+ BOOST_CHECK_NO_THROW( sock.write(std::string("TEST-WRITE")) );
+ BOOST_CHECK_EQUAL( sock.read(), std::string("TEST-WRITE") );
// this fails with ENOFILE ... why ????
// BOOST_CHECK_NO_THROW( sock.protocol().timestamp() );
BOOST_CHECK( !sock.eof() );
- sock.write("QUIT");
+ sock.write(std::string("QUIT"));
sleep(1);
stop();
sleep(1);
BOOST_CHECKPOINT("Accepting connection");
senf::TCPv4ClientSocketHandle client = server.accept();
- BOOST_CHECK_NO_THROW(client.write("QUIT"));
+ BOOST_CHECK_NO_THROW(client.write(std::string("QUIT")));
BOOST_CHECKPOINT("Stopping client");
sleep(1);
BOOST_CHECKPOINT("Accepting connection");
senf::TCPv6ClientSocketHandle client = server.accept();
- BOOST_CHECK_NO_THROW(client.write("QUIT"));
+ BOOST_CHECK_NO_THROW(client.write(std::string("QUIT")));
BOOST_CHECKPOINT("Stopping client");
sleep(1);
server_pid = ::fork();
if (server_pid < 0) BOOST_FAIL("fork()");
if (server_pid == 0) {
+ signal(SIGCHLD, SIG_IGN);
(*fn)();
_exit(0);
}
+ signal(SIGCHLD, SIG_DFL);
}
void wait()
std::string("TEST-WRITE")) );
BOOST_CHECK_EQUAL( sock.read(), "TEST-WRITE" );
BOOST_CHECK_NO_THROW( sock.protocol().timestamp() );
- sock.writeto(senf::INet4SocketAddress("127.0.0.1:12345"),"QUIT");
+ sock.writeto(senf::INet4SocketAddress("127.0.0.1:12345"), std::string("QUIT"));
sleep(1);
stop();
sleep(1);
if (pid < 0) throw senf::SystemException("::fork()");
if (pid == 0) {
signal(SIGABRT, &backtrace);
+ signal(SIGCHLD, SIG_IGN);
try {
::_exit(myMain(argc, argv));
} catch (std::exception & ex) {
}
::_exit(125);
}
+ signal(SIGCHLD, SIG_DFL);
int status;
if (::waitpid(pid, &status, 0) < 0)
throw senf::SystemException("::waitpid()");
"--console-log=testDaemon.log",
"--pid-file=testDaemon.pid" };
- BOOST_CHECK_EQUAL( run(sizeof(args)/sizeof(*args), const_cast<char **>(args)), 0 );
+ SENF_CHECK_NO_THROW( BOOST_CHECK_EQUAL( run(sizeof(args)/sizeof(*args), const_cast<char **>(args)), 0 ) );
BOOST_CHECK( ! boost::filesystem::exists("invalid.log") );
BOOST_CHECK( ! boost::filesystem::exists("invalid.pid") );
template <class ArgumentPack, class TagType>
struct has_parameter
: public boost::mpl::not_<
- boost::is_same< typename boost::parameter::binding< ArgumentPack, TagType>::type,
+ boost::is_same< typename boost::parameter::binding< ArgumentPack, TagType, void>::type,
void > >::type
{};
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief range inline template implementation */
+
+//#include "range.ih"
+
+// Custom includes
+#include <boost/utility.hpp>
+
+#define prefix_ inline
+///////////////////////////////cti.p///////////////////////////////////////
+
+template <class Range>
+prefix_ bool senf::has_one_elt(Range r)
+{
+ return ! r.empty() && boost::next(r.begin()) == r.end();
+}
+
+///////////////////////////////cti.e///////////////////////////////////////
+#undef prefix_
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
--- /dev/null
+// $Id$
+//
+// Copyright (C) 2008
+// Fraunhofer Institute for Open Communication Systems (FOKUS)
+// Competence Center NETwork research (NET), St. Augustin, GERMANY
+// Stefan Bund <g0dil@berlios.de>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the
+// Free Software Foundation, Inc.,
+// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+/** \file
+ \brief range public header */
+
+#ifndef HH_range_
+#define HH_range_ 1
+
+// Custom includes
+
+//#include "range.mpp"
+///////////////////////////////hh.p////////////////////////////////////////
+
+namespace senf {
+
+ template <class Range>
+ bool has_one_elt(Range r);
+
+}
+
+///////////////////////////////hh.e////////////////////////////////////////
+//#include "range.cci"
+//#include "range.ct"
+#include "range.cti"
+#endif
+
+\f
+// Local Variables:
+// mode: c++
+// fill-column: 100
+// comment-column: 40
+// c-file-style: "senf"
+// indent-tabs-mode: nil
+// ispell-local-dictionary: "american"
+// compile-command: "scons -u test"
+// End:
Source: libsenf
Priority: extra
Maintainer: Stefan Bund <senf-dev@lists.berlios.de>
-Build-Depends: debhelper (>= 5), scons (>= 0.97), binutils-dev, libboost-dev,
+Build-Depends: debhelper (>= 5), scons (>= 0.97), g++, binutils-dev, libboost-dev,
libboost-test-dev, libboost-date-time-dev, libboost-regex-dev,
libboost-filesystem-dev, libboost-serialization-dev, libboost-iostreams-dev,
doxygen (>= 1.5.5), libreadline-dev, dia, tidy, xsltproc, graphviz, perl-base,
opts.Add('BOOST_RUNTIME', 'The boost runtime to use', '')
opts.Add('BOOST_DEBUG_RUNTIME', 'The boost debug runtime to use', '')
opts.Add('BOOST_LIBDIR', 'The directory of the boost libraries', '')
+ opts.Add('BOOST_PREFIX', 'The prefix into which boost is installed', '')
+ opts.Add('BOOST_VERSION', 'The version of boost to use', '')
Finalizer(FinalizeBoost)
## \brief Finalize Boost environment
if runtime: runtime = "-" + runtime
env['BOOST_VARIANT'] = "-" + env['BOOST_TOOLSET'] + runtime
+ if env['BOOST_VARIANT'] and env['BOOST_VERSION']:
+ env['BOOST_VARIANT'] = env['BOOST_VARIANT'] + '-%s' % env['BOOST_VERSION'].replace('.','_')
+
env['BOOSTTESTLIB'] = 'boost_unit_test_framework' + env['BOOST_VARIANT']
env['BOOSTREGEXLIB'] = 'boost_regex' + env['BOOST_VARIANT']
env['BOOSTFSLIB'] = 'boost_filesystem' + env['BOOST_VARIANT']
env['BOOSTIOSTREAMSLIB'] = 'boost_iostreams' + env['BOOST_VARIANT']
+ if env['BOOST_PREFIX']:
+ env['BOOST_LIBDIR'] = os.path.join(env['BOOST_PREFIX'], 'lib')
+ env['BOOST_INCLUDES'] = os.path.join(env['BOOST_PREFIX'],
+ 'include/boost-%s'
+ % env['BOOST_VERSION'].replace('.','_'))
+
env.Append(LIBPATH = [ '$BOOST_LIBDIR' ],
CPPPATH = [ '$BOOST_INCLUDES' ])
+ if env['BOOST_LIBDIR']:
+ env.Append(ENV = { 'LD_LIBRARY_PATH': env['BOOST_LIBDIR'] })
+
## \brief Use STLPort as STL replacement if available
#
# Use <a href="http://www.stlport.org">STLPort</a> as a replacement