Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
20e10665
Commit
20e10665
authored
May 17, 2021
by
Pavel Vainerman
Committed by
Pavel Vainerman
Jun 30, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[unet-multicast]: added setup test
parent
3216cd88
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
58 additions
and
10 deletions
+58
-10
MulticastTransport.cc
extensions/UNetUDP/MulticastTransport.cc
+7
-7
Makefile.am
extensions/UNetUDP/tests/Makefile.am
+1
-1
test_unetmulticast.cc
extensions/UNetUDP/tests/test_unetmulticast.cc
+39
-0
unetudp-test-configure.xml
extensions/UNetUDP/tests/unetudp-test-configure.xml
+11
-2
No files found.
extensions/UNetUDP/MulticastTransport.cc
View file @
20e10665
...
...
@@ -55,21 +55,21 @@ std::unique_ptr<MulticastReceiveTransport> MulticastReceiveTransport::createFrom
}
ostringstream
fieldPort
;
fieldPort
<<
"unet_port"
;
fieldPort
<<
"unet_
multicast_
port"
;
if
(
numChan
>
0
)
fieldPort
<<
numChan
;
int
p
=
it
.
getPIntProp
(
fieldPort
.
str
(),
it
.
getIntProp
(
"id"
));
if
(
it
.
find
(
"multicast"
)
)
if
(
!
it
.
find
(
"multicast"
)
)
throw
SystemError
(
"(MulticastReceiveTransport): not found <multicast> node"
);
if
(
!
it
.
goChildren
()
)
throw
SystemError
(
"(MulticastReceiveTransport): empty <multicast> node"
);
if
(
it
.
find
(
"receive"
)
)
throw
SystemError
(
"(MulticastReceiveTransport): not found <receive>
node
"
);
if
(
!
it
.
find
(
"receive"
)
)
throw
SystemError
(
"(MulticastReceiveTransport): not found <receive>
in <multicast>
"
);
if
(
!
it
.
goChildren
()
)
throw
SystemError
(
"(MulticastReceiveTransport): empty <receive> groups"
);
...
...
@@ -230,20 +230,20 @@ std::unique_ptr<MulticastSendTransport> MulticastSendTransport::createFromXml( U
}
ostringstream
fieldPort
;
fieldPort
<<
"unet_port"
;
fieldPort
<<
"unet_
multicast_
port"
;
if
(
numChan
>
0
)
fieldPort
<<
numChan
;
int
p
=
it
.
getPIntProp
(
fieldPort
.
str
(),
it
.
getIntProp
(
"id"
));
if
(
it
.
find
(
"multicast"
)
)
if
(
!
it
.
find
(
"multicast"
)
)
throw
SystemError
(
"(MulticastSendTransport): not found <multicast> node"
);
if
(
!
it
.
goChildren
()
)
throw
SystemError
(
"(MulticastSendTransport): empty <multicast> node"
);
if
(
it
.
find
(
"send"
)
)
if
(
!
it
.
find
(
"send"
)
)
throw
SystemError
(
"(MulticastSendTransport): not found <send> node"
);
if
(
!
it
.
goChildren
()
)
...
...
extensions/UNetUDP/tests/Makefile.am
View file @
20e10665
...
...
@@ -2,7 +2,7 @@ if HAVE_TESTS
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
\
$(top_builddir)
/extensions/UNetUDP/libUniSet2UNetUDP.la
\
$(top_builddir)
/extensions/SharedMemory/libUniSet2SharedMemory.la
\
...
...
extensions/UNetUDP/tests/test_unetmulticast.cc
0 → 100644
View file @
20e10665
#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"
);
}
// -----------------------------------------------------------------------------
extensions/UNetUDP/tests/unetudp-test-configure.xml
View file @
20e10665
...
...
@@ -32,8 +32,17 @@
</settings>
<ObjectsMap
idfromfile=
"1"
>
<nodes
port=
"2809"
unet_broadcast_ip=
"127.255.255.255"
unet_broadcast_ip2=
"badip"
>
<item
id=
"3000"
ip=
"127.0.0.1"
name=
"localhost"
textname=
"Локальный узел"
unet_ignore=
"0"
unet_port=
"3000"
/>
<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"
>
<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=
"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"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment