From 465391d1825ea3906d27a1285d2da5876f763cd7 Mon Sep 17 00:00:00 2001 From: Vivek Date: Mon, 5 Aug 2024 14:26:32 -0700 Subject: [PATCH] Reduce log verbosity when the capability is not implemented (#3240) Co-authored-by: Sudharsan Dhamal Gopalarathnam --- orchagent/portsorch.cpp | 7 ++++++- tests/mock_tests/portsorch_ut.cpp | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp index 123e01c2b4..14b6d17847 100644 --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -440,7 +440,12 @@ static bool isPathTracingSupported() } } } - else + else if (status == SAI_STATUS_ATTR_NOT_IMPLEMENTED_0) + { + SWSS_LOG_INFO("Querying OBJECT_TYPE_LIST is not supported on this platform"); + return false; + } + else { SWSS_LOG_ERROR( "Failed to get a list of supported switch capabilities. Error=%d", status diff --git a/tests/mock_tests/portsorch_ut.cpp b/tests/mock_tests/portsorch_ut.cpp index da95b9dfb2..0f5d5929ab 100644 --- a/tests/mock_tests/portsorch_ut.cpp +++ b/tests/mock_tests/portsorch_ut.cpp @@ -27,6 +27,8 @@ namespace portsorch_test { using namespace std; + bool support_object_type_list = true; + // SAI default ports std::map> defaultPortList; @@ -197,6 +199,10 @@ namespace portsorch_test sai_status_t status; if (attr_count == 1 && attr_list[0].id == SAI_SWITCH_ATTR_SUPPORTED_OBJECT_TYPE_LIST) { + if (!support_object_type_list) + { + return SAI_STATUS_ATTR_NOT_IMPLEMENTED_0; + } uint32_t i; for (i = 0; i < attr_list[0].value.s32list.count && i < supported_sai_objects.size(); i++) { @@ -1626,6 +1632,11 @@ namespace portsorch_test // Port count: 32 Data + 1 CPU ASSERT_EQ(gPortsOrch->getAllPorts().size(), ports.size() + 1); + // Scenario 0: Query to fetch OBJECT_TYPE_LIST is not Implemented by the vendor + support_object_type_list = false; + ASSERT_FALSE(gPortsOrch->checkPathTracingCapability()); + support_object_type_list = true; + // Scenario 1: Path Tracing supported ASSERT_TRUE(gPortsOrch->checkPathTracingCapability());