SDK: Pass CSession as shared ptr

Even though it is copyable the copy does not work.
This commit is contained in:
Dennis Klein
2019-07-25 14:40:24 +02:00
parent 5ab328b01f
commit 363576496d
8 changed files with 75 additions and 64 deletions

View File

@@ -289,7 +289,7 @@ if(BUILD_SDK)
${CMAKE_CURRENT_BINARY_DIR}/runner.cxx
sdk/_dds.cxx
sdk/_topology.cxx
sdk/TopologyFixture.h
sdk/Fixtures.h
LINKS
SDK

View File

@@ -6,8 +6,8 @@
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#ifndef FAIR_MQ_TEST_TOPOLOGYFIXTURE
#define FAIR_MQ_TEST_TOPOLOGYFIXTURE
#ifndef FAIR_MQ_TEST_FIXTURES
#define FAIR_MQ_TEST_FIXTURES
#include "TestEnvironment.h"
#include <fairmq/SDK.h>
@@ -51,10 +51,6 @@ struct TopologyFixture : ::testing::Test
mDDSSession.StopOnDestruction();
}
// auto ActivateDDSTopology(const std::string& topology_file) -> void {
// LOG(debug) << "ActivateDDSTopology(\"" << topology_file << "\")";
// }
auto SetUp() -> void override {
LOG(info) << mDDSEnv;
LOG(info) << mDDSSession;
@@ -78,5 +74,5 @@ struct TopologyFixture : ::testing::Test
} /* namespace mq */
} /* namespace fair */
#endif /* FAIR_MQ_TEST_TOPOLOGYFIXTURE */
#endif /* FAIR_MQ_TEST_FIXTURES */

View File

@@ -6,41 +6,44 @@
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include <TestEnvironment.h>
#include <fairlogger/Logger.h>
#include <fairmq/sdk/DDSEnvironment.h>
#include <fairmq/sdk/DDSInfo.h>
#include <fairmq/sdk/DDSSession.h>
#include <gtest/gtest.h>
#include "Fixtures.h"
#include <DDS/Topology.h>
#include <DDS/Tools.h>
namespace {
auto setup() -> void
TEST(DDSEnvironment, Construction)
{
fair::Logger::SetConsoleSeverity("debug");
fair::Logger::DefineVerbosity("user1",
fair::VerbositySpec::Make(fair::VerbositySpec::Info::timestamp_us,
fair::VerbositySpec::Info::severity));
fair::Logger::SetVerbosity("user1");
fair::Logger::SetConsoleColor();
}
TEST(DDS, Environment)
{
setup();
fair::mq::test::LoggerConfig cfg;
fair::mq::sdk::DDSEnvironment env(CMAKE_CURRENT_BINARY_DIR);
LOG(debug) << env;
}
TEST(DDS, Session)
TEST(DDSSession, Construction)
{
setup();
fair::mq::test::LoggerConfig cfg;
fair::mq::sdk::DDSEnvironment env(CMAKE_CURRENT_BINARY_DIR);
fair::mq::sdk::DDSSession session(env);
session.StopOnDestruction();
LOG(debug) << session;
}
TEST(DDSSession, Construction2)
{
fair::mq::test::LoggerConfig cfg;
fair::mq::sdk::DDSEnvironment env(CMAKE_CURRENT_BINARY_DIR);
auto nativeSession(std::make_shared<dds::tools_api::CSession>());
nativeSession->create();
fair::mq::sdk::DDSSession session(nativeSession, env);
session.StopOnDestruction();
LOG(debug) << session;
session.RequestCommanderInfo();
}
} // namespace

View File

@@ -6,7 +6,7 @@
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include "TopologyFixture.h"
#include "Fixtures.h"
#include <DDS/Topology.h>
#include <DDS/Tools.h>
@@ -20,13 +20,15 @@ using Topology = fair::mq::test::TopologyFixture;
TEST(Topology2, ConstructionWithNativeDdsApiObjects)
{
// This is only needed for this unit test
fair::mq::test::LoggerConfig cfg;
fair::mq::sdk::DDSEnv env(CMAKE_CURRENT_BINARY_DIR);
/////////////////////////////////////////
// Example usage:
dds::topology_api::CTopology nativeTopo(fair::mq::tools::ToString(SDK_TESTSUITE_SOURCE_DIR, "/test_topo.xml"));
dds::tools_api::CSession nativeSession;
nativeSession.create();
fair::mq::sdk::Topology topo(nativeTopo, nativeSession, env);
auto nativeSession(std::make_shared<dds::tools_api::CSession>());
nativeSession->create();
EXPECT_THROW(fair::mq::sdk::Topology topo(nativeTopo, nativeSession, env), std::runtime_error);
}
TEST_F(Topology, Construction)