mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Add options tests and (re-)/enable more nanomsg tests
This commit is contained in:
parent
ce4062f3a0
commit
ffab4ac78c
|
@ -202,11 +202,13 @@ add_testsuite(FairMQ.Transport
|
|||
SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/runner.cxx
|
||||
transport/_transfer_timeout.cxx
|
||||
transport/_options.cxx
|
||||
|
||||
LINKS FairMQ
|
||||
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
TIMEOUT 10
|
||||
${definitions}
|
||||
)
|
||||
|
||||
add_testsuite(FairMQ.Poller
|
||||
|
@ -218,4 +220,5 @@ add_testsuite(FairMQ.Poller
|
|||
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
TIMEOUT 10
|
||||
${definitions}
|
||||
)
|
||||
|
|
98
test/transport/_options.cxx
Normal file
98
test/transport/_options.cxx
Normal file
|
@ -0,0 +1,98 @@
|
|||
/********************************************************************************
|
||||
* Copyright (C) 2017 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 <gtest/gtest.h>
|
||||
#include <FairMQChannel.h>
|
||||
#include <FairMQParts.h>
|
||||
#include <FairMQLogger.h>
|
||||
#include <FairMQTransportFactory.h>
|
||||
#include <fairmq/Tools.h>
|
||||
#include <options/FairMQProgOptions.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
using namespace std;
|
||||
|
||||
void CheckOldOptionInterface(FairMQChannel& channel, const string& option, const string& transport)
|
||||
{
|
||||
int value = 500;
|
||||
channel.GetSocket().SetOption(option, &value, sizeof(value));
|
||||
value = 0;
|
||||
size_t valueSize = sizeof(value);
|
||||
channel.GetSocket().GetOption(option, &value, &valueSize);
|
||||
if (transport == "nanomsg" && (option == "snd-hwm" || option == "rcv-hwm")) {
|
||||
ASSERT_EQ(value, -1);
|
||||
} else {
|
||||
ASSERT_EQ(value, 500);
|
||||
}
|
||||
}
|
||||
|
||||
void RunOptionsTest(const string& transport)
|
||||
{
|
||||
size_t session{fair::mq::tools::UuidHash()};
|
||||
|
||||
FairMQProgOptions config;
|
||||
config.SetValue<string>("session", to_string(session));
|
||||
auto factory = FairMQTransportFactory::CreateTransportFactory(transport, fair::mq::tools::Uuid(), &config);
|
||||
FairMQChannel channel("Push", "push", factory);
|
||||
|
||||
CheckOldOptionInterface(channel, "linger", transport);
|
||||
CheckOldOptionInterface(channel, "snd-hwm", transport);
|
||||
CheckOldOptionInterface(channel, "rcv-hwm", transport);
|
||||
CheckOldOptionInterface(channel, "snd-size", transport);
|
||||
CheckOldOptionInterface(channel, "rcv-size", transport);
|
||||
|
||||
channel.GetSocket().SetLinger(300);
|
||||
ASSERT_EQ(channel.GetSocket().GetLinger(), 300);
|
||||
|
||||
channel.GetSocket().SetSndBufSize(500);
|
||||
if (transport == "nanomsg") { // nanomsg doesn't use this option and the getter always returns -1
|
||||
ASSERT_EQ(channel.GetSocket().GetSndBufSize(), -1);
|
||||
} else {
|
||||
ASSERT_EQ(channel.GetSocket().GetSndBufSize(), 500);
|
||||
}
|
||||
|
||||
channel.GetSocket().SetRcvBufSize(500);
|
||||
if (transport == "nanomsg") { // nanomsg doesn't use this option and the getter always returns -1
|
||||
ASSERT_EQ(channel.GetSocket().GetRcvBufSize(), -1);
|
||||
} else {
|
||||
ASSERT_EQ(channel.GetSocket().GetRcvBufSize(), 500);
|
||||
}
|
||||
|
||||
channel.GetSocket().SetSndKernelSize(8000);
|
||||
ASSERT_EQ(channel.GetSocket().GetSndKernelSize(), 8000);
|
||||
|
||||
channel.GetSocket().SetRcvKernelSize(8000);
|
||||
ASSERT_EQ(channel.GetSocket().GetRcvKernelSize(), 8000);
|
||||
}
|
||||
|
||||
TEST(Options, ZeroMQ)
|
||||
{
|
||||
RunOptionsTest("zeromq");
|
||||
}
|
||||
|
||||
TEST(Options, shmem)
|
||||
{
|
||||
RunOptionsTest("shmem");
|
||||
}
|
||||
|
||||
#ifdef BUILD_NANOMSG_TRANSPORT
|
||||
TEST(Options, nanomsg)
|
||||
{
|
||||
RunOptionsTest("nanomsg");
|
||||
}
|
||||
#endif /* BUILD_NANOMSG_TRANSPORT */
|
||||
|
||||
} // namespace
|
Loading…
Reference in New Issue
Block a user