Commit 20e10665 authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

[unet-multicast]: added setup test

parent 3216cd88
...@@ -55,21 +55,21 @@ std::unique_ptr<MulticastReceiveTransport> MulticastReceiveTransport::createFrom ...@@ -55,21 +55,21 @@ std::unique_ptr<MulticastReceiveTransport> MulticastReceiveTransport::createFrom
} }
ostringstream fieldPort; ostringstream fieldPort;
fieldPort << "unet_port"; fieldPort << "unet_multicast_port";
if( numChan > 0 ) if( numChan > 0 )
fieldPort << numChan; fieldPort << numChan;
int p = it.getPIntProp(fieldPort.str(), it.getIntProp("id")); int p = it.getPIntProp(fieldPort.str(), it.getIntProp("id"));
if( it.find("multicast") ) if( !it.find("multicast") )
throw SystemError("(MulticastReceiveTransport): not found <multicast> node"); throw SystemError("(MulticastReceiveTransport): not found <multicast> node");
if( !it.goChildren() ) if( !it.goChildren() )
throw SystemError("(MulticastReceiveTransport): empty <multicast> node"); throw SystemError("(MulticastReceiveTransport): empty <multicast> node");
if( it.find("receive") ) if( !it.find("receive") )
throw SystemError("(MulticastReceiveTransport): not found <receive> node"); throw SystemError("(MulticastReceiveTransport): not found <receive> in <multicast>");
if( !it.goChildren() ) if( !it.goChildren() )
throw SystemError("(MulticastReceiveTransport): empty <receive> groups"); throw SystemError("(MulticastReceiveTransport): empty <receive> groups");
...@@ -230,20 +230,20 @@ std::unique_ptr<MulticastSendTransport> MulticastSendTransport::createFromXml( U ...@@ -230,20 +230,20 @@ std::unique_ptr<MulticastSendTransport> MulticastSendTransport::createFromXml( U
} }
ostringstream fieldPort; ostringstream fieldPort;
fieldPort << "unet_port"; fieldPort << "unet_multicast_port";
if( numChan > 0 ) if( numChan > 0 )
fieldPort << numChan; fieldPort << numChan;
int p = it.getPIntProp(fieldPort.str(), it.getIntProp("id")); int p = it.getPIntProp(fieldPort.str(), it.getIntProp("id"));
if( it.find("multicast") ) if( !it.find("multicast") )
throw SystemError("(MulticastSendTransport): not found <multicast> node"); throw SystemError("(MulticastSendTransport): not found <multicast> node");
if( !it.goChildren() ) if( !it.goChildren() )
throw SystemError("(MulticastSendTransport): empty <multicast> node"); throw SystemError("(MulticastSendTransport): empty <multicast> node");
if( it.find("send") ) if( !it.find("send") )
throw SystemError("(MulticastSendTransport): not found <send> node"); throw SystemError("(MulticastSendTransport): not found <send> node");
if( !it.goChildren() ) if( !it.goChildren() )
......
...@@ -2,7 +2,7 @@ if HAVE_TESTS ...@@ -2,7 +2,7 @@ if HAVE_TESTS
noinst_PROGRAMS = tests-with-sm urecv-perf-test noinst_PROGRAMS = tests-with-sm urecv-perf-test
tests_with_sm_SOURCES = tests_with_sm.cc test_unetudp.cc tests_with_sm_SOURCES = tests_with_sm.cc test_unetudp.cc test_unetmulticast.cc
tests_with_sm_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la \ tests_with_sm_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la \
$(top_builddir)/extensions/UNetUDP/libUniSet2UNetUDP.la \ $(top_builddir)/extensions/UNetUDP/libUniSet2UNetUDP.la \
$(top_builddir)/extensions/SharedMemory/libUniSet2SharedMemory.la \ $(top_builddir)/extensions/SharedMemory/libUniSet2SharedMemory.la \
......
#include <catch.hpp>
// -----------------------------------------------------------------------------
#include <memory>
#include "UniSetTypes.h"
#include "UInterface.h"
#include "UDPPacket.h"
#include "UDPCore.h"
#include "MulticastTransport.h"
// -----------------------------------------------------------------------------
using namespace std;
using namespace uniset;
// -----------------------------------------------------------------------------
static int port = 3000;
static const std::string host("127.255.255.255");
// -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: multicast setup", "[unetudp][multicast][config]")
{
UniXML xml("unetudp-test-configure.xml");
UniXML::iterator it = xml.findNode(xml.getFirstNode(), "nodes");
REQUIRE( it.getCurrent() );
REQUIRE( it.goChildren() );
REQUIRE( it.findName("item", "localhost", false) );
REQUIRE( it.getName() == "item" );
REQUIRE( it.getProp("name") == "localhost" );
REQUIRE_NOTHROW( MulticastReceiveTransport::createFromXml(it, "192.168.0.1", 0 ) );
REQUIRE_NOTHROW( MulticastReceiveTransport::createFromXml(it, "192.168.1.1", 2 ) );
REQUIRE_NOTHROW( MulticastSendTransport::createFromXml(it, "192.168.0.1", 0 ) );
REQUIRE_NOTHROW( MulticastSendTransport::createFromXml(it, "192.168.1.1", 2 ) );
auto t1 = MulticastReceiveTransport::createFromXml(it, "192.168.1.1", 2 );
REQUIRE( t1->toString() == "127.0.1.1:2999" );
auto t2 = MulticastSendTransport::createFromXml(it, "192.168.1.1", 2 );
REQUIRE( t2->toString() == "127.0.1.1:2999" );
}
// -----------------------------------------------------------------------------
...@@ -32,8 +32,17 @@ ...@@ -32,8 +32,17 @@
</settings> </settings>
<ObjectsMap idfromfile="1"> <ObjectsMap idfromfile="1">
<nodes port="2809" unet_broadcast_ip="127.255.255.255" unet_broadcast_ip2="badip"> <nodes port="2809" unet_broadcast_ip="127.255.255.255" unet_broadcast_ip2="badip" unet_multicast_ip="127.0.0.1">
<item id="3000" ip="127.0.0.1" name="localhost" textname="Локальный узел" unet_ignore="0" unet_port="3000"/> <item id="3000" ip="127.0.0.1" name="localhost" textname="Локальный узел" unet_ignore="0" unet_port="3000" unet_multicast_ip2="127.0.1.1" unet_multicast_port2="2999">
<multicast>
<receive>
<group addr="224.0.0.1" addr2="224.0.1.1"/>
</receive>
<send>
<group addr="224.0.0.1" addr2="224.0.1.1"/>
</send>
</multicast>
</item>
<item id="3001" ip="127.0.0.1" name="localhost1" textname="Локальный узел" unet_ignore="1" unet_port="3001"/> <item id="3001" ip="127.0.0.1" name="localhost1" textname="Локальный узел" unet_ignore="1" unet_port="3001"/>
<item id="3002" ip="192.168.56.10" name="Node1" textname="Node1" unet_ignore="0" unet_respond_id="Node1_Not_Respond_S" unet_respond_invert="1" unet_channelswitchcount_id="Node1_ChannelSwitchCount_AS"/> <item id="3002" ip="192.168.56.10" name="Node1" textname="Node1" unet_ignore="0" unet_respond_id="Node1_Not_Respond_S" unet_respond_invert="1" unet_channelswitchcount_id="Node1_ChannelSwitchCount_AS"/>
<item id="3003" ip="192.168.56.11" name="Node2" textname="Node2" unet_ignore="0" unet_respond_id="Node2_Respond_S" unet_lostpackets_id="Node2_LostPackets_AS" unet_numchannel_id="Node2_NumChannel_AS"/> <item id="3003" ip="192.168.56.11" name="Node2" textname="Node2" unet_ignore="0" unet_respond_id="Node2_Respond_S" unet_lostpackets_id="Node2_LostPackets_AS" unet_numchannel_id="Node2_NumChannel_AS"/>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment