Skip to content

Commit

Permalink
tests: fix section mapping in test_ukify.py
Browse files Browse the repository at this point in the history
The regexp only worked if the sections were small enough for the size to
start with "0". I have an initrd that is 0x1078ec7e bytes, so the tests
would spuriously fail.
  • Loading branch information
keszybz authored and bluca committed Dec 3, 2023
1 parent 1707d5d commit 8244f39
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ukify/test/test_ukify.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def test_sections(kernel_initrd, tmpdir):
dump = subprocess.check_output(['objdump', '-h', output], text=True)

for sect in 'text osrel cmdline linux initrd uname test'.split():
assert re.search(fr'^\s*\d+\s+.{sect}\s+0', dump, re.MULTILINE)
assert re.search(fr'^\s*\d+\s+\.{sect}\s+[0-9a-f]+', dump, re.MULTILINE)

def test_addon(tmpdir):
output = f'{tmpdir}/addon.efi'
Expand Down Expand Up @@ -499,7 +499,7 @@ def test_addon(tmpdir):
dump = subprocess.check_output(['objdump', '-h', output], text=True)

for sect in 'text cmdline test sbat'.split():
assert re.search(fr'^\s*\d+\s+.{sect}\s+0', dump, re.MULTILINE)
assert re.search(fr'^\s*\d+\s+\.{sect}\s+[0-9a-f]+', dump, re.MULTILINE)

pe = pefile.PE(output, fast_load=True)
found = False
Expand Down Expand Up @@ -694,7 +694,7 @@ def test_pcr_signing(kernel_initrd, tmpdir):
dump = subprocess.check_output(['objdump', '-h', output], text=True)

for sect in 'text osrel cmdline linux initrd uname pcrsig'.split():
assert re.search(fr'^\s*\d+\s+.{sect}\s+0', dump, re.MULTILINE)
assert re.search(fr'^\s*\d+\s+\.{sect}\s+[0-9a-f]+', dump, re.MULTILINE)

# objcopy fails when called without an output argument (EPERM).
# It also fails when called with /dev/null (file truncated).
Expand Down Expand Up @@ -767,7 +767,7 @@ def test_pcr_signing2(kernel_initrd, tmpdir):
dump = subprocess.check_output(['objdump', '-h', output], text=True)

for sect in 'text osrel cmdline linux initrd uname pcrsig'.split():
assert re.search(fr'^\s*\d+\s+.{sect}\s+0', dump, re.MULTILINE)
assert re.search(fr'^\s*\d+\s+\.{sect}\s+[0-9a-f]+', dump, re.MULTILINE)

subprocess.check_call([
'objcopy',
Expand Down

0 comments on commit 8244f39

Please sign in to comment.