Skip to content

Commit

Permalink
Merge branch 'master' into optoe_write_timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
mihirpat1 authored Dec 18, 2023
2 parents ac0d84c + 0f72932 commit c6fb499
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion sonic_platform_base/sonic_sfp/sfputilhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def read_porttab_mappings(self, porttabfile, asic_inst=0):
self.logical_to_asic[intf_name] = asic_inst

self.logical.extend(logical)
self.logical = list(set(self.logical))
self.logical = list(OrderedDict.fromkeys(self.logical).keys())
self.logical_to_physical.update(logical_to_physical)
self.physical_to_logical.update(physical_to_logical)

Expand Down
19 changes: 11 additions & 8 deletions tests/sfputilhelper_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,11 @@ def test_read_port_mappings(self):
sfputil_helper.read_porttab_mappings(self.port_config_file, 0)

logical_port_list = sfputil_helper.logical

assert len(logical_port_list) == len(PORT_LIST)

for logical_port_name in logical_port_list:
assert logical_port_name in PORT_LIST
for logical_port, port in zip(logical_port_list, PORT_LIST):
assert logical_port == port


@mock.patch('portconfig.get_hwsku_file_name', mock.MagicMock(return_value=hwsku_json_file))
Expand All @@ -90,28 +91,30 @@ def test_read_all_port_mappings(self):
sfputil_helper = sfputilhelper.SfpUtilHelper()
sfputil_helper.logical = []
sfputil_helper.logical_to_physical = {}
sfputil_helper.physical_to_logica = {}
sfputil_helper.physical_to_logical = {}
sfputil_helper.read_all_porttab_mappings(self.platform_dir, 2)
logical_port_list = sfputil_helper.logical

assert len(logical_port_list) == len(PORT_LIST)
for logical_port_name in logical_port_list:
assert logical_port_name in PORT_LIST

for logical_port, port in zip(logical_port_list, PORT_LIST):
assert logical_port == port

assert sfputil_helper.logical_to_physical == LOGICAL_TO_PHYSICAL
assert sfputil_helper.physical_to_logical == PHYSICAL_TO_LOGICAL

# test platform.json case

sfputil_helper.logical = []
sfputil_helper.logical_to_physical = {}
sfputil_helper.physical_to_logica = {}
sfputil_helper.physical_to_logical = {}
sfputil_helper.read_all_porttab_mappings(self.platform_json_dir, 2)
logical_port_list = sfputil_helper.logical

assert len(logical_port_list) == len(PORT_LIST)

for logical_port_name in logical_port_list:
assert logical_port_name in PORT_LIST
for logical_port, port in zip(logical_port_list, PORT_LIST):
assert logical_port == port

assert sfputil_helper.logical_to_physical == LOGICAL_TO_PHYSICAL
assert sfputil_helper.physical_to_logical == PHYSICAL_TO_LOGICAL

0 comments on commit c6fb499

Please sign in to comment.