]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tests: fix section mapping in test_ukify.py
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 2 Dec 2023 09:26:05 +0000 (10:26 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 3 Dec 2023 12:34:43 +0000 (12:34 +0000)
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.

src/ukify/test/test_ukify.py

index b12c09d4bf9207b046539ab94723fd3ead415776..e85171b0e9b9776bc76d1d295e2ec4804f04efb0 100755 (executable)
@@ -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'
@@ -499,7 +499,7 @@ baz,3
     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
@@ -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).
@@ -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',