diff --git a/unittest/vslib/Makefile.am b/unittest/vslib/Makefile.am index ce3b19719..9dfe4728f 100644 --- a/unittest/vslib/Makefile.am +++ b/unittest/vslib/Makefile.am @@ -42,7 +42,8 @@ tests_SOURCES = main.cpp \ TestSwitchBCM56850.cpp \ TestSwitchBCM81724.cpp \ TestSwitchStateBaseMACsec.cpp \ - TestMACsecManager.cpp + TestMACsecManager.cpp \ + TestSwitchStateBase.cpp tests_CXXFLAGS = $(DBGFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS_COMMON) -fno-access-control tests_LDADD = $(LDADD_GTEST) $(top_srcdir)/vslib/libSaiVS.a -lhiredis -lswsscommon -lnl-genl-3 -lnl-nf-3 -lnl-route-3 -lnl-3 \ diff --git a/unittest/vslib/TestSwitchStateBase.cpp b/unittest/vslib/TestSwitchStateBase.cpp new file mode 100644 index 000000000..4cc6fe692 --- /dev/null +++ b/unittest/vslib/TestSwitchStateBase.cpp @@ -0,0 +1,34 @@ +#include "SwitchStateBase.h" +#include "MACsecAttr.h" + +#include + +#include + +using namespace saivs; + +//Test the following function: +//sai_status_t initialize_voq_switch_objects( +// _In_ uint32_t attr_count, +// _In_ const sai_attribute_t *attr_list); + +TEST(SwitchStateBase, initialize_voq_switch_objects) +{ + auto sc = std::make_shared(0, ""); + auto scc = std::make_shared(); + + SwitchStateBase ss( + 0x2100000000, + std::make_shared(0, scc), + sc); + + sai_attribute_t attr; + + attr.id = SAI_SWITCH_ATTR_TYPE; + attr.value.u32 = SAI_SWITCH_TYPE_FABRIC; + sc->m_fabricLaneMap = LaneMap::getDefaultLaneMap(0); + // Check the result of the initialize_voq_switch_objects + EXPECT_EQ(SAI_STATUS_SUCCESS, + ss.initialize_voq_switch_objects(1, &attr)); +} +