Skip to content

Commit

Permalink
Merge branch 'master' into bugfix/event_ownership_added_api
Browse files Browse the repository at this point in the history
  • Loading branch information
rex-schilasky authored Oct 25, 2023
2 parents 85e193e + 171ecae commit b83511b
Show file tree
Hide file tree
Showing 21 changed files with 104 additions and 70 deletions.
4 changes: 2 additions & 2 deletions ecal/core/src/io/ecal_memfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace eCAL
if (!memfile::db::AddFile(name_, create_, create_ ? len_ + m_header.int_hdr_size : SIZEOF_PARTIAL_STRUCT(SInternalHeader, int_hdr_size), m_memfile_info))
{
#ifndef NDEBUG
printf("Could not create memory file: %s.\n\n", name_);
printf("Could not create memory file: %s.\n", name_);
#endif
return(false);
}
Expand All @@ -98,7 +98,7 @@ namespace eCAL
if(!m_memfile_mutex.Create(name_, m_auto_sanitizing))
{
#ifndef NDEBUG
printf("Could not create memory file mutex: %s.\n\n", name_);
printf("Could not create memory file mutex: %s.\n", name_);
#endif
return(false);
}
Expand Down
4 changes: 2 additions & 2 deletions ecal/core/src/io/ecal_memfile_sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,12 @@ namespace eCAL
// create the memory file
if (!m_memfile.Create(m_memfile_name.c_str(), true, memfile_size))
{
Logging::Log(log_level_error, std::string(m_base_name + "::CSyncMemoryFile::Create - FAILED : ") + m_memfile_name);
Logging::Log(log_level_error, std::string("CSyncMemoryFile::Create FAILED : ") + m_memfile_name);
return false;
}

#ifndef NDEBUG
Logging::Log(log_level_debug2, std::string(m_base_name + "::CSyncMemoryFile::Create - SUCCESS : ") + m_memfile_name);
Logging::Log(log_level_debug2, std::string("CSyncMemoryFile::Create SUCCESS : ") + m_memfile_name);
#endif

// initialize memory file with empty header
Expand Down
1 change: 1 addition & 0 deletions ecal/core/src/io/ecal_memfile_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ namespace eCAL

std::string GetName() const;
size_t GetSize() const;
bool IsCreated() const { return m_created; };

protected:
bool Create(const std::string& base_name_, size_t size_);
Expand Down
13 changes: 10 additions & 3 deletions ecal/core/src/io/linux/ecal_memfile_os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ namespace eCAL
umask(previous_umask); // reset umask to previous permissions
if (mem_file_info_.memfile == -1)
{
std::cout << "shm_open failed : " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
if(create_)
{
std::cerr << "shm_open failed to CREATE memory file (memfile::os::AllocFile): " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
}
else
{
std::cerr << "shm_open failed to OPEN memory file (memfile::os::AllocFile): " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
}
mem_file_info_.memfile = 0;
mem_file_info_.name = "";
mem_file_info_.exists = false;
Expand Down Expand Up @@ -101,7 +108,7 @@ namespace eCAL
// truncate file
if (::ftruncate(mem_file_info_.memfile, mem_file_info_.size) != 0)
{
std::cout << "ftruncate failed : " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
std::cerr << "ftruncate failed (memfile::os::MapFile): " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
}
}

Expand All @@ -113,7 +120,7 @@ namespace eCAL
if (mem_file_info_.mem_address == MAP_FAILED)
{
mem_file_info_.mem_address = nullptr;
std::cout << "mmap failed : " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
std::cerr << "mmap failed (memfile::os::MapFile): " << mem_file_info_.name << " errno: " << strerror(errno) << std::endl;
return(false);
}
}
Expand Down
40 changes: 32 additions & 8 deletions ecal/core/src/readwrite/ecal_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1057,10 +1057,16 @@ namespace eCAL
{
case TLayer::eSendMode::smode_auto:
case TLayer::eSendMode::smode_on:
m_writer.udp_mc.Create(m_host_name, m_topic_name, m_topic_id);
if (m_writer.udp_mc.Create(m_host_name, m_topic_name, m_topic_id))
{
#ifndef NDEBUG
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::UDP_MC_WRITER");
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::UDP_MC_WRITER - SUCCESS");
#endif
}
else
{
Logging::Log(log_level_error, m_topic_name + "::CDataWriter::Create::UDP_MC_WRITER - FAILED");
}
break;
case TLayer::eSendMode::smode_none:
case TLayer::eSendMode::smode_off:
Expand All @@ -1081,10 +1087,16 @@ namespace eCAL
{
case TLayer::eSendMode::smode_auto:
case TLayer::eSendMode::smode_on:
m_writer.shm.Create(m_host_name, m_topic_name, m_topic_id);
if (m_writer.shm.Create(m_host_name, m_topic_name, m_topic_id))
{
#ifndef NDEBUG
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::SHM_WRITER");
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::SHM_WRITER - SUCCESS");
#endif
}
else
{
Logging::Log(log_level_error, m_topic_name + "::CDataWriter::Create::SHM_WRITER - FAILED");
}
break;
case TLayer::eSendMode::smode_none:
case TLayer::eSendMode::smode_off:
Expand All @@ -1105,10 +1117,16 @@ namespace eCAL
{
case TLayer::eSendMode::smode_auto:
case TLayer::eSendMode::smode_on:
m_writer.tcp.Create(m_host_name, m_topic_name, m_topic_id);
if (m_writer.tcp.Create(m_host_name, m_topic_name, m_topic_id))
{
#ifndef NDEBUG
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::TCP_WRITER");
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::TCP_WRITER - SUCCESS");
#endif
}
else
{
Logging::Log(log_level_error, m_topic_name + "::CDataWriter::Create::TCP_WRITER - FAILED");
}
break;
case TLayer::eSendMode::smode_none:
case TLayer::eSendMode::smode_off:
Expand All @@ -1129,10 +1147,16 @@ namespace eCAL
{
case TLayer::eSendMode::smode_auto:
case TLayer::eSendMode::smode_on:
m_writer.inproc.Create(m_host_name, m_topic_name, m_topic_id);
if (m_writer.inproc.Create(m_host_name, m_topic_name, m_topic_id))
{
#ifndef NDEBUG
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::INPROC_WRITER");
Logging::Log(log_level_debug4, m_topic_name + "::CDataWriter::Create::INPROC_WRITER - SUCCESS");
#endif
}
else
{
Logging::Log(log_level_error, m_topic_name + "::CDataWriter::Create::INPROC_WRITER - FAILED");
}
break;
default:
m_writer.inproc.Destroy();
Expand Down
17 changes: 12 additions & 5 deletions ecal/core/src/readwrite/ecal_writer_shm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ namespace eCAL
m_memory_file_attr.timeout_ack_ms = Config::GetMemfileAckTimeoutMs();

// initialize memory file buffer
SetBufferCount(m_buffer_count);

m_created = true;
m_created = SetBufferCount(m_buffer_count);;
return m_created;
}

Expand Down Expand Up @@ -124,12 +122,21 @@ namespace eCAL
memory_file_size = m_memory_file_attr.min_size;
}

// recreate memory file vector
// create memory file vector
m_memory_file_vec.clear();
while (m_memory_file_vec.size() < buffer_count_)
{
auto sync_memfile = std::make_shared<CSyncMemoryFile>(m_memfile_base_name, memory_file_size, m_memory_file_attr);
m_memory_file_vec.push_back(sync_memfile);
if (sync_memfile->IsCreated())
{
m_memory_file_vec.push_back(sync_memfile);
}
else
{
m_memory_file_vec.clear();
Logging::Log(log_level_error, "CDataWriterSHM::SetBufferCount - FAILED");
return false;
}
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion ecal/service/test/src/ecal_tcp_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,7 +1306,7 @@ TEST(CommunicationAndCallbacks, StressfulCommunicationMassivePayload) // NOLINT
#endif

#if 1
TEST(callback, ServerAndClientManagers) // NOLINT
TEST(Callback, ServerAndClientManagers) // NOLINT
{
for (std::uint8_t protocol_version = min_protocol_version; protocol_version <= max_protocol_version; protocol_version++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
void ProcProtoMsg(const google::protobuf::Message& msg_, const std::string& prefix_ /* = "" */);

// google test
TEST(IO, dynproto)
TEST(DynProto, dynproto)
{
// generate a class instance of Person
pb::People::Person person;
Expand Down
10 changes: 5 additions & 5 deletions testing/contrib/ecalproto/ecal_proto_test/src/test_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@

using namespace eCAL::protobuf;

TEST(filter, nofilter)
TEST(Filter, nofilter)
{
NoFilter filter;
bool result = filter.Filter("abc");
EXPECT_EQ(true, result);
}

TEST(filter, include_filter_clear)
TEST(Filter, include_filter_clear)
{
SimpleIncludeFilter filter;
std::string a("a");
Expand Down Expand Up @@ -90,15 +90,15 @@ void test_regular_includes(BaseIncludeFilter& filter)
EXPECT_EQ(false, filter.Filter(adf));
}

TEST(filter, include_filter)
TEST(Filter, include_filter)
{
SimpleIncludeFilter simple_filter;
test_regular_includes(simple_filter);
ComplexIncludeFilter complex_filter;
test_regular_includes(complex_filter);
}

TEST(filter, include_filter_array_simple)
TEST(Filter, include_filter_array_simple)
{
const std::string a("a");
const std::string a1("a[1]");
Expand Down Expand Up @@ -130,7 +130,7 @@ TEST(filter, include_filter_array_simple)
EXPECT_EQ(false, filter.Filter(a2b)); // should not accept a[2].b
}

TEST(filter, include_filter_array_complex)
TEST(Filter, include_filter_array_complex)
{
const std::string a ("a" );
const std::string a1 ("a[1]" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#define CMN_MONITORING_TIMEOUT 5000

TEST(IO, GetServices)
TEST(ClientServer, GetServices)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "clientserver_getservices");
Expand Down
20 changes: 10 additions & 10 deletions testing/ecal/clientserver_test/src/clientserver_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace

#if ClientConnectEventTest

TEST(IO, ClientConnectEvent)
TEST(ClientServer, ClientConnectEvent)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "clientserver base connect event callback");
Expand Down Expand Up @@ -156,7 +156,7 @@ TEST(IO, ClientConnectEvent)

#if ServerConnectEventTest

TEST(IO, ServerConnectEvent)
TEST(ClientServer, ServerConnectEvent)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "clientserver base connect event callback");
Expand Down Expand Up @@ -218,7 +218,7 @@ TEST(IO, ServerConnectEvent)

#if ClientServerBaseCallbackTest

TEST(IO, ClientServerBaseCallback)
TEST(ClientServer, ClientServerBaseCallback)
{
const int num_services(2);
const int num_clients(3);
Expand Down Expand Up @@ -332,7 +332,7 @@ TEST(IO, ClientServerBaseCallback)

#if ClientServerBaseCallbackTimeoutTest

TEST(IO, ClientServerBaseCallbackTimeout)
TEST(ClientServer, ClientServerBaseCallbackTimeout)
{
const int num_services(2);
const int num_clients(3);
Expand Down Expand Up @@ -502,7 +502,7 @@ TEST(IO, ClientServerBaseCallbackTimeout)

#if ClientServerBaseAsyncCallbackTest

TEST(IO, ClientServerBaseAsyncCallback)
TEST(ClientServer, ClientServerBaseAsyncCallback)
{
const int calls(1);
const int sleep(100);
Expand Down Expand Up @@ -576,7 +576,7 @@ TEST(IO, ClientServerBaseAsyncCallback)

#if ClientServerBaseAsyncTest

TEST(IO, ClientServerBaseAsyncTest)
TEST(ClientServer, ClientServerBaseAsyncTest)
{
const int calls(5);

Expand Down Expand Up @@ -683,7 +683,7 @@ TEST(IO, ClientServerBaseAsyncTest)

#if ClientServerBaseBlockingTest

TEST(IO, ClientServerBaseBlocking)
TEST(ClientServer, ClientServerBaseBlocking)
{
const int num_services(2);
const int num_clients(3);
Expand Down Expand Up @@ -818,7 +818,7 @@ class MathServiceImpl : public MathService
}
};

TEST(IO, ClientServerProtoCallback)
TEST(ClientServer, ClientServerProtoCallback)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "clientserver proto callback test");
Expand Down Expand Up @@ -907,7 +907,7 @@ class PingServiceImpl : public PingService
}
};

TEST(IO, ClientServerProtoBlocking)
TEST(ClientServer, ClientServerProtoBlocking)
{
// initialize eCAL API
eCAL::Initialize(0, nullptr, "clientserver proto blocking test");
Expand Down Expand Up @@ -959,7 +959,7 @@ TEST(IO, ClientServerProtoBlocking)

#if NestedRPCCallTest

TEST(IO, NestedRPCCall)
TEST(ClientServer, NestedRPCCall)
{
const int calls(1);
const int sleep(0);
Expand Down
3 changes: 1 addition & 2 deletions testing/ecal/io_memfile_test/src/memfile_naming_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <gtest/gtest.h>


TEST(IO, MemfileNaming)
TEST(MemFile, MemfileNaming)
{
std::chrono::steady_clock::time_point timepoint{};

Expand All @@ -37,5 +37,4 @@ TEST(IO, MemfileNaming)

EXPECT_LE(memfile_name_1.size(), 13);
EXPECT_NE(memfile_name_1, memfile_name_2);

}
6 changes: 3 additions & 3 deletions testing/ecal/io_memfile_test/src/memfile_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace eCAL
}
}

TEST(IO, MemfileReadWrite)
TEST(MemFile, MemfileReadWrite)
{
eCAL::CMemoryFile mem_file;

Expand Down Expand Up @@ -140,7 +140,7 @@ TEST(IO, MemfileReadWrite)
EXPECT_EQ(true, mem_file.Destroy(true));
}

TEST(IO, MemfilePerf)
TEST(MemFile, MemfilePerf)
{
eCAL::CMemoryFile mem_file;

Expand Down Expand Up @@ -200,7 +200,7 @@ TEST(IO, MemfilePerf)
EXPECT_EQ(true, mem_file.Destroy(true));
}

TEST(IO, MemfileConcurrency)
TEST(MemFile, MemfileConcurrency)
{
eCAL::CMemoryFile mem_file;

Expand Down
2 changes: 1 addition & 1 deletion testing/ecal/pubsub_inproc_test/src/pubsub_inproc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void OnReceive3()
sub_clock3++;
}

TEST(INPROC, CLOCKS)
TEST(PubSubInproc, CLOCKS)
{
// initialize eCAL API
EXPECT_EQ(0, eCAL::Initialize(0, nullptr, "inproc_clock_test"));
Expand Down
Loading

0 comments on commit b83511b

Please sign in to comment.