Skip to content

Commit 75e69f3

Browse files
Fix Minor bugs
- minor bugs - added one more unit test
1 parent bd210f5 commit 75e69f3

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

orchagent/portsorch.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3812,9 +3812,9 @@ bool PortsOrch::initPort(const PortConfig &port)
38123812
}
38133813
if (flex_counters_orch->getPortAttrCountersState())
38143814
{
3815-
if (p.m_type == Port::Type::PHY && supportsPortAttr(p.m_port_id, p.m_alias.c_str()))
3815+
if (!m_supported_phy_attrs.empty())
38163816
{
3817-
if (!m_supported_phy_attrs.empty())
3817+
if (p.m_type == Port::Type::PHY && supportsPortAttr(p.m_port_id, p.m_alias.c_str()))
38183818
{
38193819
auto port_attr_stats = generateCounterStats(m_supported_phy_attrs, sai_serialize_port_attr);
38203820
port_attr_manager.setCounterIdList(p.m_port_id,
@@ -3906,9 +3906,9 @@ void PortsOrch::deInitPort(string alias, sai_object_id_t port_id)
39063906
{
39073907
wred_port_stat_manager.clearCounterIdList(p.m_port_id);
39083908
}
3909-
if (p.m_type == Port::Type::PHY && supportsPortAttr(p.m_port_id, p.m_alias.c_str()))
3909+
if (!m_supported_phy_attrs.empty())
39103910
{
3911-
if (!m_supported_phy_attrs.empty())
3911+
if (p.m_type == Port::Type::PHY && supportsPortAttr(p.m_port_id, p.m_alias.c_str()))
39123912
{
39133913
port_attr_manager.clearCounterIdList(p.m_port_id);
39143914
}
@@ -8422,8 +8422,6 @@ void PortsOrch::queryPortAttrCapabilities()
84228422
SWSS_LOG_NOTICE("PORT_ATTR: Attribute %s is NOT supported (status=%d, get_implemented=%d)",
84238423
attr_name, status, capability.get_implemented);
84248424
}
8425-
//TODO: remove the next line once brcm support attribute query capability
8426-
m_supported_phy_attrs.push_back(attr_id);
84278425
}
84288426

84298427
m_phy_attr_capability_checked = true;

tests/mock_tests/portphyattr_ut.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,23 @@ namespace portphyattr_test
247247
// Verify the operations completed without crashes
248248
SUCCEED() << "All PORT_ATTR counter map operations completed successfully";
249249
}
250+
251+
TEST_F(PortAttrTest, QueryPortAttrCapabilitiesWithMockedSAI)
252+
{
253+
ASSERT_NE(gPortsOrch, nullptr);
254+
255+
EXPECT_FALSE(gPortsOrch->m_phy_attr_capability_checked);
256+
EXPECT_TRUE(gPortsOrch->m_supported_phy_attrs.empty());
257+
258+
gPortsOrch->queryPortAttrCapabilities();
259+
260+
EXPECT_TRUE(gPortsOrch->m_phy_attr_capability_checked);
261+
262+
for (const auto& attr : gPortsOrch->m_supported_phy_attrs)
263+
{
264+
EXPECT_TRUE(attr == SAI_PORT_ATTR_RX_SIGNAL_DETECT ||
265+
attr == SAI_PORT_ATTR_FEC_ALIGNMENT_LOCK ||
266+
attr == SAI_PORT_ATTR_RX_SNR);
267+
}
268+
}
250269
} // namespace portphyattr_test

0 commit comments

Comments
 (0)