4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief net.test public header */
31 #include "net.test.hh"
39 #include <boost/format.hpp>
40 #include <senf/Utils/auto_unit_test.hh>
41 #include <boost/test/test_tools.hpp>
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
49 void senf::test::error(char const * fn, char const * proc)
51 std::cerr << "\n" << proc << ((*proc)?": ":"") << fn << ": " << strerror(errno) << std::endl;
54 void senf::test::fail(char const * proc, char const * fn)
60 void senf::test::start(void (*fn)())
63 base_pid = ::getpid();
64 server_pid = ::fork();
65 if (server_pid < 0) BOOST_FAIL("fork()");
66 if (server_pid == 0) {
67 signal(SIGCHLD, SIG_IGN);
71 signal(SIGCHLD, SIG_DFL);
75 void senf::test::wait()
78 if (waitpid(server_pid,&status,0)<0)
79 BOOST_FAIL("waitpid()");
80 BOOST_CHECK_EQUAL( status , 0 );
83 void senf::test::stop()
92 unsigned senf::test::port(unsigned i)
95 base_pid = ::getpid();
96 return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i;
99 std::string senf::test::localhost4str(unsigned i)
101 return (boost::format("localhost:%d") % port(i)).str();
104 std::string senf::test::localhost6str(unsigned i)
106 return (boost::format("[::1]:%d") % port(i)).str();
110 //-/////////////////////////////////////////////////////////////////////////////////////////////////
111 //#include "net.test.cci"
112 //#include "net.test.ct"
113 //#include "net.test.cti"
119 // comment-column: 40
120 // c-file-style: "senf"
121 // indent-tabs-mode: nil
122 // ispell-local-dictionary: "american"
123 // compile-command: "scons -u test"