Merge branch 'feature/check_uniqueness_name_of_partitions' into 'master'
partition_table: Check - partition names must be unique See merge request idf/esp-idf!3204
This commit is contained in:
commit
fdabd5e0b1
2 changed files with 22 additions and 0 deletions
|
@ -169,6 +169,19 @@ class PartitionTable(list):
|
||||||
# verify each partition individually
|
# verify each partition individually
|
||||||
for p in self:
|
for p in self:
|
||||||
p.verify()
|
p.verify()
|
||||||
|
|
||||||
|
# check on duplicate name
|
||||||
|
names = [ p.name for p in self ]
|
||||||
|
duplicates = set( n for n in names if names.count(n) > 1 )
|
||||||
|
|
||||||
|
# print sorted duplicate partitions by name
|
||||||
|
if len(duplicates) != 0:
|
||||||
|
print("A list of partitions that have the same name:")
|
||||||
|
for p in sorted(self, key=lambda x:x.name):
|
||||||
|
if len(duplicates.intersection([p.name])) != 0:
|
||||||
|
print("%s" % (p.to_csv()))
|
||||||
|
raise InputError("Partition names must be unique")
|
||||||
|
|
||||||
# check for overlaps
|
# check for overlaps
|
||||||
last = None
|
last = None
|
||||||
for p in sorted(self, key=lambda x:x.offset):
|
for p in sorted(self, key=lambda x:x.offset):
|
||||||
|
|
|
@ -166,6 +166,15 @@ second, app, ota_0, 0x200000, 1M
|
||||||
t = PartitionTable.from_csv(csv)
|
t = PartitionTable.from_csv(csv)
|
||||||
t.verify()
|
t.verify()
|
||||||
|
|
||||||
|
def test_unique_name_fail(self):
|
||||||
|
csv = """
|
||||||
|
first, app, factory, 0x100000, 1M
|
||||||
|
first, app, ota_0, 0x200000, 1M
|
||||||
|
"""
|
||||||
|
with self.assertRaisesRegexp(InputError, "Partition names must be unique"):
|
||||||
|
t = PartitionTable.from_csv(csv)
|
||||||
|
t.verify()
|
||||||
|
|
||||||
class BinaryOutputTests(unittest.TestCase):
|
class BinaryOutputTests(unittest.TestCase):
|
||||||
def test_binary_entry(self):
|
def test_binary_entry(self):
|
||||||
csv = """
|
csv = """
|
||||||
|
|
Loading…
Reference in a new issue