Skip to content

Commit

Permalink
[decode-syseeprom] Fix setting use_db based on support_eeprom_db (#2270)
Browse files Browse the repository at this point in the history
What I did
Set use_db after support_eeprom_db is determined. The issue was affecting platform Arista platforms, where db is not used for syseeprom.

How to verify it
Verified on dut by running "show platform syseeprom" and "decode-syseeprom -d"
  • Loading branch information
byu343 authored and yxieca committed Sep 1, 2022
1 parent 1542e7a commit edc0169
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/decode-syseeprom
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ def main():

(opts, args) = get_cmdline_opts()

use_db = opts.db and support_eeprom_db

# Get platform name
platform = device_info.get_platform()

Expand All @@ -238,6 +236,8 @@ def main():
if any(re.match(p, platform) for p in platforms_without_eeprom_db):
support_eeprom_db = False

use_db = opts.db and support_eeprom_db

if opts.mgmtmac:
print_mgmt_mac(use_db)
elif opts.serial:
Expand Down
9 changes: 9 additions & 0 deletions tests/decode_syseeprom_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,12 @@ def test_print_model(self, capsys):
decode_syseeprom.print_model(True)
captured = capsys.readouterr()
assert captured.out == 'S6100-ON\n'

@mock.patch('os.geteuid', lambda: 0)
@mock.patch('sonic_py_common.device_info.get_platform', lambda: 'arista')
@mock.patch('decode-syseeprom.read_and_print_eeprom')
@mock.patch('decode-syseeprom.read_eeprom_from_db')
def test_support_platforms_not_db_based(self, mockDbBased, mockNotDbBased):
decode_syseeprom.main()
assert mockNotDbBased.called
assert not mockDbBased.called

0 comments on commit edc0169

Please sign in to comment.