partition_table: add tests for checking secure boot part size

pull/10984/head
Mahavir Jain 2023-02-06 09:06:32 +05:30
rodzic 51a61fb41c
commit 5002ccd9c3
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 99324EF4A00734E0
1 zmienionych plików z 32 dodań i 0 usunięć

Wyświetl plik

@ -389,6 +389,38 @@ class CommandLineTests(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):
csv = """
# Name,Type, SubType,Offset,Size