mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
partition_table: add tests for checking secure boot part size
This commit is contained in:
parent
33568182d4
commit
e532de9aa5
@ -389,6 +389,38 @@ class CommandLineTests(Py23TestCase):
|
|||||||
|
|
||||||
class VerificationTests(Py23TestCase):
|
class VerificationTests(Py23TestCase):
|
||||||
|
|
||||||
|
def _run_genesp32(self, csvcontents, args):
|
||||||
|
csvpath = tempfile.mktemp()
|
||||||
|
with open(csvpath, 'w') as f:
|
||||||
|
f.write(csvcontents)
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output([sys.executable, '../gen_esp32part.py', csvpath] + args, stderr=subprocess.STDOUT)
|
||||||
|
return output.strip()
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
return e.output.strip()
|
||||||
|
finally:
|
||||||
|
os.remove(csvpath)
|
||||||
|
|
||||||
|
def test_check_secure_app_size(self):
|
||||||
|
sample_csv = """
|
||||||
|
ota_0, app, ota_0, , 0x101000
|
||||||
|
ota_1, app, ota_1, , 0x100800
|
||||||
|
"""
|
||||||
|
|
||||||
|
def rge(args):
|
||||||
|
return self._run_genesp32(sample_csv, args)
|
||||||
|
|
||||||
|
# Valid test that would pass with the above partition table
|
||||||
|
partfile = tempfile.mktemp()
|
||||||
|
self.assertEqual(rge([partfile]), b'Parsing CSV input...\nVerifying table...')
|
||||||
|
os.remove(partfile)
|
||||||
|
# Failure case 1, incorrect ota_0 partition size
|
||||||
|
self.assertEqual(rge(['-q', '--secure', 'v1']),
|
||||||
|
b'Partition ota_0 invalid: Size 0x101000 is not aligned to 0x10000')
|
||||||
|
# Failure case 2, incorrect ota_1 partition size
|
||||||
|
self.assertEqual(rge(['-q', '--secure', 'v2']),
|
||||||
|
b'Partition ota_1 invalid: Size 0x100800 is not aligned to 0x1000')
|
||||||
|
|
||||||
def test_bad_alignment(self):
|
def test_bad_alignment(self):
|
||||||
csv = """
|
csv = """
|
||||||
# Name,Type, SubType,Offset,Size
|
# Name,Type, SubType,Offset,Size
|
||||||
|
Loading…
x
Reference in New Issue
Block a user