From e51ff47dd2dcfb2439c61cade8465ca8321b1b79 Mon Sep 17 00:00:00 2001 From: aviramd Date: Thu, 28 Nov 2024 14:49:10 +0000 Subject: [PATCH] fix and add unittests - draft --- lib/ClientSai.cpp | 5 +++-- proxylib/Sai.cpp | 2 +- unittest/lib/TestClientSai.cpp | 6 +++--- unittest/lib/TestServerSai.cpp | 1 + unittest/syncd/TestVendorSai.cpp | 7 +++++++ unittest/vslib/TestSai.cpp | 11 ++++++++++- vslib/Sai.cpp | 6 +++--- 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/ClientSai.cpp b/lib/ClientSai.cpp index 72f7e64af..34103be31 100644 --- a/lib/ClientSai.cpp +++ b/lib/ClientSai.cpp @@ -1557,7 +1557,8 @@ sai_status_t ClientSai::dbgGenerateDump( SWSS_LOG_ENTER(); REDIS_CHECK_API_INITIALIZED(); - const std::vector entry = + return SAI_STATUS_NOT_IMPLEMENTED; + /*const std::vector entry = { swss::FieldValueTuple("DBG_GENERATE_DUMP", dump_file_name), }; @@ -1567,5 +1568,5 @@ sai_status_t ClientSai::dbgGenerateDump( m_communicationChannel->set(key, entry, REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMP); swss::KeyOpFieldsValuesTuple kco; - return m_communicationChannel->wait(REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE, kco); + return m_communicationChannel->wait(REDIS_ASIC_STATE_COMMAND_DBG_GEN_DUMPRESPONSE, kco);*/ } diff --git a/proxylib/Sai.cpp b/proxylib/Sai.cpp index 2c58626f8..50e01687d 100644 --- a/proxylib/Sai.cpp +++ b/proxylib/Sai.cpp @@ -1131,7 +1131,7 @@ sai_status_t Sai::dbgGenerateDump( std::string key = "DBG_GEN_DUMP:01"; - m_communicationChannel->set(key, entry, "dbg_gen_dump"); + m_communicationChannel->set("api", entry, "dbg_gen_dump"); /*swss::KeyOpFieldsValuesTuple kco; diff --git a/unittest/lib/TestClientSai.cpp b/unittest/lib/TestClientSai.cpp index 45050ad54..b2f88ddaf 100644 --- a/unittest/lib/TestClientSai.cpp +++ b/unittest/lib/TestClientSai.cpp @@ -56,7 +56,7 @@ TEST(ClientSai, dbgGenerateDump) sai.apiInitialize(0,&test_services); - const std::string filePath = "/var/log/dbgGenerateDump.log"; + const std::string filePath = "/var/log/testDump.log"; - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.dbgGenerateDump(filePath.c_str())); -} + EXPECT_EQ(sai.dbgGenerateDump(filePath.c_str()), SAI_STATUS_NOT_IMPLEMENTED); +} \ No newline at end of file diff --git a/unittest/lib/TestServerSai.cpp b/unittest/lib/TestServerSai.cpp index df90bcc6f..91185c025 100644 --- a/unittest/lib/TestServerSai.cpp +++ b/unittest/lib/TestServerSai.cpp @@ -49,3 +49,4 @@ TEST(ServerSai, bulkGet) SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, statuses)); } + diff --git a/unittest/syncd/TestVendorSai.cpp b/unittest/syncd/TestVendorSai.cpp index f14d280a4..161409187 100644 --- a/unittest/syncd/TestVendorSai.cpp +++ b/unittest/syncd/TestVendorSai.cpp @@ -1558,3 +1558,10 @@ TEST_F(VendorSaiTest, bulk_prefix_compression_entry) EXPECT_EQ(SAI_STATUS_NOT_SUPPORTED, m_vsai->bulkSet(0, e, nullptr, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, nullptr)); } + +TEST_F(VendorSaiTest, dbgGenerateDump) +{ + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(SAI_STATUS_SUCCESS, m_vsai->dbgGenerateDump(filePath.c_str())); +} \ No newline at end of file diff --git a/unittest/vslib/TestSai.cpp b/unittest/vslib/TestSai.cpp index 5c0fa810e..32d9a1a70 100644 --- a/unittest/vslib/TestSai.cpp +++ b/unittest/vslib/TestSai.cpp @@ -24,4 +24,13 @@ TEST(Sai, bulkGet) attrs, SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR, statuses)); -} \ No newline at end of file +} + +TEST(Sai, dbgGenerateDump) +{ + Sai sai; + + const std::string filePath = "/var/log/testDump.log"; + + EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.dbgGenerateDump(filePath.c_str())); +} diff --git a/vslib/Sai.cpp b/vslib/Sai.cpp index 2248a9e52..4a5eb6585 100644 --- a/vslib/Sai.cpp +++ b/vslib/Sai.cpp @@ -856,11 +856,11 @@ sai_status_t Sai::queryApiVersion( sai_status_t Sai::dbgGenerateDump( _In_ const char *dump_file_name) { - MUTEX(); SWSS_LOG_ENTER(); - VS_CHECK_API_INITIALIZED(); - return m_meta->dbgGenerateDump(dump_file_name); + SWSS_LOG_ERROR("not implemented, FIXME"); + + return SAI_STATUS_NOT_IMPLEMENTED; }