Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+54
@@ -0,0 +1,54 @@
|
||||
#
|
||||
# $Id$
|
||||
# $HeadURL$
|
||||
# $Author$
|
||||
#
|
||||
|
||||
SET(SRCS_DT_TEST
|
||||
srp_dt_tests.cpp
|
||||
)
|
||||
SET(HDRS_DT_TEST
|
||||
srp_dt_tests.h
|
||||
)
|
||||
|
||||
SET(SRCS_FT_TEST
|
||||
srp_ft_tests.cpp
|
||||
)
|
||||
SET(HDRS_FT_TEST
|
||||
srp_ft_tests.h
|
||||
)
|
||||
|
||||
IF(BUILD_TESTING)
|
||||
IF(TARGET svcSrpClient)
|
||||
|
||||
# Testing DataTopic Functionality (DTC)
|
||||
ADD_EXECUTABLE(srpDtTests ${SRCS_DT_TEST} ${HDRS_DT_TEST})
|
||||
TARGET_LINK_LIBRARIES(srpDtTests
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
RTI::nddscpp2
|
||||
svcSrpClient
|
||||
LtsCommandLineParser
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
)
|
||||
|
||||
# Testing FunctionTopic Functionality (FTC)
|
||||
ADD_EXECUTABLE(srpFtTests ${SRCS_FT_TEST} ${HDRS_FT_TEST})
|
||||
TARGET_LINK_LIBRARIES(srpFtTests
|
||||
Qt5::Core
|
||||
Qt5::Test
|
||||
RTI::nddscpp2
|
||||
svcSrpClient
|
||||
LtsCommandLineParser
|
||||
ddsconnector
|
||||
nglcoreapplication
|
||||
)
|
||||
IF(NOT BUILD_RPM)
|
||||
NGL_INSTALL(AAR SV TARGETS srpDtTests DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV TARGETS srpFtTests DESTINATION bin/test)
|
||||
NGL_INSTALL(AAR SV FILES ../log4cxx_srp.props DESTINATION bin/test)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SRP Data Topic test executable
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-11
|
||||
*/
|
||||
|
||||
#include "srp_dt_tests.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
|
||||
#include <SituationReplay/srp_dtc.h>
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
namespace SituationReplay
|
||||
{
|
||||
SrpDtTests::SrpDtTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_replayPartitionId(0)
|
||||
, m_situationReplayId(0)
|
||||
, m_bTestsSuccessful(true)
|
||||
, m_logger(getLogger("DtTest"))
|
||||
{
|
||||
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
SrpDtTests::~SrpDtTests()
|
||||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
bool SrpDtTests::init(int domainId, int replayPartitionId)
|
||||
{
|
||||
DEBUG_LOG(m_logger) << "init begin";
|
||||
m_replayPartitionId = replayPartitionId;
|
||||
|
||||
// initialize DDS
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Replay, replayPartitionId));
|
||||
if (!m_ddsConnector->init())
|
||||
return false;
|
||||
|
||||
// Subscribe on replayPartition - default = true in this DdsSubscriber
|
||||
|
||||
// DdsInterface Subscriber
|
||||
m_ddsConnector->initSubscriber();
|
||||
|
||||
// DdsInterface Publisher
|
||||
//m_ddsConnector->setPublisher(new Publisher(domainId, m_ddsConnector->getPartition(), m_ddsConnector->getDomainParticipant()));
|
||||
|
||||
DEBUG_LOG(m_logger) << "Create dtc";
|
||||
m_dtc = SituationReplay::Interface::Dtc::create(m_ddsConnector);
|
||||
DEBUG_LOG(m_logger) << "Init dtc";
|
||||
bool bRet = m_dtc->enableAll();
|
||||
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
||||
|
||||
connect(m_dtc.get(), &SituationReplay::Interface::Dtc::sitReplayChanged,
|
||||
this, &SrpDtTests::onReceiveSituationReplayData);
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void SrpDtTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest";
|
||||
QTimer::singleShot(1000, this, &SrpDtTests::tryGetAllSituationReplays);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void SrpDtTests::tryGetAllSituationReplays()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to get all situationReplays";
|
||||
const QMap<qint32, SituationReplay::SitReplay> map = m_dtc->sitReplays();
|
||||
if (map.isEmpty())
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error requesting all situation replay data";
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(m_logger) << "Amout of existing situation replays = " << map.size();
|
||||
m_situationReplayId = map.firstKey();
|
||||
for(auto it = map.begin(); it != map.end(); ++it)
|
||||
INFO_LOG(m_logger) << "situationReplay(" << it.key() << ") : " << it.value().replayPartitionId() ;
|
||||
}
|
||||
|
||||
QTimer::singleShot(10, this, &SrpDtTests::tryGetSituationReplay);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void SrpDtTests::tryGetSituationReplay()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying get itemData for situationReplay " << m_situationReplayId;
|
||||
SituationReplay::SitReplay data = m_dtc->sitReplay(m_situationReplayId);
|
||||
|
||||
if (data.id() <= 0)
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error receiving data for situation replay " << m_situationReplayId;
|
||||
failExit();
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(m_logger) << "## SitReplay(" << data.id() << "), replayPartition: " << data.replayPartitionId()
|
||||
<< ", on exercise " << data.exerciseId();
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
void SrpDtTests::onReceiveSituationReplayData(const SituationReplay::SitReplay &data)
|
||||
{
|
||||
if (m_situationReplayId == data.id())
|
||||
INFO_LOG(m_logger) << "##################### Data for id = " << data.id() << " received";
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
void SrpDtTests::failExit()
|
||||
{
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("p") << QLatin1String("replay-partition-id")
|
||||
, QLatin1String("ReplayPartitionId (required).")
|
||||
, QLatin1String("> 0")
|
||||
, QLatin1String("1")
|
||||
} );
|
||||
|
||||
addHelpOption();
|
||||
}
|
||||
|
||||
int replayPartitionId() const { return isSet(QLatin1String("p")) ? value(QLatin1String("p")).toInt() : -1; }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("SRP", "log4cxx_srp.props");
|
||||
|
||||
int iRet = -1;
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
if (options.replayPartitionId() <= 0)
|
||||
{
|
||||
ERROR_LOG(app.baseLogger()) << "Required parameter p: (replay) partitionId ";
|
||||
options.showHelp();
|
||||
return -2;
|
||||
}
|
||||
|
||||
std::unique_ptr<SituationReplay::SrpDtTests> srpDtTests(new SituationReplay::SrpDtTests);
|
||||
|
||||
if(!srpDtTests->init(options.domainId(), options.replayPartitionId()))
|
||||
return iRet;
|
||||
|
||||
QTimer::singleShot(0, srpDtTests.get(), &SituationReplay::SrpDtTests::startTest);
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
iRet = srpDtTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "%d\n", iRet);
|
||||
|
||||
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SRP Data Topic test executable
|
||||
*
|
||||
* ModuleTests to get data from Service SituationReplay
|
||||
* -> getAll()
|
||||
* -> getItem()
|
||||
* ---------------------------------------------------
|
||||
* Client DTC is implemented
|
||||
*
|
||||
* => (!) Preconditon:
|
||||
* - Service sExeMgmt running
|
||||
*
|
||||
* -------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Hanna E. Rathje, SLSE, 2015-09-11
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplay/srp_dtc.h>
|
||||
#include <SituationReplay/srp_dtc_types.h>
|
||||
#include <SituationReplay/logger.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/DDSConnector/publisher.h>
|
||||
#include <DDS/DDSConnector/subscriber.h>
|
||||
|
||||
//#include <Common/ProjectConfig/project_defines.h>
|
||||
|
||||
namespace SituationReplay
|
||||
{
|
||||
class SrpDtTests : public QObject
|
||||
{
|
||||
using Publisher = DDSConnector::Publisher;
|
||||
using Subscriber = DDSConnector::Subscriber;
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit SrpDtTests(QObject *parent = nullptr);
|
||||
~SrpDtTests();
|
||||
|
||||
bool init(int domainId, int exerciseId);
|
||||
bool testsSuccessful() const { return m_bTestsSuccessful; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void startTest();
|
||||
protected Q_SLOTS:
|
||||
void tryGetAllSituationReplays();
|
||||
void tryGetSituationReplay();
|
||||
void onReceiveSituationReplayData(const SitReplay &data);
|
||||
protected:
|
||||
void failExit();
|
||||
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<SituationReplay::Interface::Dtc> m_dtc;
|
||||
qint32 m_replayPartitionId;
|
||||
qint32 m_situationReplayId;
|
||||
bool m_bTestsSuccessful;
|
||||
LOGGER_T m_logger;
|
||||
|
||||
};
|
||||
|
||||
} // namespace SituationReplay
|
||||
+301
@@ -0,0 +1,301 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SRP Function Topic test executable
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-01-14
|
||||
*/
|
||||
|
||||
#include "srp_ft_tests.h"
|
||||
|
||||
#include <nglapplication/nglcoreapplication.h>
|
||||
#include <LtsCommandLineParser/LtsCommandLineParser.h>
|
||||
#include <QTimer>
|
||||
|
||||
#include <SituationReplay/srp_ftc.h>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
namespace SituationReplay
|
||||
{
|
||||
|
||||
SrpFtTests::SrpFtTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_replayPartitionId(0)
|
||||
, m_testId(All)
|
||||
, m_bTestsSuccessful(true)
|
||||
, m_logger(getLogger("FtTest"))
|
||||
{
|
||||
qRegisterMetaType<Core::FunctionReply>("Core::FunctionReply");
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
SrpFtTests::~SrpFtTests()
|
||||
{}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
bool SrpFtTests::init(int domainId, TestId testId, int replayPartitionId, int srpId)
|
||||
{
|
||||
INFO_LOG(m_logger) << "init begin";
|
||||
|
||||
m_testId = testId;
|
||||
m_replayPartitionId = replayPartitionId;
|
||||
|
||||
if (m_testId > 0)
|
||||
m_situationReplayId = srpId;
|
||||
|
||||
// initialize DDS
|
||||
m_ddsConnector.reset(new DDSConnector::DdsConnector(domainId, IDL::PartitionType::Replay, m_replayPartitionId));
|
||||
if (!m_ddsConnector->init())
|
||||
return false;
|
||||
|
||||
|
||||
// Publish/Subscribe on replayPartition
|
||||
m_ddsConnector->initPublisherSubscriber();
|
||||
|
||||
DEBUG_LOG(m_logger) << "create ftc";
|
||||
m_ftc = SituationReplay::Interface::Ftc::create(m_ddsConnector);
|
||||
DEBUG_LOG(m_logger) << "init ftc";
|
||||
bool bRet = m_ftc->enableAll();
|
||||
DEBUG_LOG(m_logger) << "init end - bRet = " << bRet;
|
||||
|
||||
return bRet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::startTest()
|
||||
{
|
||||
INFO_LOG(m_logger) << "startTest";
|
||||
|
||||
if (m_testId <= TryStart)
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryStart);
|
||||
else if (m_testId == TryNotAllowedChange)
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryNotAllowedChange);
|
||||
else if (m_testId == TryChangePaused)
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryChangePaused);
|
||||
else if (m_testId == TryChangeResumed)
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryChangeResumed);
|
||||
else if (m_testId == TryStop)
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryStop);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::tryStart()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send startReplay";
|
||||
m_currentTestId = TryStart;
|
||||
|
||||
qint64 beginTime = 1468401389668;
|
||||
qint64 endTime = 1468401659954;
|
||||
double pace = 2.0;
|
||||
|
||||
ChangeReplayStateRequest req;
|
||||
req.id(0);
|
||||
req.replayPartitionId(m_replayPartitionId);
|
||||
req.state(SrpState::Started);
|
||||
req.beginTime(beginTime);
|
||||
req.endTime(endTime); // infinite
|
||||
req.pace(pace);
|
||||
|
||||
if (!m_ftc->changeReplayStateRequest(req, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error starting replay for srp " << m_replayPartitionId;
|
||||
failExit();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::tryNotAllowedChange()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send changeReplayState (start) => should fail (not possible with this method)";
|
||||
m_currentTestId = TryNotAllowedChange;
|
||||
switchToState(SituationReplay::SrpState::Started);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::tryChangePaused()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send changeReplayState (Paused)";
|
||||
m_currentTestId = TryChangePaused;
|
||||
switchToState(SituationReplay::SrpState::Paused);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::tryChangeResumed()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send changeReplayState (Resumed)";
|
||||
m_currentTestId = TryChangeResumed;
|
||||
switchToState(SituationReplay::SrpState::Resumed);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::tryStop()
|
||||
{
|
||||
INFO_LOG(m_logger) << "trying to send stopReplay";
|
||||
m_currentTestId = TryStop;
|
||||
switchToState(SituationReplay::SrpState::Stopped);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::startReplayReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got startReplayReply with id " << replyObject.id();
|
||||
m_situationReplayId = replyObject.id();
|
||||
if (m_testId == 0 && !replyObject.error())
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryNotAllowedChange);
|
||||
else
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::changeReplayStateReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got changeReplayStateReply with id " << replyObject.id();
|
||||
if (replyObject.error())
|
||||
INFO_LOG(m_logger) << ", string: " << replyObject.translated();
|
||||
if (m_testId == 0 && !replyObject.error())
|
||||
{
|
||||
if (m_currentTestId == TryNotAllowedChange)
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryChangePaused);
|
||||
else if (m_currentTestId == TryChangePaused)
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryChangeResumed);
|
||||
else
|
||||
QTimer::singleShot(0, this, &SrpFtTests::tryStop);
|
||||
}
|
||||
else
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::stopReplayReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
INFO_LOG(m_logger) << "Got stopReplayReply with id " << replyObject.id() ;
|
||||
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::onChangeReplayStateReply(const Core::FunctionReplyObject &replyObject)
|
||||
{
|
||||
switch (m_currentTestId)
|
||||
{
|
||||
case TryStart:
|
||||
startReplayReply(replyObject);
|
||||
break;
|
||||
case TryNotAllowedChange:
|
||||
case TryChangePaused:
|
||||
case TryChangeResumed:
|
||||
changeReplayStateReply(replyObject);
|
||||
break;
|
||||
case TryStop:
|
||||
stopReplayReply(replyObject);
|
||||
break;
|
||||
case All:
|
||||
changeReplayStateReply(replyObject);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
void SrpFtTests::failExit()
|
||||
{
|
||||
m_bTestsSuccessful = false;
|
||||
QTimer::singleShot(0, qApp, &QCoreApplication::quit);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------
|
||||
void SrpFtTests::switchToState(SrpState state)
|
||||
{
|
||||
ChangeReplayStateRequest req;
|
||||
req.id(m_situationReplayId);
|
||||
req.replayPartitionId(m_replayPartitionId);
|
||||
req.state(state);
|
||||
|
||||
if (!m_ftc->changeReplayStateRequest(req, this))
|
||||
{
|
||||
ERROR_LOG(m_logger) << "Error changing replay state for srp " << m_situationReplayId << "(" << m_replayPartitionId << ")";
|
||||
failExit();
|
||||
}
|
||||
}
|
||||
} // end namespace
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
class CmdLineParser : public LtsCommandLineParser::LtsCommandLineParser
|
||||
{
|
||||
public:
|
||||
CmdLineParser()
|
||||
: LtsCommandLineParser()
|
||||
{
|
||||
addOption( { QStringList() << QLatin1String("t") << QLatin1String("testId")
|
||||
, QLatin1String("TestId.")
|
||||
, QLatin1String("Default: 0 (all tests)")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("p") << QLatin1String("replayPartitionId")
|
||||
, QLatin1String("ReplayPartitionId.")
|
||||
, QLatin1String("required")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
|
||||
addOption( { QStringList() << QLatin1String("r") << QLatin1String("situationReplayId")
|
||||
, QLatin1String("SituationReplayId.")
|
||||
, QLatin1String("optional")
|
||||
, QLatin1String("0")
|
||||
} );
|
||||
|
||||
addHelpOption();
|
||||
}
|
||||
|
||||
int testId() const { return isSet(QLatin1String("t")) ? value(QLatin1String("t")).toInt() : -1; }
|
||||
int replayPartitionId() const { return isSet(QLatin1String("p")) ? value(QLatin1String("p")).toInt() : -1; }
|
||||
int situationReplayId() const { return isSet(QLatin1String("r")) ? value(QLatin1String("r")).toInt() : -1; }
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
NGLCoreApplication app(argc, argv);
|
||||
app.createLogger("SRP", "log4cxx_srp.props");
|
||||
|
||||
CmdLineParser options;
|
||||
if (!options.init())
|
||||
return -1;
|
||||
|
||||
if (options.exerciseId() <= 0 || options.replayPartitionId() <= 0)
|
||||
{
|
||||
ERROR_LOG(app.baseLogger()) << "Required parameter: exerciseId & replayPartitionId ";
|
||||
options.showHelp();
|
||||
return -2;
|
||||
}
|
||||
|
||||
if (options.testId() > 0 && options.situationReplayId() <= 0)
|
||||
{
|
||||
ERROR_LOG(app.baseLogger()) << "Required parameter for single test: situationReplayId ";
|
||||
options.showHelp();
|
||||
return -2;
|
||||
}
|
||||
|
||||
std::unique_ptr<SituationReplay::SrpFtTests> SrpFtTests(new SituationReplay::SrpFtTests);
|
||||
|
||||
int iRet = -1;
|
||||
if(!SrpFtTests->init(options.domainId(), SituationReplay::SrpFtTests::TestId(options.testId()),
|
||||
options.replayPartitionId(), options.situationReplayId()))
|
||||
return iRet;
|
||||
|
||||
QTimer::singleShot(0, SrpFtTests.get(), &SituationReplay::SrpFtTests::startTest);
|
||||
|
||||
STARTUP_LOG(app.baseLogger());
|
||||
|
||||
app.exec();
|
||||
|
||||
iRet = SrpFtTests->testsSuccessful() ? 0 : 1;
|
||||
fprintf(stderr, "%d\n", iRet);
|
||||
|
||||
DEBUG_LOG(app.baseLogger()) << "** TEST result = " << iRet;
|
||||
|
||||
SHUTDOWN_LOG(app.baseLogger());
|
||||
|
||||
return iRet;
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* SRP Function Topic test executable
|
||||
*
|
||||
* ModuleTests for create/modify/remove exercise
|
||||
* ---------------------------------------------------
|
||||
* Client FTC is implemented
|
||||
*
|
||||
* => (!) Preconditon:
|
||||
* - Service sSrp running
|
||||
*
|
||||
* -------------------------------------------------
|
||||
*
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
*
|
||||
* Created by Hanna E. Rathje, SLSE, 2016-01-14
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <SituationReplay/srp_ftc.h>
|
||||
#include <SituationReplay/srp_ftc_types.h>
|
||||
|
||||
#include <DDS/DDSConnector/dds_connector.h>
|
||||
#include <DDS/DDSConnector/publisher.h>
|
||||
#include <DDS/DDSConnector/subscriber.h>
|
||||
|
||||
#include <Common/ProjectConfig/project_defines.h>
|
||||
#include <SituationReplay/logger.h>
|
||||
|
||||
namespace SituationReplay
|
||||
{
|
||||
class SrpFtTests : public QObject
|
||||
, protected SituationReplay::Interface::Ftc::ChangeReplayStateReplyHandler
|
||||
{
|
||||
using Publisher = DDSConnector::Publisher;
|
||||
using Subscriber = DDSConnector::Subscriber;
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum TestId
|
||||
{
|
||||
All,
|
||||
TryStart,
|
||||
TryNotAllowedChange,
|
||||
TryChangePaused,
|
||||
TryChangeResumed,
|
||||
TryStop,
|
||||
};
|
||||
explicit SrpFtTests(QObject *parent = nullptr);
|
||||
~SrpFtTests();
|
||||
|
||||
bool init(int domainId, TestId testId, int replayPartitionId, int srpId);
|
||||
bool testsSuccessful() const { return m_bTestsSuccessful; }
|
||||
|
||||
public Q_SLOTS:
|
||||
void startTest();
|
||||
protected Q_SLOTS:
|
||||
void tryStart();
|
||||
void tryNotAllowedChange();
|
||||
void tryChangePaused();
|
||||
void tryChangeResumed();
|
||||
void tryStop();
|
||||
protected:
|
||||
void startReplayReply(const Core::FunctionReplyObject &replyObject);
|
||||
void stopReplayReply(const Core::FunctionReplyObject &replyObject);
|
||||
void changeReplayStateReply(const Core::FunctionReplyObject &replyObject);
|
||||
void onChangeReplayStateReply(const Core::FunctionReplyObject &replyObject) override final;
|
||||
void failExit();
|
||||
void switchToState(SrpState state);
|
||||
private:
|
||||
std::shared_ptr<DDSConnector::DdsConnector> m_ddsConnector;
|
||||
std::shared_ptr<SituationReplay::Interface::Ftc> m_ftc;
|
||||
qint32 m_replayPartitionId;
|
||||
qint32 m_situationReplayId;
|
||||
TestId m_testId;
|
||||
TestId m_currentTestId;
|
||||
bool m_bTestsSuccessful;
|
||||
LOGGER_T m_logger;
|
||||
};
|
||||
|
||||
} // namespace SituationReplay
|
||||
Reference in new issue
Block a user