Merge branch 'bugfix/fix_esp32h2_efuse_get_ext_mac_v4.2' into 'release/v4.2'

efuse_table_gen: Fixes wrong joining fields with omitted names  (v4.2)

See merge request espressif/esp-idf!15739
This commit is contained in:
Konstantin Kondrashov 2021-12-14 14:07:39 +00:00
commit 0877949237
2 changed files with 70 additions and 1 deletions

View File

@ -111,9 +111,11 @@ class FuseTable(list):
# fill group
names = [p.field_name for p in res]
duplicates = set(n for n in names if names.count(n) > 1)
if len(duplicates) != 0:
for dname in duplicates:
i_count = 0
for p in res:
if p.field_name != dname:
continue
if len(duplicates.intersection([p.field_name])) != 0:
p.group = str(i_count)
i_count += 1

View File

@ -336,6 +336,73 @@ name4, EFUSE_BLK3, 4,
with self.assertRaisesRegex(efuse_table_gen.InputError, "overlaps"):
two_tables.verify()
def test_two_fields_with_lists(self):
csv = """
MAC_FACTORY, EFUSE_BLK1, 40, 8, Factory MAC addr [0]
, EFUSE_BLK1, 32, 8, Factory MAC addr [1]
, EFUSE_BLK1, 24, 8, Factory MAC addr [2]
, EFUSE_BLK1, 16, 8, Factory MAC addr [3]
, EFUSE_BLK1, 8, 8, Factory MAC addr [4]
, EFUSE_BLK1, 0, 8, Factory MAC addr [5]
MAC_EXT, EFUSE_BLK1, 123, 8, Extend MAC addr [0]
, EFUSE_BLK1, 131, 8, Extend MAC addr [1]
"""
t = efuse_table_gen.FuseTable.from_csv(csv)
t.verify()
self.assertEqual(t[0].field_name, 'MAC_FACTORY')
self.assertEqual(t[0].group, str(0))
self.assertEqual(t[1].field_name, 'MAC_FACTORY')
self.assertEqual(t[1].group, str(1))
self.assertEqual(t[2].field_name, 'MAC_FACTORY')
self.assertEqual(t[2].group, str(2))
self.assertEqual(t[3].field_name, 'MAC_FACTORY')
self.assertEqual(t[3].group, str(3))
self.assertEqual(t[4].field_name, 'MAC_FACTORY')
self.assertEqual(t[4].group, str(4))
self.assertEqual(t[5].field_name, 'MAC_FACTORY')
self.assertEqual(t[5].group, str(5))
self.assertEqual(t[6].field_name, 'MAC_EXT')
self.assertEqual(t[6].group, str(0))
self.assertEqual(t[7].field_name, 'MAC_EXT')
self.assertEqual(t[7].group, str(1))
def test_two_fields_with_lists_and_field_between(self):
csv = """
MAC_FACTORY, EFUSE_BLK1, 40, 8, Factory MAC addr [0]
, EFUSE_BLK1, 32, 8, Factory MAC addr [1]
, EFUSE_BLK1, 24, 8, Factory MAC addr [2]
, EFUSE_BLK1, 16, 8, Factory MAC addr [3]
, EFUSE_BLK1, 8, 8, Factory MAC addr [4]
, EFUSE_BLK1, 0, 8, Factory MAC addr [5]
name2, EFUSE_BLK3, 5, 1, comment
MAC_EXT, EFUSE_BLK1, 123, 8, Extend MAC addr [0]
, EFUSE_BLK1, 131, 8, Extend MAC addr [1]
"""
t = efuse_table_gen.FuseTable.from_csv(csv)
t.verify()
self.assertEqual(t[0].field_name, 'MAC_FACTORY')
self.assertEqual(t[0].group, str(0))
self.assertEqual(t[1].field_name, 'MAC_FACTORY')
self.assertEqual(t[1].group, str(1))
self.assertEqual(t[2].field_name, 'MAC_FACTORY')
self.assertEqual(t[2].group, str(2))
self.assertEqual(t[3].field_name, 'MAC_FACTORY')
self.assertEqual(t[3].group, str(3))
self.assertEqual(t[4].field_name, 'MAC_FACTORY')
self.assertEqual(t[4].group, str(4))
self.assertEqual(t[5].field_name, 'MAC_FACTORY')
self.assertEqual(t[5].group, str(5))
self.assertEqual(t[6].field_name, 'name2')
self.assertEqual(t[7].field_name, 'MAC_EXT')
self.assertEqual(t[7].group, str(0))
self.assertEqual(t[8].field_name, 'MAC_EXT')
self.assertEqual(t[8].group, str(1))
if __name__ == "__main__":
unittest.main()