Skip to content

Commit

Permalink
Fixing the sairedis build issue caused at sonic-net/sonic-buildimage#…
Browse files Browse the repository at this point in the history
…21614 , Reverting the testcase
  • Loading branch information
rpmarvell authored and pavannaregundi committed Feb 13, 2025
1 parent afaa59d commit b527e08
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 96 deletions.
4 changes: 0 additions & 4 deletions unittest/lib/MockSaiInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,5 @@ class MockSaiInterface: public saimeta::DummySaiInterface
_In_ uint64_t flags,
_In_ const sai_service_method_table_t *service_method_table) override;
virtual sai_status_t apiUninitialize(void) override;
public:
MOCK_METHOD(sai_status_t, queryStatsCapability,
(sai_object_id_t switchOid, sai_object_type_t objectType, sai_stat_capability_list_t* statCapList),
(override));
};

92 changes: 0 additions & 92 deletions unittest/lib/TestServerSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,95 +65,3 @@ TEST(ServerSai, bulkGet)
SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR,
statuses));
}

using namespace ::testing;

#ifdef MOCK_METHOD
class MockSelectableChannel : public sairedis::SelectableChannel {
public:
MOCK_METHOD(bool, empty, (), (override));
MOCK_METHOD(void, pop, (swss::KeyOpFieldsValuesTuple& kco, bool initViewMode), (override));
MOCK_METHOD(void, set, (const std::string& key, const std::vector<swss::FieldValueTuple>& values, const std::string& op), (override));
MOCK_METHOD(int, getFd, (), (override));
MOCK_METHOD(uint64_t, readData, (), (override));
};

class TestableServerSai : public ServerSai
{
public:

using ServerSai::processStatsCapabilityQuery;

void setSaiInterface(std::shared_ptr<SaiInterface> saiInterface)
{
SWSS_LOG_ENTER();
m_sai = std::move(saiInterface);
}

void setSelectableChannel(std::shared_ptr<SelectableChannel> selectableChannel)
{
SWSS_LOG_ENTER();
m_selectableChannel = std::move(selectableChannel);
}
};

class ServerSaiTest : public ::testing::Test
{
protected:
TestableServerSai serverSai;
std::shared_ptr<MockSaiInterface> mockSai;
std::shared_ptr<MockSelectableChannel> mockSelectableChannel;

void SetUp() override
{
mockSai = std::make_shared<MockSaiInterface>();
mockSelectableChannel = std::make_shared<MockSelectableChannel>();

serverSai.setSaiInterface(mockSai);
serverSai.setSelectableChannel(mockSelectableChannel);

}

void TearDown() override
{
mockSai.reset();
mockSelectableChannel.reset();
}
};

TEST_F(ServerSaiTest, ProcessStatsCapabilityQuery_ValidInputSuccess)
{
swss::KeyOpFieldsValuesTuple kco(
std::string("oid:0x21000000000000"),
std::string("SET"),
std::vector<std::pair<std::string, std::string>>{
{std::string("type"), std::string("SAI_OBJECT_TYPE_PORT")},
{std::string("list_size"), std::string("1")}
}
);

sai_stat_capability_t statList[2] = {
{SAI_PORT_STAT_IF_IN_UCAST_PKTS, SAI_STATS_MODE_READ}
};

sai_stat_capability_list_t statCapList;
statCapList.count = 1;
statCapList.list = statList;

EXPECT_CALL(*mockSai, queryStatsCapability(_, _, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(statCapList), Return(SAI_STATUS_SUCCESS)));

EXPECT_CALL(*mockSelectableChannel, set(
StrEq("SAI_STATUS_SUCCESS"),
AllOf(
Contains(swss::FieldValueTuple("STAT_ENUM", "1,")),
Contains(swss::FieldValueTuple("STAT_MODES", "1,")),
Contains(swss::FieldValueTuple("STAT_COUNT", "1"))
),
StrEq("stats_capability_response")
)).Times(1);

sai_status_t status = serverSai.processStatsCapabilityQuery(kco);
EXPECT_EQ(status, SAI_STATUS_SUCCESS);
}
#endif

0 comments on commit b527e08

Please sign in to comment.