Skip to content

Commit

Permalink
Add ZeroMQChannel tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kcudnik committed Sep 20, 2021
1 parent 0a2cb2c commit bcd1648
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
5 changes: 4 additions & 1 deletion unittest/lib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main

tests_SOURCES = \
main.cpp \
../../meta/NumberOidIndexGenerator.cpp \
TestSwitch.cpp \
TestClientConfig.cpp \
TestClientServerSai.cppa \
TestContext.cpp \
TestContextConfig.cpp \
TestContextConfigContainer.cpp \
TestUtils.cpp
TestUtils.cpp \
TestVirtualObjectIdManager.cpp \
TestZeroMQChannel.cpp

tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/lib/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)
Expand Down
34 changes: 34 additions & 0 deletions unittest/lib/TestZeroMQChannel.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "ZeroMQChannel.h"

#include "swss/logger.h"

#include <gtest/gtest.h>

#include <memory>

using namespace sairedis;

TEST(ZeroMQChannel, ctr)
{
EXPECT_THROW(std::make_shared<ZeroMQChannel>("/invalid_ep", "/invalid_ntf_ep", nullptr), std::runtime_error);

EXPECT_THROW(std::make_shared<ZeroMQChannel>("ipc:///tmp/valid", "/invalid_ntf_ep", nullptr), std::runtime_error);
}

TEST(ZeroMQChannel, flush)
{
auto c = std::make_shared<ZeroMQChannel>("ipc:///tmp/valid_ep", "ipc:///tmp/valid_ntf_ep", nullptr);

c->flush();
}

TEST(ZeroMQChannel, wait)
{
auto c = std::make_shared<ZeroMQChannel>("ipc:///tmp/valid_ep", "ipc:///tmp/valid_ntf_ep", nullptr);

c->setResponseTimeout(60);

swss::KeyOpFieldsValuesTuple kco;

EXPECT_NE(c->wait("foo", kco), SAI_STATUS_SUCCESS);
}

0 comments on commit bcd1648

Please sign in to comment.