4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief net.test public header */
26 #ifndef HH_SENF_senf_Socket_Protocols_INet_net_test_
27 #define HH_SENF_senf_Socket_Protocols_INet_net_test_ 1
30 #include <boost/format.hpp>
31 #include <boost/test/test_tools.hpp>
33 //#include "net.test.mpp"
34 ///////////////////////////////hh.p////////////////////////////////////////
38 void error(char const * fn, char const * proc="")
40 std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl;
43 void fail(char const * proc, char const * fn)
52 void start(void (*fn)())
55 base_pid = ::getpid();
56 server_pid = ::fork();
57 if (server_pid < 0) BOOST_FAIL("fork()");
58 if (server_pid == 0) {
59 signal(SIGCHLD, SIG_IGN);
63 signal(SIGCHLD, SIG_DFL);
69 if (waitpid(server_pid,&status,0)<0)
70 BOOST_FAIL("waitpid()");
71 BOOST_CHECK_EQUAL( status , 0 );
83 unsigned port(unsigned i)
86 base_pid = ::getpid();
87 return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i;
90 std::string localhost4str(unsigned i)
92 return (boost::format("localhost:%d") % port(i)).str();
95 std::string localhost6str(unsigned i)
97 return (boost::format("[::1]:%d") % port(i)).str();
102 ///////////////////////////////hh.e////////////////////////////////////////
103 //#include "net.test.cci"
104 //#include "net.test.ct"
105 //#include "net.test.cti"
112 // comment-column: 40
113 // c-file-style: "senf"
114 // indent-tabs-mode: nil
115 // ispell-local-dictionary: "american"
116 // compile-command: "scons -u test"