Skip to content

Commit

Permalink
fix and add unittests - draft
Browse files Browse the repository at this point in the history
  • Loading branch information
aviramd committed Dec 4, 2024
1 parent 51db5c1 commit 747da04
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 20 deletions.
12 changes: 1 addition & 11 deletions lib/ClientSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1557,15 +1557,5 @@ sai_status_t ClientSai::dbgGenerateDump(
SWSS_LOG_ENTER();
REDIS_CHECK_API_INITIALIZED();

const std::vector<swss::FieldValueTuple> entry =
{
swss::FieldValueTuple("DBG_GENERATE_DUMP", dump_file_name),
};

std::string key = "DBG_GEN_DUMP:01";

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 SAI_STATUS_NOT_IMPLEMENTED;
}
5 changes: 3 additions & 2 deletions proxylib/Proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ void Proxy::processSingleEvent(
void Proxy::processDbgGenerateDump(
_In_ const swss::KeyOpFieldsValuesTuple &kco)
{
SWSS_LOG_ENTER();
return SAI_STATUS_SUCCESS;
/*SWSS_LOG_ENTER();
const auto& values = kfvFieldsValues(kco);
if (values.size() != 1)
Expand All @@ -386,7 +387,7 @@ void Proxy::processDbgGenerateDump(
sai_status_t status = m_vendorSai->dbgGenerateDump(value_cstr);
m_selectableChannel->set(sai_serialize_status(status), {} , "dbg_gen_dumpresponse");
m_selectableChannel->set(sai_serialize_status(status), {} , "dbg_gen_dumpresponse");*/
}

void Proxy::processCreate(
Expand Down
6 changes: 3 additions & 3 deletions unittest/lib/TestClientSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions unittest/lib/TestServerSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,4 @@ TEST(ServerSai, bulkGet)
SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR,
statuses));
}

7 changes: 7 additions & 0 deletions unittest/syncd/TestVendorSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
}
11 changes: 10 additions & 1 deletion unittest/vslib/TestSai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,13 @@ TEST(Sai, bulkGet)
attrs,
SAI_BULK_OP_ERROR_MODE_STOP_ON_ERROR,
statuses));
}
}

TEST(Sai, dbgGenerateDump)
{
Sai sai;

const std::string filePath = "/var/log/testDump.log";

EXPECT_EQ(SAI_STATUS_NOT_IMPLEMENTED, sai.dbgGenerateDump(filePath.c_str()));
}
6 changes: 3 additions & 3 deletions vslib/Sai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


Expand Down

0 comments on commit 747da04

Please sign in to comment.