Skip to content

Commit

Permalink
[xcvrd] Fix xcvrd crash for RJ45 cable type (#513)
Browse files Browse the repository at this point in the history
Signed-off-by: Vivek Reddy <vkarri@nvidia.com>
  • Loading branch information
vivekrnv authored Jul 23, 2024
1 parent 8c89f6b commit d6a4635
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sonic-xcvrd/tests/test_xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2908,6 +2908,15 @@ def test_wrapper_is_flat_memory(self, mock_chassis):
mock_chassis.get_sfp = MagicMock(side_effect=NotImplementedError)
assert not _wrapper_is_flat_memory(1)

@patch('xcvrd.xcvrd.platform_chassis')
def test_wrapper_is_flat_memory_no_xcvr_api(self, mock_chassis):
mock_object = MagicMock()
mock_object.get_xcvr_api = MagicMock(return_value=None)
mock_chassis.get_sfp = MagicMock(return_value=mock_object)

from xcvrd.xcvrd import _wrapper_is_flat_memory
assert _wrapper_is_flat_memory(1) == True

def test_check_port_in_range(self):
range_str = '1 - 32'
physical_port = 1
Expand Down
2 changes: 2 additions & 0 deletions sonic-xcvrd/xcvrd/xcvrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,8 @@ def _wrapper_is_flat_memory(physical_port):
try:
sfp = platform_chassis.get_sfp(physical_port)
api = sfp.get_xcvr_api()
if not api:
return True
return api.is_flat_memory()
except NotImplementedError:
pass
Expand Down

0 comments on commit d6a4635

Please sign in to comment.