Skip to content

Commit edc0169

Browse files
byu343yxieca
authored andcommitted
[decode-syseeprom] Fix setting use_db based on support_eeprom_db (#2270)
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"
1 parent 1542e7a commit edc0169

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

scripts/decode-syseeprom

+2-2
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ def main():
228228

229229
(opts, args) = get_cmdline_opts()
230230

231-
use_db = opts.db and support_eeprom_db
232-
233231
# Get platform name
234232
platform = device_info.get_platform()
235233

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

239+
use_db = opts.db and support_eeprom_db
240+
241241
if opts.mgmtmac:
242242
print_mgmt_mac(use_db)
243243
elif opts.serial:

tests/decode_syseeprom_test.py

+9
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,12 @@ def test_print_model(self, capsys):
192192
decode_syseeprom.print_model(True)
193193
captured = capsys.readouterr()
194194
assert captured.out == 'S6100-ON\n'
195+
196+
@mock.patch('os.geteuid', lambda: 0)
197+
@mock.patch('sonic_py_common.device_info.get_platform', lambda: 'arista')
198+
@mock.patch('decode-syseeprom.read_and_print_eeprom')
199+
@mock.patch('decode-syseeprom.read_eeprom_from_db')
200+
def test_support_platforms_not_db_based(self, mockDbBased, mockNotDbBased):
201+
decode_syseeprom.main()
202+
assert mockNotDbBased.called
203+
assert not mockDbBased.called

0 commit comments

Comments
 (0)