Skip to content

Commit

Permalink
Add unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
jfeng-arista committed Aug 30, 2022
1 parent cb41a91 commit 9800a21
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
3 changes: 2 additions & 1 deletion unittest/vslib/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
34 changes: 34 additions & 0 deletions unittest/vslib/TestSwitchStateBase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include "SwitchStateBase.h"
#include "MACsecAttr.h"

#include <gtest/gtest.h>

#include <vector>

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<SwitchConfig>(0, "");
auto scc = std::make_shared<SwitchConfigContainer>();

SwitchStateBase ss(
0x2100000000,
std::make_shared<RealObjectIdManager>(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));
}

0 comments on commit 9800a21

Please sign in to comment.