// Custom includes
#include <algorithm>
-#include "../Socket/Protocols/INet/UDPSocketHandle.hh"
-#include "../Scheduler/Scheduler.hh"
+#include <senf/Socket/Protocols/INet/UDPSocketHandle.hh>
+#include <senf/Scheduler/Scheduler.hh>
#include "SocketSource.hh"
#include "DebugModules.hh"
#include "Setup.hh"
-#include "../Utils/auto_unit_test.hh"
+#include <senf/Utils/auto_unit_test.hh>
#include <boost/test/test_tools.hpp>
#define prefix_
void timeout() {
senf::scheduler::terminate();
}
+
+ int base_pid = 0;
+
+ unsigned port(unsigned i)
+ {
+ if (! base_pid)
+ base_pid = ::getpid();
+ return 23456u + (((base_pid^(base_pid>>8)^(base_pid>>16)^(base_pid>>24))&0xff)<<2) + i;
+ }
+
+ std::string localhost4str(unsigned i)
+ {
+ return (boost::format("localhost:%d") % port(i)).str();
+ }
+
+ std::string localhost6str(unsigned i)
+ {
+ return (boost::format("[::1]:%d") % port(i)).str();
+ }
}
BOOST_AUTO_UNIT_TEST(socketSource)
{
senf::UDPv4ClientSocketHandle inputSocket;
- inputSocket.bind(senf::INet4SocketAddress("localhost:44344"));
+ inputSocket.bind(senf::INet4SocketAddress(localhost4str(0)));
inputSocket.blocking(false);
module::ActiveSocketSource<> udpSource(inputSocket);
debug::PassiveSink sink;
std::string data ("TEST");
senf::UDPv4ClientSocketHandle outputSocket;
- outputSocket.writeto(senf::INet4SocketAddress("localhost:44344"),data);
+ outputSocket.writeto(senf::INet4SocketAddress(localhost4str(0)),data);
senf::scheduler::TimerEvent timer (
"socketSource test timer", &timeout,
senf::ClockService::now() + senf::ClockService::milliseconds(100));