Skip to content

Commit d93341f

Browse files
committed
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)
1 parent 197ac7d commit d93341f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/ukify/test/test_ukify.py

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

441+
shutil.rmtree(tmp_path)
442+
441443
def test_sections(kernel_initrd, tmp_path):
442444
if kernel_initrd is None:
443445
pytest.skip('linux+initrd not found')
@@ -466,6 +468,8 @@ def test_sections(kernel_initrd, tmp_path):
466468
for sect in 'text osrel cmdline linux initrd uname test'.split():
467469
assert re.search(fr'^\s*\d+\s+\.{sect}\s+[0-9a-f]+', dump, re.MULTILINE)
468470

471+
shutil.rmtree(tmp_path)
472+
469473
def test_addon(tmp_path):
470474
output = f'{tmp_path}/addon.efi'
471475
args = [
@@ -567,6 +571,8 @@ def test_efi_signing_sbsign(kernel_initrd, tmp_path):
567571

568572
assert 'Signature verification OK' in dump
569573

574+
shutil.rmtree(tmp_path)
575+
570576
def test_efi_signing_pesign(kernel_initrd, tmp_path):
571577
if kernel_initrd is None:
572578
pytest.skip('linux+initrd not found')
@@ -610,6 +616,8 @@ def test_efi_signing_pesign(kernel_initrd, tmp_path):
610616

611617
assert f"The signer's common name is {author}" in dump
612618

619+
shutil.rmtree(tmp_path)
620+
613621
def test_inspect(kernel_initrd, tmp_path, capsys):
614622
if kernel_initrd is None:
615623
pytest.skip('linux+initrd not found')
@@ -655,6 +663,7 @@ def test_inspect(kernel_initrd, tmp_path, capsys):
655663
expected_linux = '.linux:\n size:'
656664
assert expected_linux in text
657665

666+
shutil.rmtree(tmp_path)
658667

659668
def test_pcr_signing(kernel_initrd, tmp_path):
660669
if kernel_initrd is None:
@@ -719,6 +728,8 @@ def test_pcr_signing(kernel_initrd, tmp_path):
719728
assert list(sig.keys()) == ['sha1']
720729
assert len(sig['sha1']) == 4 # four items for four phases
721730

731+
shutil.rmtree(tmp_path)
732+
722733
def test_pcr_signing2(kernel_initrd, tmp_path):
723734
if kernel_initrd is None:
724735
pytest.skip('linux+initrd not found')
@@ -789,6 +800,8 @@ def test_pcr_signing2(kernel_initrd, tmp_path):
789800
assert list(sig.keys()) == ['sha1']
790801
assert len(sig['sha1']) == 6 # six items for six phases paths
791802

803+
shutil.rmtree(tmp_path)
804+
792805
def test_key_cert_generation(tmp_path):
793806
opts = ukify.parse_args([
794807
'genkey',

0 commit comments

Comments
 (0)