diff --git a/unittest/lib/Makefile.am b/unittest/lib/Makefile.am index 6a274bca3..067158618 100644 --- a/unittest/lib/Makefile.am +++ b/unittest/lib/Makefile.am @@ -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) diff --git a/unittest/lib/TestZeroMQChannel.cpp b/unittest/lib/TestZeroMQChannel.cpp new file mode 100644 index 000000000..a5aaef833 --- /dev/null +++ b/unittest/lib/TestZeroMQChannel.cpp @@ -0,0 +1,34 @@ +#include "ZeroMQChannel.h" + +#include "swss/logger.h" + +#include + +#include + +using namespace sairedis; + +TEST(ZeroMQChannel, ctr) +{ + EXPECT_THROW(std::make_shared("/invalid_ep", "/invalid_ntf_ep", nullptr), std::runtime_error); + + EXPECT_THROW(std::make_shared("ipc:///tmp/valid", "/invalid_ntf_ep", nullptr), std::runtime_error); +} + +TEST(ZeroMQChannel, flush) +{ + auto c = std::make_shared("ipc:///tmp/valid_ep", "ipc:///tmp/valid_ntf_ep", nullptr); + + c->flush(); +} + +TEST(ZeroMQChannel, wait) +{ + auto c = std::make_shared("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); +}