Skip to content

Commit 1b2ef88

Browse files
Add UT
Signed-off-by: Stepan Blyschak <[email protected]>
1 parent eb58cca commit 1b2ef88

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

tests/mock_tests/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ tests_SOURCES = aclorch_ut.cpp \
4040
mock_orchagent_main.cpp \
4141
mock_dbconnector.cpp \
4242
mock_consumerstatetable.cpp \
43+
mock_subscriberstatetable.cpp \
4344
common/mock_shell_command.cpp \
4445
mock_table.cpp \
4546
mock_hiredis.cpp \
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include "subscriberstatetable.h"
2+
3+
namespace swss
4+
{
5+
SubscriberStateTable::SubscriberStateTable(DBConnector *db, const std::string &tableName, int popBatchSize, int pri) :
6+
ConsumerTableBase(db, tableName, popBatchSize, pri),
7+
m_table(db, tableName)
8+
{
9+
}
10+
11+
void SubscriberStateTable::pops(std::deque<KeyOpFieldsValuesTuple> &vkco, const std::string& /*prefix*/)
12+
{
13+
std::vector<std::string> keys;
14+
m_table.getKeys(keys);
15+
for (const auto &key: keys)
16+
{
17+
KeyOpFieldsValuesTuple kco;
18+
19+
kfvKey(kco) = key;
20+
kfvOp(kco) = SET_COMMAND;
21+
22+
if (!m_table.get(key, kfvFieldsValues(kco)))
23+
{
24+
continue;
25+
}
26+
m_table.del(key);
27+
vkco.push_back(kco);
28+
}
29+
}
30+
}

tests/mock_tests/portsorch_ut.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,9 @@ namespace portsorch_test
499499
}
500500

501501
};
502-
502+
503503
/*
504-
* Test port flap count
504+
* Test port flap count
505505
*/
506506
TEST_F(PortsOrchTest, PortFlapCount)
507507
{
@@ -1473,6 +1473,7 @@ namespace portsorch_test
14731473
Table pgTable = Table(m_app_db.get(), APP_BUFFER_PG_TABLE_NAME);
14741474
Table profileTable = Table(m_app_db.get(), APP_BUFFER_PROFILE_TABLE_NAME);
14751475
Table poolTable = Table(m_app_db.get(), APP_BUFFER_POOL_TABLE_NAME);
1476+
Table transceieverInfoTable = Table(m_state_db.get(), STATE_TRANSCEIVER_INFO_TABLE_NAME);
14761477

14771478
// Get SAI default ports to populate DB
14781479

@@ -1506,6 +1507,7 @@ namespace portsorch_test
15061507
for (const auto &it : ports)
15071508
{
15081509
portTable.set(it.first, it.second);
1510+
transceieverInfoTable.set(it.first, {});
15091511
}
15101512

15111513
// Set PortConfigDone, PortInitDone
@@ -1553,6 +1555,24 @@ namespace portsorch_test
15531555

15541556
gBufferOrch->dumpPendingTasks(ts);
15551557
ASSERT_TRUE(ts.empty());
1558+
1559+
// Verify port configuration
1560+
vector<sai_object_id_t> port_list;
1561+
port_list.resize(ports.size());
1562+
sai_attribute_t attr;
1563+
sai_status_t status;
1564+
attr.id = SAI_SWITCH_ATTR_PORT_LIST;
1565+
attr.value.objlist.count = static_cast<uint32_t>(port_list.size());
1566+
attr.value.objlist.list = port_list.data();
1567+
status = sai_switch_api->get_switch_attribute(gSwitchId, 1, &attr);
1568+
ASSERT_EQ(status, SAI_STATUS_SUCCESS);
1569+
1570+
for (uint32_t i = 0; i < port_list.size(); i++) {
1571+
attr.id = SAI_PORT_ATTR_HOST_TX_SIGNAL_ENABLE;
1572+
status = sai_port_api->get_port_attribute(port_list[i], 1, &attr);
1573+
ASSERT_EQ(status, SAI_STATUS_SUCCESS);
1574+
ASSERT_TRUE(attr.value.booldata);
1575+
}
15561576
}
15571577

15581578
TEST_F(PortsOrchTest, PfcDlrHandlerCallingDlrInitAttribute)

0 commit comments

Comments
 (0)