Skip to content

Commit 2eed4fc

Browse files
keszybzbluca
authored andcommitted
test_ukify: explicitly remove big temporary directories
pytest intentionally keeps around a limited number of the previous test temporary directories [1]. This is generally OK, but in our tests that generate initrds, we create a few very large files (both the initrd and kernel in a few copies), which quickly adds up. I had a particularly large initrd (because of some mkosi-initrd shenanigans), and I unded up with dozens of gigabytes of temporary files from the tests. Let's just nuke the dirs where we write kernel data. [1] pytest-dev/pytest#543 (cherry picked from commit ef0a69e) (cherry picked from commit d93341f)
1 parent f922e2a commit 2eed4fc

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/ukify/test/test_ukify.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,8 @@ def test_basic_operation(kernel_initrd, tmp_path):
431431
# let's check that objdump likes the resulting file
432432
subprocess.check_output(['objdump', '-h', output])
433433

434+
shutil.rmtree(tmp_path)
435+
434436
def test_sections(kernel_initrd, tmp_path):
435437
if kernel_initrd is None:
436438
pytest.skip('linux+initrd not found')
@@ -459,6 +461,8 @@ def test_sections(kernel_initrd, tmp_path):
459461
for sect in 'text osrel cmdline linux initrd uname test'.split():
460462
assert re.search(fr'^\s*\d+\s+.{sect}\s+0', dump, re.MULTILINE)
461463

464+
shutil.rmtree(tmp_path)
465+
462466
def test_addon(tmp_path):
463467
output = f'{tmp_path}/addon.efi'
464468
args = [
@@ -560,6 +564,8 @@ def test_efi_signing_sbsign(kernel_initrd, tmp_path):
560564

561565
assert 'Signature verification OK' in dump
562566

567+
shutil.rmtree(tmp_path)
568+
563569
def test_efi_signing_pesign(kernel_initrd, tmp_path):
564570
if kernel_initrd is None:
565571
pytest.skip('linux+initrd not found')
@@ -603,6 +609,8 @@ def test_efi_signing_pesign(kernel_initrd, tmp_path):
603609

604610
assert f"The signer's common name is {author}" in dump
605611

612+
shutil.rmtree(tmp_path)
613+
606614
def test_pcr_signing(kernel_initrd, tmp_path):
607615
if kernel_initrd is None:
608616
pytest.skip('linux+initrd not found')
@@ -666,6 +674,8 @@ def test_pcr_signing(kernel_initrd, tmp_path):
666674
assert list(sig.keys()) == ['sha1']
667675
assert len(sig['sha1']) == 4 # four items for four phases
668676

677+
shutil.rmtree(tmp_path)
678+
669679
def test_pcr_signing2(kernel_initrd, tmp_path):
670680
if kernel_initrd is None:
671681
pytest.skip('linux+initrd not found')
@@ -736,6 +746,8 @@ def test_pcr_signing2(kernel_initrd, tmp_path):
736746
assert list(sig.keys()) == ['sha1']
737747
assert len(sig['sha1']) == 6 # six items for six phases paths
738748

749+
shutil.rmtree(tmp_path)
750+
739751
def test_key_cert_generation(tmp_path):
740752
opts = ukify.parse_args([
741753
'genkey',

0 commit comments

Comments
 (0)