diff --git a/Packets/PacketInterpreter.test.cc b/Packets/PacketInterpreter.test.cc index 77e13ad84eb088d577055c146ef766b6129c2a47..49f6ebd91bd0ff7e4d3db010e51fc9c6b994eb71 100644 --- a/Packets/PacketInterpreter.test.cc +++ b/Packets/PacketInterpreter.test.cc @@ -80,7 +80,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreterBase) 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() ); @@ -286,7 +286,7 @@ BOOST_AUTO_UNIT_TEST(packetInterpreter_factory) 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 ); } } diff --git a/Scheduler/Console/Executor.cc b/Scheduler/Console/Executor.cc index 5a6337dd3394f5dbb6ae39fce38ba5a09e89d5cc..8f054c789c70885b7cc01fb76220189235cfbc2d 100644 --- a/Scheduler/Console/Executor.cc +++ b/Scheduler/Console/Executor.cc @@ -33,6 +33,7 @@ #include "../../Utils/senfassert.hh" #include "../../Utils/Range.hh" #include "../../Utils/String.hh" +#include "../../Utils/range.hh" //#include "Executor.mpp" #define prefix_ @@ -301,7 +302,7 @@ prefix_ std::string senf::console::Executor::complete(DirectoryNode & dir, { 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; diff --git a/Scheduler/Console/Node.cc b/Scheduler/Console/Node.cc index fddf01a01fab2736f2f09c8f4c9f0efbff431f70..39c26859d46d9f11f14c7ceca344cd64f92634c2 100644 --- a/Scheduler/Console/Node.cc +++ b/Scheduler/Console/Node.cc @@ -25,6 +25,7 @@ #include "Node.hh" #include "Node.ih" +#include "../../Utils/range.hh" // Custom includes @@ -173,7 +174,7 @@ prefix_ void senf::console::detail::NodeTraverser::operator()(std::string const 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 ???? : @@ -190,7 +191,7 @@ prefix_ senf::console::GenericNode & senf::console::detail::NodeTraverser::node( 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_); diff --git a/Scheduler/Console/Node.test.cc b/Scheduler/Console/Node.test.cc index cc786dc43c294dbdf770283a6554ac97490e9afd..810ce2532ef104ad9095600e281af00159908171 100644 --- a/Scheduler/Console/Node.test.cc +++ b/Scheduler/Console/Node.test.cc @@ -116,7 +116,8 @@ BOOST_AUTO_UNIT_TEST(directoryNode) 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) diff --git a/Scheduler/Console/Parse.test.cc b/Scheduler/Console/Parse.test.cc index 472b9a3ae8d5ee04af86c691fee0792736e1604b..4570fb0e61c706b49ee4a55d9cce22c90f563c5c 100644 --- a/Scheduler/Console/Parse.test.cc +++ b/Scheduler/Console/Parse.test.cc @@ -211,7 +211,7 @@ BOOST_AUTO_UNIT_TEST(commandParser) 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", @@ -222,7 +222,7 @@ BOOST_AUTO_UNIT_TEST(commandParser) 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; diff --git a/Scheduler/Console/ParsedCommand.mpp b/Scheduler/Console/ParsedCommand.mpp index c5ffd18450dc2fbbf58e8bd2f1755c16a40cfcba..f444a6b2c52236d187663461e16ab7a597a0e412 100644 --- a/Scheduler/Console/ParsedCommand.mpp +++ b/Scheduler/Console/ParsedCommand.mpp @@ -254,12 +254,13 @@ v_execute(std::ostream & os, ParseCommandInfo const & command) { // 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())); @@ -293,12 +294,13 @@ v_execute(std::ostream & os, ParseCommandInfo const & command) { // 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())); diff --git a/Scheduler/Console/ProgramOptions.cc b/Scheduler/Console/ProgramOptions.cc index 9f147365208187beaae2539af5d7786b8a7fd04b..63bcfb15f33ed196c6b9b050305582a590194e74 100644 --- a/Scheduler/Console/ProgramOptions.cc +++ b/Scheduler/Console/ProgramOptions.cc @@ -29,6 +29,7 @@ // Custom includes #include <boost/algorithm/string/predicate.hpp> #include <boost/format.hpp> +#include "../../Utils/range.hh" //#include "ProgramOptions.mpp" #define prefix_ @@ -115,7 +116,7 @@ senf::console::detail::ProgramOptionsSource::parseLongOption(std::string const & 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; diff --git a/Scheduler/FdEvent.test.cc b/Scheduler/FdEvent.test.cc index 6ca3572182bc901f97ef982035e063ff85204693..21f3addd791ba7e5fc253828948c624b54678323 100644 --- a/Scheduler/FdEvent.test.cc +++ b/Scheduler/FdEvent.test.cc @@ -102,6 +102,7 @@ namespace { unlink(SOCK_PATH); int pid = fork(); if (pid == 0) { + signal(SIGCHLD, SIG_IGN); server(); _exit(0); } @@ -109,6 +110,7 @@ namespace { error("fork"); return 0; } + signal(SIGCHLD, SIG_DFL); sleep(1); // Wait for the server socket to be opened return pid; diff --git a/Scheduler/Scheduler.test.cc b/Scheduler/Scheduler.test.cc index a46aa18da2e44aaa36523d2219c4a0378d326763..bc627a3b61d6b9bf7c9f07948e2fa4c19e995959 100644 --- a/Scheduler/Scheduler.test.cc +++ b/Scheduler/Scheduler.test.cc @@ -102,6 +102,7 @@ namespace { unlink(SOCK_PATH); int pid = fork(); if (pid == 0) { + signal(SIGCHLD, SIG_IGN); server(); _exit(0); } @@ -109,6 +110,7 @@ namespace { error("fork"); return 0; } + signal(SIGCHLD, SIG_DFL); sleep(1); // Wait for the server socket to be opened return pid; diff --git a/Socket/Protocols/INet/TCPSocketHandle.test.cc b/Socket/Protocols/INet/TCPSocketHandle.test.cc index 3ed3a0a0e8dc701c5095d1ed8474892e9a557a0b..70d599eafb0afacfe9fff3147119d3b388b3c0b1 100644 --- a/Socket/Protocols/INet/TCPSocketHandle.test.cc +++ b/Socket/Protocols/INet/TCPSocketHandle.test.cc @@ -61,9 +61,11 @@ namespace { 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); } @@ -174,10 +176,10 @@ BOOST_AUTO_UNIT_TEST(tcpv4ClientSocketHandle) 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); @@ -245,12 +247,12 @@ BOOST_AUTO_UNIT_TEST(tcpv6ClientSocketHandle) 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); @@ -347,7 +349,7 @@ BOOST_AUTO_UNIT_TEST(tcpv4ServerSocketHandle) 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); @@ -373,7 +375,7 @@ BOOST_AUTO_UNIT_TEST(tcpv6ServerSocketHandle) 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); diff --git a/Socket/Protocols/INet/UDPSocketHandle.test.cc b/Socket/Protocols/INet/UDPSocketHandle.test.cc index 39cece6fb724082051c47f5b3d4fbd0221ba0356..44c51ece5bb76156d97a59a8ea5f923bb7c483e3 100644 --- a/Socket/Protocols/INet/UDPSocketHandle.test.cc +++ b/Socket/Protocols/INet/UDPSocketHandle.test.cc @@ -62,9 +62,11 @@ namespace { 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() @@ -154,7 +156,7 @@ BOOST_AUTO_UNIT_TEST(udpv4ClientSocketHandle) 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); diff --git a/Utils/Daemon/Daemon.test.cc b/Utils/Daemon/Daemon.test.cc index d9e4a3eddec6fd647cda7e0feddb540df3c41a8c..6d991c41e2e96dff103c3e2821eaa56035335d95 100644 --- a/Utils/Daemon/Daemon.test.cc +++ b/Utils/Daemon/Daemon.test.cc @@ -94,6 +94,7 @@ namespace { 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) { @@ -103,6 +104,7 @@ namespace { } ::_exit(125); } + signal(SIGCHLD, SIG_DFL); int status; if (::waitpid(pid, &status, 0) < 0) throw senf::SystemException("::waitpid()"); @@ -122,7 +124,7 @@ BOOST_AUTO_UNIT_TEST(testDaemon) "--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") ); diff --git a/Utils/parameter.hh b/Utils/parameter.hh index 478925a24b1c12e5ab70c9294e51f8f626b53435..7ea462c7ba1c51bee502db6eaabe61d782323245 100644 --- a/Utils/parameter.hh +++ b/Utils/parameter.hh @@ -58,7 +58,7 @@ namespace senf { 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 {}; diff --git a/Utils/range.cti b/Utils/range.cti new file mode 100644 index 0000000000000000000000000000000000000000..197e10c3143ee0ac966a1c6dd55144d1b9c430a2 --- /dev/null +++ b/Utils/range.cti @@ -0,0 +1,52 @@ +// $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_ + + +// 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: diff --git a/Utils/range.hh b/Utils/range.hh new file mode 100644 index 0000000000000000000000000000000000000000..9d4109b53ef4c199dc1fcd208afa04d00ab36d8b --- /dev/null +++ b/Utils/range.hh @@ -0,0 +1,56 @@ +// $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 + + +// 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: diff --git a/debian/control b/debian/control index bb564cd8fab3ae3ade69badc1bc6e027c55d1b42..92aedad500441b2971c5bc4b776fc3b583a4f9b8 100644 --- a/debian/control +++ b/debian/control @@ -1,7 +1,7 @@ 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, diff --git a/senfscons/SENFSCons.py b/senfscons/SENFSCons.py index 7f08d0b23031357e29c593c284f5b9c2088a94ae..4c3f3b8626edb8444f7294da8b70c6eef575b76e 100644 --- a/senfscons/SENFSCons.py +++ b/senfscons/SENFSCons.py @@ -137,6 +137,8 @@ def UseBoost(): 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 @@ -152,14 +154,26 @@ def FinalizeBoost(env): 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