Commit cbe40d7e authored by Pavel Vainerman's avatar Pavel Vainerman Committed by Pavel Vainerman

[unet-multicast]: added simple tests, added "unet-multicast-tester"

parent 564b179b
bin_PROGRAMS = @PACKAGE@-unetexchange @PACKAGE@-unet-udp-tester bin_PROGRAMS = @PACKAGE@-unetexchange @PACKAGE@-unet-udp-tester @PACKAGE@-unet-multicast-tester
# не забывайте править версию в2.pc-файле # не забывайте править версию в2.pc-файле
UNETUDP_VER=@LIBVER@ UNETUDP_VER=@LIBVER@
...@@ -24,6 +24,10 @@ libUniSet2UNetUDP_la_SOURCES = UDPPacket.cc UDPTransport.cc MulticastTransport. ...@@ -24,6 +24,10 @@ libUniSet2UNetUDP_la_SOURCES = UDPPacket.cc UDPTransport.cc MulticastTransport.
@PACKAGE@_unet_udp_tester_LDADD = $(top_builddir)/lib/libUniSet2.la $(POCO_LIBS) @PACKAGE@_unet_udp_tester_LDADD = $(top_builddir)/lib/libUniSet2.la $(POCO_LIBS)
@PACKAGE@_unet_udp_tester_CXXFLAGS = $(POCO_CFLAGS) @PACKAGE@_unet_udp_tester_CXXFLAGS = $(POCO_CFLAGS)
@PACKAGE@_unet_multicast_tester_SOURCES = UDPPacket.cc MulticastTransport.cc unet-multicast-tester.cc
@PACKAGE@_unet_multicast_tester_LDADD = $(top_builddir)/lib/libUniSet2.la $(POCO_LIBS)
@PACKAGE@_unet_multicast_tester_CXXFLAGS = $(POCO_CFLAGS)
# install # install
devel_include_HEADERS = *.h devel_include_HEADERS = *.h
devel_includedir = $(pkgincludedir)/extensions devel_includedir = $(pkgincludedir)/extensions
......
...@@ -25,11 +25,30 @@ ...@@ -25,11 +25,30 @@
using namespace std; using namespace std;
using namespace uniset; using namespace uniset;
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
xmlNode* MulticastReceiveTransport::getReceiveListNode( UniXML::iterator root )
{
UniXML::iterator it = root;
if( !it.find("multicast") )
return nullptr;
if( !it.goChildren() )
return nullptr;
if( !it.find("receive") )
return nullptr;
if( !it.goChildren() )
return nullptr;
return it.getCurrent();
}
// -------------------------------------------------------------------------
/* /*
* <item id="3000" unet_port="2048" unet_multicast_ip="192.168.0.255" unet_port2="2048" unet_multicast_ip2="192.169.0.255"> * <item id="3000" unet_port="2048" unet_multicast_ip="192.168.0.255" unet_port2="2048" unet_multicast_ip2="192.169.0.255">
<multicast> <multicast>
<receive> <receive>
1<group addr="224.0.0.1" addr2="224.0.0.1"/> <group addr="224.0.0.1" addr2="224.0.0.1"/>
</receive> </receive>
<send> <send>
<group addr="224.0.0.1"/> <group addr="224.0.0.1"/>
...@@ -37,7 +56,7 @@ using namespace uniset; ...@@ -37,7 +56,7 @@ using namespace uniset;
</multicast> </multicast>
</item> </item>
*/ */
std::unique_ptr<MulticastReceiveTransport> MulticastReceiveTransport::createFromXml( UniXML::iterator it, const std::string& defaultIP, int numChan ) std::unique_ptr<MulticastReceiveTransport> MulticastReceiveTransport::createFromXml( UniXML::iterator it, const std::string& defaultIP, int numChan, const std::string& section )
{ {
ostringstream fieldIp; ostringstream fieldIp;
fieldIp << "unet_multicast_ip"; fieldIp << "unet_multicast_ip";
...@@ -68,11 +87,11 @@ std::unique_ptr<MulticastReceiveTransport> MulticastReceiveTransport::createFrom ...@@ -68,11 +87,11 @@ std::unique_ptr<MulticastReceiveTransport> MulticastReceiveTransport::createFrom
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(section) )
throw SystemError("(MulticastReceiveTransport): not found <receive> in <multicast>"); throw SystemError("(MulticastReceiveTransport): not found <" + section + "> in <multicast>");
if( !it.goChildren() ) if( !it.goChildren() )
throw SystemError("(MulticastReceiveTransport): empty <receive> groups"); throw SystemError("(MulticastReceiveTransport): empty <" + section + "> groups");
std::vector<Poco::Net::IPAddress> groups; std::vector<Poco::Net::IPAddress> groups;
...@@ -199,12 +218,22 @@ ssize_t MulticastReceiveTransport::receive( void* r_buf, size_t sz ) ...@@ -199,12 +218,22 @@ ssize_t MulticastReceiveTransport::receive( void* r_buf, size_t sz )
return udp->receiveBytes(r_buf, sz); return udp->receiveBytes(r_buf, sz);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool MulticastReceiveTransport::isReadyForReceive( timeout_t tout )
{
return udp->poll(UniSetTimer::millisecToPoco(tout), Poco::Net::Socket::SELECT_READ);
}
// -------------------------------------------------------------------------
std::vector<Poco::Net::IPAddress> MulticastReceiveTransport::getGroups()
{
return groups;
}
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
/* /*
* <item id="3000" unet_port="2048" unet_multicast_ip="192.168.0.255" unet_port2="2048" unet_multicast_ip2="192.169.0.255"> * <item id="3000" unet_port="2048" unet_multicast_ip="192.168.0.255" unet_port2="2048" unet_multicast_ip2="192.169.0.255">
<multicast> <multicast>
<receive> <receive>
1<group addr="224.0.0.1" addr2="224.0.0.1"/> <group addr="224.0.0.1" addr2="224.0.0.1"/>
</receive> </receive>
<send> <send>
<group addr="224.0.0.1"/> <group addr="224.0.0.1"/>
...@@ -366,3 +395,7 @@ ssize_t MulticastSendTransport::send( const void* buf, size_t sz ) ...@@ -366,3 +395,7 @@ ssize_t MulticastSendTransport::send( const void* buf, size_t sz )
return udp->sendTo(buf, sz, saddr); return udp->sendTo(buf, sz, saddr);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
std::vector<Poco::Net::IPAddress> MulticastSendTransport::getGroups()
{
return groups;
}
...@@ -31,7 +31,8 @@ namespace uniset ...@@ -31,7 +31,8 @@ namespace uniset
{ {
public: public:
static std::unique_ptr<MulticastReceiveTransport> createFromXml( UniXML::iterator it, const std::string& defaultIP, int numChan ); static std::unique_ptr<MulticastReceiveTransport> createFromXml(UniXML::iterator it, const std::string& defaultIP, int numChan, const std::string& section = "receive");
static xmlNode* getReceiveListNode( UniXML::iterator root );
MulticastReceiveTransport( const std::string& bind, int port, const std::vector<Poco::Net::IPAddress>& joinGroups ); MulticastReceiveTransport( const std::string& bind, int port, const std::vector<Poco::Net::IPAddress>& joinGroups );
virtual ~MulticastReceiveTransport(); virtual ~MulticastReceiveTransport();
...@@ -43,7 +44,9 @@ namespace uniset ...@@ -43,7 +44,9 @@ namespace uniset
virtual bool createConnection(bool throwEx, timeout_t readTimeout, bool noblock) override; virtual bool createConnection(bool throwEx, timeout_t readTimeout, bool noblock) override;
virtual void disconnect() override; virtual void disconnect() override;
virtual int getSocket() const override; virtual int getSocket() const override;
std::vector<Poco::Net::IPAddress> getGroups();
bool isReadyForReceive( timeout_t tout ) override;
virtual ssize_t receive(void* r_buf, size_t sz) override; virtual ssize_t receive(void* r_buf, size_t sz) override;
protected: protected:
...@@ -68,6 +71,7 @@ namespace uniset ...@@ -68,6 +71,7 @@ namespace uniset
virtual bool createConnection(bool throwEx, timeout_t sendTimeout) override; virtual bool createConnection(bool throwEx, timeout_t sendTimeout) override;
virtual int getSocket() const override; virtual int getSocket() const override;
std::vector<Poco::Net::IPAddress> getGroups();
// write // write
virtual bool isReadyForSend(timeout_t tout) override; virtual bool isReadyForSend(timeout_t tout) override;
......
...@@ -124,6 +124,11 @@ ssize_t UDPReceiveTransport::receive( void* r_buf, size_t sz ) ...@@ -124,6 +124,11 @@ ssize_t UDPReceiveTransport::receive( void* r_buf, size_t sz )
return udp->receiveBytes(r_buf, sz); return udp->receiveBytes(r_buf, sz);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
bool UDPReceiveTransport::isReadyForReceive( timeout_t tout )
{
return udp->poll(UniSetTimer::millisecToPoco(tout), Poco::Net::Socket::SELECT_READ);
}
// -------------------------------------------------------------------------
std::unique_ptr<UDPSendTransport> UDPSendTransport::createFromXml( UniXML::iterator it, const std::string& defaultIP, int numChan ) std::unique_ptr<UDPSendTransport> UDPSendTransport::createFromXml( UniXML::iterator it, const std::string& defaultIP, int numChan )
{ {
ostringstream fieldIp; ostringstream fieldIp;
......
...@@ -43,6 +43,7 @@ namespace uniset ...@@ -43,6 +43,7 @@ namespace uniset
virtual void disconnect() override; virtual void disconnect() override;
virtual int getSocket() const override; virtual int getSocket() const override;
virtual ssize_t receive( void* r_buf, size_t sz ) override; virtual ssize_t receive( void* r_buf, size_t sz ) override;
virtual bool isReadyForReceive(timeout_t tout) override;
protected: protected:
std::unique_ptr<UDPReceiveU> udp; std::unique_ptr<UDPReceiveU> udp;
......
...@@ -242,6 +242,9 @@ namespace uniset ...@@ -242,6 +242,9 @@ namespace uniset
void termSenders(); void termSenders();
void termReceivers(); void termReceivers();
void initMulticastTransport( UniXML::iterator nodes, const std::string& n_field, const std::string& n_fvalue, const std::string& prefix );
void initMulticastReceiverForNode( UniXML::iterator n_it, const std::string& default_ip1, const std::string& default_ip2, const std::string& section, const std::string& prefix);
void initUDPTransport(UniXML::iterator nodes, const std::string& n_field, const std::string& n_fvalue, const std::string& prefix);
void initIterators() noexcept; void initIterators() noexcept;
void startReceivers(); void startReceivers();
......
/*
* Copyright (c) 2021 Pavel Vainerman.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, version 2.1.
*
* 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
* Lesser General Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// -------------------------------------------------------------------------
#ifndef UNetTransport_H_
#define UNetTransport_H_
// -------------------------------------------------------------------------
#include <string>
#include "PassiveTimer.h" // for typedef timeout_t
// -------------------------------------------------------------------------
namespace uniset
{
// Интерфейс для работы получения данных по сети
class UNetReceiveTransport
{
public:
virtual ~UNetReceiveTransport() {}
virtual bool isConnected() const = 0;
virtual std::string toString() const = 0;
virtual std::string ID() const noexcept = 0;
virtual bool createConnection( bool throwEx, timeout_t recvTimeout, bool noblock ) = 0;
virtual int getSocket() const = 0;
virtual bool isReadyForReceive(timeout_t tout) = 0;
virtual ssize_t receive( void* r_buf, size_t sz ) = 0;
virtual void disconnect() = 0;
};
// Интерфейс для посылки данных в сеть
class UNetSendTransport
{
public:
virtual ~UNetSendTransport() {}
virtual bool isConnected() const = 0;
virtual std::string toString() const = 0;
virtual bool createConnection( bool throwEx, timeout_t sendTimeout ) = 0;
virtual int getSocket() const = 0;
// write
virtual bool isReadyForSend( timeout_t tout ) = 0;
virtual ssize_t send( const void* r_buf, size_t sz ) = 0;
};
} // end of uniset namespace
// -------------------------------------------------------------------------
#endif // UNetTransport_H_
// -------------------------------------------------------------------------
if HAVE_TESTS if HAVE_TESTS
noinst_PROGRAMS = tests-with-sm urecv-perf-test noinst_PROGRAMS = tests-with-sm tests-multicast-with-sm urecv-perf-test
tests_with_sm_SOURCES = tests_with_sm.cc test_unetudp.cc test_unetmulticast.cc tests_with_sm_SOURCES = tests_with_sm.cc test_unetudp.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 \
$(SIGC_LIBS) $(POCO_LIBS) $(SIGC_LIBS) $(POCO_LIBS)
tests_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include \ tests_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/UNetUDP \ -I$(top_builddir)/extensions/UNetUDP \
-I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(POCO_CFLAGS) -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(POCO_CFLAGS)
tests_multicast_with_sm_SOURCES = tests_multicast_with_sm.cc test_unetmulticast.cc test_unetudp_multicast.cc
tests_multicast_with_sm_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la \
$(top_builddir)/extensions/UNetUDP/libUniSet2UNetUDP.la \
$(top_builddir)/extensions/SharedMemory/libUniSet2SharedMemory.la \
$(SIGC_LIBS) $(POCO_LIBS)
tests_multicast_with_sm_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/UNetUDP \
-I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(POCO_CFLAGS)
urecv_perf_test_SOURCES = urecv_perf_test.cc urecv_perf_test_SOURCES = urecv_perf_test.cc
urecv_perf_test_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la \ urecv_perf_test_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/extensions/lib/libUniSet2Extensions.la \
...@@ -18,7 +27,7 @@ urecv_perf_test_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/ex ...@@ -18,7 +27,7 @@ urecv_perf_test_LDADD = $(top_builddir)/lib/libUniSet2.la $(top_builddir)/ex
$(SIGC_LIBS) $(POCO_LIBS) $(SIGC_LIBS) $(POCO_LIBS)
urecv_perf_test_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include \ urecv_perf_test_CPPFLAGS = -I$(top_builddir)/include -I$(top_builddir)/extensions/include \
-I$(top_builddir)/extensions/UNetUDP \ -I$(top_builddir)/extensions/UNetUDP \
-I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(POCO_CFLAGS) -I$(top_builddir)/extensions/SharedMemory $(SIGC_CFLAGS) $(POCO_CFLAGS)
include $(top_builddir)/testsuite/testsuite-common.mk include $(top_builddir)/testsuite/testsuite-common.mk
......
...@@ -98,7 +98,7 @@ void send( UniSetUDP::UDPMessage& pack, int tout = 2000 ) ...@@ -98,7 +98,7 @@ void send( UniSetUDP::UDPMessage& pack, int tout = 2000 )
REQUIRE( ret == s_buf.len ); REQUIRE( ret == s_buf.len );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: queue sort", "[unetudp][packetqueue]") TEST_CASE("[UNetUDP]: queue sort", "[unetudp][udp][packetqueue]")
{ {
UNetReceiver::PacketQueue q; UNetReceiver::PacketQueue q;
...@@ -136,7 +136,7 @@ TEST_CASE("[UNetUDP]: queue sort", "[unetudp][packetqueue]") ...@@ -136,7 +136,7 @@ TEST_CASE("[UNetUDP]: queue sort", "[unetudp][packetqueue]")
q.pop(); q.pop();
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: UDPMessage", "[unetudp][udpmessage]") TEST_CASE("[UNetUDP]: UDPMessage", "[unetudp][udp][udpmessage]")
{ {
SECTION("UDPMessage::isFull()") SECTION("UDPMessage::isFull()")
{ {
...@@ -184,7 +184,7 @@ TEST_CASE("[UNetUDP]: UDPMessage", "[unetudp][udpmessage]") ...@@ -184,7 +184,7 @@ TEST_CASE("[UNetUDP]: UDPMessage", "[unetudp][udpmessage]")
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: sizeOf", "[unetudp][sizeof]") TEST_CASE("[UNetUDP]: sizeOf", "[unetudp][udp][sizeof]")
{ {
UniSetUDP::UDPMessage m; UniSetUDP::UDPMessage m;
...@@ -200,7 +200,7 @@ TEST_CASE("[UNetUDP]: sizeOf", "[unetudp][sizeof]") ...@@ -200,7 +200,7 @@ TEST_CASE("[UNetUDP]: sizeOf", "[unetudp][sizeof]")
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
#if 0 #if 0
TEST_CASE("[UNetUDP]: respond sensor", "[unetudp]") TEST_CASE("[UNetUDP]: respond sensor", "[unetudp][udp]")
{ {
InitTest(); InitTest();
...@@ -214,7 +214,7 @@ TEST_CASE("[UNetUDP]: respond sensor", "[unetudp]") ...@@ -214,7 +214,7 @@ TEST_CASE("[UNetUDP]: respond sensor", "[unetudp]")
} }
#endif #endif
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: check sender", "[unetudp][sender]") TEST_CASE("[UNetUDP]: check sender", "[unetudp][udp][sender]")
{ {
InitTest(); InitTest();
...@@ -285,7 +285,7 @@ TEST_CASE("[UNetUDP]: check sender", "[unetudp][sender]") ...@@ -285,7 +285,7 @@ TEST_CASE("[UNetUDP]: check sender", "[unetudp][sender]")
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: check receiver", "[unetudp][receiver]") TEST_CASE("[UNetUDP]: check receiver", "[unetudp][udp][receiver]")
{ {
InitTest(); InitTest();
...@@ -335,7 +335,7 @@ TEST_CASE("[UNetUDP]: check receiver", "[unetudp][receiver]") ...@@ -335,7 +335,7 @@ TEST_CASE("[UNetUDP]: check receiver", "[unetudp][receiver]")
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: check packets 'hole'", "[unetudp][udphole]") TEST_CASE("[UNetUDP]: check packets 'hole'", "[unetudp][udp][udphole]")
{ {
InitTest(); InitTest();
...@@ -386,7 +386,7 @@ TEST_CASE("[UNetUDP]: check packets 'hole'", "[unetudp][udphole]") ...@@ -386,7 +386,7 @@ TEST_CASE("[UNetUDP]: check packets 'hole'", "[unetudp][udphole]")
} }
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: check packets 'MaxDifferens'", "[unetudp][maxdifferens]") TEST_CASE("[UNetUDP]: check packets 'MaxDifferens'", "[unetudp][udp][maxdifferens]")
{ {
InitTest(); InitTest();
...@@ -414,7 +414,7 @@ TEST_CASE("[UNetUDP]: check packets 'MaxDifferens'", "[unetudp][maxdifferens]") ...@@ -414,7 +414,7 @@ TEST_CASE("[UNetUDP]: check packets 'MaxDifferens'", "[unetudp][maxdifferens]")
REQUIRE( ui->getValue(node2_lostpackets_as) > nlost ); REQUIRE( ui->getValue(node2_lostpackets_as) > nlost );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: bad packet number", "[unetudp][badnumber]") TEST_CASE("[UNetUDP]: bad packet number", "[unetudp][udp][badnumber]")
{ {
InitTest(); InitTest();
...@@ -455,7 +455,7 @@ TEST_CASE("[UNetUDP]: bad packet number", "[unetudp][badnumber]") ...@@ -455,7 +455,7 @@ TEST_CASE("[UNetUDP]: bad packet number", "[unetudp][badnumber]")
REQUIRE( ui->getValue(8) == 160 ); REQUIRE( ui->getValue(8) == 160 );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: switching channels", "[unetudp][chswitch]") TEST_CASE("[UNetUDP]: switching channels", "[unetudp][udp][chswitch]")
{ {
InitTest(); InitTest();
UniSetUDP::UDPMessage pack; UniSetUDP::UDPMessage pack;
...@@ -479,7 +479,7 @@ TEST_CASE("[UNetUDP]: switching channels", "[unetudp][chswitch]") ...@@ -479,7 +479,7 @@ TEST_CASE("[UNetUDP]: switching channels", "[unetudp][chswitch]")
REQUIRE( ui->getValue(node1_channelSwitchCount_as) == 0 ); REQUIRE( ui->getValue(node1_channelSwitchCount_as) == 0 );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
TEST_CASE("[UNetUDP]: check undefined value", "[unetudp][sender]") TEST_CASE("[UNetUDP]: check undefined value", "[unetudp][udp][sender]")
{ {
InitTest(); InitTest();
......
#define CATCH_CONFIG_RUNNER
#include <catch.hpp>
#include <string>
#include "Debug.h"
#include "UniSetActivator.h"
#include "PassiveTimer.h"
#include "SharedMemory.h"
#include "Extensions.h"
#include "UNetExchange.h"
// --------------------------------------------------------------------------
using namespace std;
using namespace uniset;
using namespace uniset::extensions;
// --------------------------------------------------------------------------
int main(int argc, const char* argv[] )
{
try
{
Catch::Session session;
if( argc > 1 && ( strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0 ) )
{
cout << "--confile - Использовать указанный конф. файл. По умолчанию configure.xml" << endl;
SharedMemory::help_print(argc, argv);
cout << endl << endl << "--------------- CATCH HELP --------------" << endl;
session.showHelp("test_multicast_with_sm");
return 0;
}
int returnCode = session.applyCommandLine( argc, argv, Catch::Session::OnUnusedOptions::Ignore );
if( returnCode != 0 ) // Indicates a command line error
return returnCode;
auto conf = uniset_init(argc, argv);
bool apart = findArgParam("--apart", argc, argv) != -1;
auto shm = SharedMemory::init_smemory(argc, argv);
if( !shm )
return 1;
auto unet = UNetExchange::init_unetexchange(argc, argv, shm->getId(), (apart ? nullptr : shm ), "unet");
if( !unet )
return 1;
auto act = UniSetActivator::Instance();
act->add(shm);
act->add(unet);
SystemMessage sm(SystemMessage::StartUp);
act->broadcast( sm.transport_msg() );
act->run(true);
int tout = 6000;
PassiveTimer pt(tout);
while( !pt.checkTime() && !act->exist() )
msleep(100);
if( !act->exist() )
{
cerr << "(tests_multicast_with_sm): SharedMemory not exist! (timeout=" << tout << ")" << endl;
return 1;
}
return session.run();
}
catch( const SystemError& err )
{
cerr << "(tests_multicast_with_sm): " << err << endl;
}
catch( const uniset::Exception& ex )
{
cerr << "(tests_multicast_with_sm): " << ex << endl;
}
catch( const std::exception& e )
{
cerr << "(tests_multicast_with_sm): " << e.what() << endl;
}
catch(...)
{
cerr << "(tests_multicast_with_sm): catch(...)" << endl;
}
return 1;
}
#!/bin/sh
# '--' - нужен для отделения аргументов catch, от наших..
cd ../../../Utilities/Admin/
./uniset2-start.sh -f ./create_links.sh
./uniset2-start.sh -f ./create
./uniset2-start.sh -f ./exist | grep -q UNISET_PLC/Controllers || exit 1
cd -
./uniset2-start.sh -f ./tests-multicast-with-sm $* -- --unet-transport multicast --confile unetudp-test-configure.xml --e-startup-pause 10 \
--unet-name UNetExchange --unet-filter-field unet --unet-filter-value 1 --unet-maxdifferense 5 \
--unet-recv-timeout 1000 --unet-sendpause 500 --unet-update-strategy evloop
#--unet-log-add-levels any
...@@ -33,19 +33,40 @@ ...@@ -33,19 +33,40 @@
<ObjectsMap idfromfile="1"> <ObjectsMap idfromfile="1">
<nodes port="2809" unet_broadcast_ip="127.255.255.255" unet_broadcast_ip2="badip" unet_multicast_ip="127.0.0.1"> <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" unet_multicast_ip2="127.0.1.1" unet_multicast_port2="2999"> <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" unet_multicast_receive_from_all_nodes="1">
<multicast> <multicast>
<receive> <receive>
<group addr="239.255.1.1" addr2="239.255.2.1"/> <group addr="238.255.1.2" addr2="239.255.1.2"/>
</receive> <group addr="238.255.1.3" addr2="239.255.1.3"/>
<send> </receive>
<group addr="239.255.1.1" addr2="239.255.2.1"/> <send>
</send> <group addr="238.255.1.1" addr2="239.255.1.1"/>
</multicast> </send>
</multicast>
</item> </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" unet_multicast_receive_from_all_nodes="1">
<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"/> <multicast>
<receive>
<group addr="238.255.1.1" addr2="239.255.1.1"/>
<group addr="238.255.1.3" addr2="239.255.1.3"/>
</receive>
<send>
<group addr="238.255.1.2" addr2="239.255.1.2"/>
</send>
</multicast>
</item>
<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" unet_multicast_receive_from_all_nodes="1">
<multicast>
<receive>
<group addr="238.255.1.1" addr2="239.255.1.1"/>
<group addr="238.255.1.2" addr2="239.255.1.2"/>
</receive>
<send>
<group addr="238.255.1.3" addr2="239.255.1.3"/>
</send>
</multicast>
</item>
</nodes> </nodes>
<!-- ************************ Датчики ********************** --> <!-- ************************ Датчики ********************** -->
<sensors name="Sensors"> <sensors name="Sensors">
......
...@@ -6,6 +6,12 @@ AT_SETUP([UNetUDP tests (with SM)(evloop)]) ...@@ -6,6 +6,12 @@ AT_SETUP([UNetUDP tests (with SM)(evloop)])
AT_CHECK([$abs_top_builddir/testsuite/at-test-launch.sh $abs_top_builddir/extensions/UNetUDP/tests tests_with_sm_evloop.sh],[0],[ignore],[ignore]) AT_CHECK([$abs_top_builddir/testsuite/at-test-launch.sh $abs_top_builddir/extensions/UNetUDP/tests tests_with_sm_evloop.sh],[0],[ignore],[ignore])
AT_CLEANUP AT_CLEANUP
AT_SETUP([UNetUDP multicast tests (with SM)(evloop)])
AT_CHECK([$abs_top_builddir/testsuite/at-test-launch.sh $abs_top_builddir/extensions/UNetUDP/tests tests_multicast_with_sm_evloop.sh],[0],[ignore],[ignore])
AT_CLEANUP
# AT_SETUP([UNetUDP tests (separately)]) # AT_SETUP([UNetUDP tests (separately)])
# AT_CHECK([$abs_top_builddir/testsuite/at-test-launch.sh $abs_top_builddir/extensions/UNetUDP/tests tests_with_sm_apart.sh],[0],[ignore],[ignore]) # AT_CHECK([$abs_top_builddir/testsuite/at-test-launch.sh $abs_top_builddir/extensions/UNetUDP/tests tests_with_sm_apart.sh],[0],[ignore],[ignore])
# AT_CLEANUP # AT_CLEANUP
...@@ -270,12 +270,17 @@ ...@@ -270,12 +270,17 @@
./extensions/tests/test_ui.cc ./extensions/tests/test_ui.cc
./extensions/tests/test_vtypes.cc ./extensions/tests/test_vtypes.cc
./extensions/UNetUDP/Makefile.am ./extensions/UNetUDP/Makefile.am
./extensions/UNetUDP/MulticastTransport.cc
./extensions/UNetUDP/MulticastTransport.h
./extensions/UNetUDP/tests/a.cc ./extensions/UNetUDP/tests/a.cc
./extensions/UNetUDP/tests/Makefile.am ./extensions/UNetUDP/tests/Makefile.am
./extensions/UNetUDP/tests/tests_individual_process.cc ./extensions/UNetUDP/tests/tests_individual_process.cc
./extensions/UNetUDP/tests/tests_multicast_with_sm.cc
./extensions/UNetUDP/tests/tests_with_sm.cc ./extensions/UNetUDP/tests/tests_with_sm.cc
./extensions/UNetUDP/tests/test_unetmulticast.cc
./extensions/UNetUDP/tests/test_unetudp1.cc ./extensions/UNetUDP/tests/test_unetudp1.cc
./extensions/UNetUDP/tests/test_unetudp.cc ./extensions/UNetUDP/tests/test_unetudp.cc
./extensions/UNetUDP/tests/test_unetudp_multicast.cc
./extensions/UNetUDP/tests/u.cc ./extensions/UNetUDP/tests/u.cc
./extensions/UNetUDP/tests/urecv_perf_test.cc ./extensions/UNetUDP/tests/urecv_perf_test.cc
./extensions/UNetUDP/UDPPacket.cc ./extensions/UNetUDP/UDPPacket.cc
...@@ -286,6 +291,7 @@ ...@@ -286,6 +291,7 @@
./extensions/UNetUDP/UNetExchange.cc ./extensions/UNetUDP/UNetExchange.cc
./extensions/UNetUDP/UNetExchange.h ./extensions/UNetUDP/UNetExchange.h
./extensions/UNetUDP/UNetLogSugar.h ./extensions/UNetUDP/UNetLogSugar.h
./extensions/UNetUDP/unet-multicast-tester.cc
./extensions/UNetUDP/UNetReceiver.cc ./extensions/UNetUDP/UNetReceiver.cc
./extensions/UNetUDP/UNetReceiver.h ./extensions/UNetUDP/UNetReceiver.h
./extensions/UNetUDP/UNetSender.cc ./extensions/UNetUDP/UNetSender.cc
......
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