Commit 254e0852 authored by Pavel Vainerman's avatar Pavel Vainerman

(UNet): подправил тесты, исправил ошибку инициализации

parent 1bf3a239
......@@ -38,10 +38,11 @@ bool UNetReceiver::PacketCompare::operator()(const UniSetUDP::UDPMessage& lhs,
}
*/
// ------------------------------------------------------------------------------------------
UNetReceiver::UNetReceiver( const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection ):
UNetReceiver::UNetReceiver( const std::string& s_host, const ost::tpport_t _port, const std::shared_ptr<SMInterface>& smi, bool nocheckConnection ):
shm(smi),
recvpause(10),
updatepause(100),
port(_port),
recvTimeout(5000),
prepareTime(2000),
lostTimeout(200), /* 2*updatepause */
......
......@@ -25,14 +25,15 @@ using namespace std;
using namespace UniSetTypes;
using namespace UniSetExtensions;
// -----------------------------------------------------------------------------
UNetSender::UNetSender(const std::string& s_host, const ost::tpport_t port, const std::shared_ptr<SMInterface>& smi,
UNetSender::UNetSender(const std::string& _host, const ost::tpport_t _port, const std::shared_ptr<SMInterface>& smi,
bool nocheckConnection, const std::string& s_f, const std::string& s_val,
const std::string& s_prefix, size_t maxDCount, size_t maxACount ):
s_field(s_f),
s_fvalue(s_val),
prefix(s_prefix),
shm(smi),
s_host(s_host),
port(_port),
s_host(_host),
sendpause(150),
packsendpause(5),
activated(false),
......@@ -56,9 +57,6 @@ UNetSender::UNetSender(const std::string& s_host, const ost::tpport_t port, cons
auto conf = uniset_conf();
conf->initLogStream(unetlog, myname);
// определяем фильтр
// s_field = conf->getArgParam("--udp-filter-field");
// s_fvalue = conf->getArgParam("--udp-filter-value");
unetinfo << myname << "(init): read filter-field='" << s_field
<< "' filter-value='" << s_fvalue << "'" << endl;
......@@ -280,7 +278,7 @@ void UNetSender::send()
// -----------------------------------------------------------------------------
// #define UNETUDP_DISABLE_OPTIMIZATION_N1
void UNetSender::real_send(UniSetUDP::UDPMessage& mypack)
void UNetSender::real_send( UniSetUDP::UDPMessage& mypack )
{
UniSetTypes::uniset_rwmutex_rlock l(pack_mutex);
#ifdef UNETUDP_DISABLE_OPTIMIZATION_N1
......
......@@ -171,7 +171,7 @@ class UNetSender
private:
UNetSender();
std::shared_ptr<ost::UDPBroadcast> udp;
std::shared_ptr<ost::UDPBroadcast> udp = { nullptr };
ost::IPV4Address addr;
ost::tpport_t port = { 0 };
std::string s_host = { "" };
......
#include <catch.hpp>
// -----------------------------------------------------------------------------
#include <memory>
#include <cc++/socket.h>
#include "UniSetTypes.h"
#include "UInterface.h"
......@@ -15,10 +16,10 @@ using namespace UniSetTypes;
// -----------------------------------------------------------------------------
static int port = 3000;
static ost::IPV4Host host("127.255.255.255");
static UInterface* ui = nullptr;
static shared_ptr<UInterface> ui = nullptr;
static ObjectId aid = 2;
static ost::UDPDuplex* udp_r = nullptr;
static ost::UDPBroadcast* udp_s = nullptr;
static std::shared_ptr<UDPReceiveU> udp_r = nullptr;
static shared_ptr<ost::UDPBroadcast> udp_s = nullptr;
static int s_port = 3003; // Node2
static int s_nodeID = 3003;
static int s_procID = 123;
......@@ -36,7 +37,7 @@ void InitTest()
if( ui == nullptr )
{
ui = new UInterface();
ui = make_shared<UInterface>();
// UI понадобиться для проверки записанных в SM значений.
CHECK( ui->getObjectIndex() != nullptr );
CHECK( ui->getConf() == conf );
......@@ -44,10 +45,10 @@ void InitTest()
}
if( udp_r == nullptr )
udp_r = new ost::UDPDuplex(host, port);
udp_r = make_shared<UDPReceiveU>(host, port);
if( udp_s == nullptr )
udp_s = new ost::UDPBroadcast(host, s_port);
udp_s = make_shared<ost::UDPBroadcast>(host, s_port);
}
// -----------------------------------------------------------------------------
// pnum - минималный номер ожидаемого пакета ( 0 - любой пришедщий )
......
......@@ -11,3 +11,4 @@ cd -
./uniset2-start.sh -f ./tests-with-sm $* -- --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-log-add-levels any
......@@ -8,6 +8,7 @@
#include <cc++/socket.h>
#include "UDPPacket.h"
#include "PassiveTimer.h"
#include "UDPCore.h"
// --------------------------------------------------------------------------
static struct option longopts[] =
{
......@@ -201,7 +202,7 @@ int main(int argc, char* argv[])
{
case cmdReceive:
{
ost::UDPDuplex udp(host, port);
UDPReceiveU udp(host, port);
// char buf[UniSetUDP::MaxDataLen];
UniSetUDP::UDPMessage pack;
......
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