shm: add monitor method to retrieve free segment memory

This commit is contained in:
Alexey Rybalchenko
2021-05-14 13:36:09 +02:00
parent aaf74ad93f
commit 021c1b1c4d
4 changed files with 104 additions and 2 deletions

View File

@@ -263,6 +263,7 @@ add_testsuite(Transport
${CMAKE_CURRENT_BINARY_DIR}/runner.cxx
transport/_transfer_timeout.cxx
transport/_options.cxx
transport/_shmem.cxx
LINKS FairMQ
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}

43
test/transport/_shmem.cxx Normal file
View File

@@ -0,0 +1,43 @@
/********************************************************************************
* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
* *
* This software is distributed under the terms of the *
* GNU Lesser General Public Licence (LGPL) version 3, *
* copied verbatim in the file "LICENSE" *
********************************************************************************/
#include <fairmq/ProgOptions.h>
#include <fairmq/shmem/Monitor.h>
#include <fairmq/tools/Unique.h>
#include <FairMQTransportFactory.h>
#include <gtest/gtest.h>
#include <string>
namespace
{
using namespace std;
using namespace fair::mq;
void GetFreeMemory()
{
ProgOptions config;
string sessionId(to_string(tools::UuidHash()));
config.SetProperty<string>("session", sessionId);
ASSERT_THROW(shmem::Monitor::GetFreeMemory(shmem::SessionId{sessionId}, 0), shmem::Monitor::MonitorError);
auto factory = FairMQTransportFactory::CreateTransportFactory("shmem", tools::Uuid(), &config);
ASSERT_NO_THROW(shmem::Monitor::GetFreeMemory(shmem::SessionId{sessionId}, 0));
ASSERT_THROW(shmem::Monitor::GetFreeMemory(shmem::SessionId{sessionId}, 1), shmem::Monitor::MonitorError);
}
TEST(Monitor, GetFreeMemory)
{
GetFreeMemory();
}
} // namespace