From e3c934afc2506c1db61a708257e85b7345da8993 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 --- proxylib/Sai.cpp | 4 ++-- unittest/lib/TestClientSai.cpp | 10 ---------- unittest/lib/TestServerSai.cpp | 1 + unittest/syncd/TestVendorSai.cpp | 11 +++++++++++ unittest/vslib/TestSai.cpp | 11 ++++++++++- vslib/Sai.cpp | 6 +++--- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/proxylib/Sai.cpp b/proxylib/Sai.cpp index 2c58626f8..84d1ead83 100644 --- a/proxylib/Sai.cpp +++ b/proxylib/Sai.cpp @@ -1129,11 +1129,11 @@ sai_status_t Sai::dbgGenerateDump( swss::FieldValueTuple("DBG_GENERATE_DUMP", dump_file_name), }; - std::string key = "DBG_GEN_DUMP:01"; + /*std::string key = "DBG_GEN_DUMP:01"; m_communicationChannel->set(key, entry, "dbg_gen_dump"); - /*swss::KeyOpFieldsValuesTuple kco; + swss::KeyOpFieldsValuesTuple kco; return m_communicationChannel->wait("dbg_gen_dumpresponse", kco);*/ diff --git a/unittest/lib/TestClientSai.cpp b/unittest/lib/TestClientSai.cpp index 45050ad54..b080fd23a 100644 --- a/unittest/lib/TestClientSai.cpp +++ b/unittest/lib/TestClientSai.cpp @@ -50,13 +50,3 @@ TEST(ClientSai, bulkGet) statuses)); } -TEST(ClientSai, dbgGenerateDump) -{ - ClientSai sai; - - sai.apiInitialize(0,&test_services); - - const std::string filePath = "/var/log/dbgGenerateDump.log"; - - EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.dbgGenerateDump(filePath.c_str())); -} 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..00a9e574a 100644 --- a/unittest/syncd/TestVendorSai.cpp +++ b/unittest/syncd/TestVendorSai.cpp @@ -1558,3 +1558,14 @@ 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(VendorSaiTest, queryApiVersion) +{ + VendorSai sai; + + sai_api_version_t version; + + sai.apiInitialize(0,&test_services); + + EXPECT_EQ(sai.queryApiVersion(&version), SAI_STATUS_SUCCESS); +} \ 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; }