From b527e0878fabbfce41715e72913d84d028988a44 Mon Sep 17 00:00:00 2001 From: rpmarvell Date: Tue, 11 Feb 2025 13:44:04 +0000 Subject: [PATCH] Fixing the sairedis build issue caused at https://github.com/sonic-net/sonic-buildimage/pull/21614 , Reverting the testcase --- unittest/lib/MockSaiInterface.h | 4 -- unittest/lib/TestServerSai.cpp | 92 --------------------------------- 2 files changed, 96 deletions(-) diff --git a/unittest/lib/MockSaiInterface.h b/unittest/lib/MockSaiInterface.h index f9b0b025c..8e982f3a0 100644 --- a/unittest/lib/MockSaiInterface.h +++ b/unittest/lib/MockSaiInterface.h @@ -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)); }; diff --git a/unittest/lib/TestServerSai.cpp b/unittest/lib/TestServerSai.cpp index 2c6fe89a6..3a2c8ea91 100644 --- a/unittest/lib/TestServerSai.cpp +++ b/unittest/lib/TestServerSai.cpp @@ -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& 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) - { - SWSS_LOG_ENTER(); - m_sai = std::move(saiInterface); - } - - void setSelectableChannel(std::shared_ptr selectableChannel) - { - SWSS_LOG_ENTER(); - m_selectableChannel = std::move(selectableChannel); - } -}; - -class ServerSaiTest : public ::testing::Test -{ -protected: - TestableServerSai serverSai; - std::shared_ptr mockSai; - std::shared_ptr mockSelectableChannel; - - void SetUp() override - { - mockSai = std::make_shared(); - mockSelectableChannel = std::make_shared(); - - 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::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