Skip to content

Commit bcd1648

Browse files
committed
Add ZeroMQChannel tests
1 parent 0a2cb2c commit bcd1648

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

unittest/lib/Makefile.am

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ LDADD_GTEST = -L/usr/src/gtest -lgtest -lgtest_main
66

77
tests_SOURCES = \
88
main.cpp \
9+
../../meta/NumberOidIndexGenerator.cpp \
910
TestSwitch.cpp \
1011
TestClientConfig.cpp \
1112
TestClientServerSai.cppa \
1213
TestContext.cpp \
1314
TestContextConfig.cpp \
1415
TestContextConfigContainer.cpp \
15-
TestUtils.cpp
16+
TestUtils.cpp \
17+
TestVirtualObjectIdManager.cpp \
18+
TestZeroMQChannel.cpp
1619

1720
tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON)
1821
tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/lib/libSaiRedis.a -lhiredis -lswsscommon -lpthread -L$(top_srcdir)/meta/.libs -lsaimetadata -lsaimeta -lzmq $(CODE_COVERAGE_LIBS)

unittest/lib/TestZeroMQChannel.cpp

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#include "ZeroMQChannel.h"
2+
3+
#include "swss/logger.h"
4+
5+
#include <gtest/gtest.h>
6+
7+
#include <memory>
8+
9+
using namespace sairedis;
10+
11+
TEST(ZeroMQChannel, ctr)
12+
{
13+
EXPECT_THROW(std::make_shared<ZeroMQChannel>("/invalid_ep", "/invalid_ntf_ep", nullptr), std::runtime_error);
14+
15+
EXPECT_THROW(std::make_shared<ZeroMQChannel>("ipc:///tmp/valid", "/invalid_ntf_ep", nullptr), std::runtime_error);
16+
}
17+
18+
TEST(ZeroMQChannel, flush)
19+
{
20+
auto c = std::make_shared<ZeroMQChannel>("ipc:///tmp/valid_ep", "ipc:///tmp/valid_ntf_ep", nullptr);
21+
22+
c->flush();
23+
}
24+
25+
TEST(ZeroMQChannel, wait)
26+
{
27+
auto c = std::make_shared<ZeroMQChannel>("ipc:///tmp/valid_ep", "ipc:///tmp/valid_ntf_ep", nullptr);
28+
29+
c->setResponseTimeout(60);
30+
31+
swss::KeyOpFieldsValuesTuple kco;
32+
33+
EXPECT_NE(c->wait("foo", kco), SAI_STATUS_SUCCESS);
34+
}

0 commit comments

Comments
 (0)