Skip to content

Commit

Permalink
Refactoring code and adding more coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dgsudharsan committed Mar 25, 2024
1 parent 32a195a commit 2ccadf4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 2 additions & 6 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7739,7 +7739,7 @@ void PortsOrch::refreshPortStatus()
updateDbPortOperSpeed(port, 0);
}
sai_port_fec_mode_t fec_mode;
string fec_str;
string fec_str = "N/A";
if (oper_fec_sup && getPortOperFec(port, fec_mode))
{
if (!m_portHlpr.fecToStr(fec_str, fec_mode))
Expand All @@ -7748,12 +7748,8 @@ void PortsOrch::refreshPortStatus()
static_cast<std::int32_t>(fec_mode), port.m_alias.c_str());
fec_str = "N/A";
}
updateDbPortOperFec(port,fec_str);
}
else
{
updateDbPortOperFec(port, "N/A");
}
updateDbPortOperFec(port,fec_str);
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions tests/mock_tests/portsorch_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,6 +1301,20 @@ namespace portsorch_test
}
}
ASSERT_TRUE(fec_found == true);

/*Mock an invalid fec mode with high value*/
_sai_port_fec_mode = 100;
gPortsOrch->refreshPortStatus();
statePortTable.get("Ethernet0", values);
fec_found = false;
for (auto &valueTuple : values)
{
if (fvField(valueTuple) == "fec")
{
fec_found = true;
ASSERT_TRUE(fvValue(valueTuple) == "N/A");
}
}
mock_port_fec_modes = old_mock_port_fec_modes;
_unhook_sai_port_api();
}
Expand Down

0 comments on commit 2ccadf4

Please sign in to comment.