@@ -411,11 +411,11 @@ def test_check_splash():
411411 with pytest .raises (OSError ):
412412 ukify .check_splash (os .devnull )
413413
414- def test_basic_operation (kernel_initrd , tmpdir ):
414+ def test_basic_operation (kernel_initrd , tmp_path ):
415415 if kernel_initrd is None :
416416 pytest .skip ('linux+initrd not found' )
417417
418- output = f'{ tmpdir } /basic.efi'
418+ output = f'{ tmp_path } /basic.efi'
419419 opts = ukify .parse_args ([
420420 'build' ,
421421 * kernel_initrd ,
@@ -431,11 +431,11 @@ def test_basic_operation(kernel_initrd, tmpdir):
431431 # let's check that objdump likes the resulting file
432432 subprocess .check_output (['objdump' , '-h' , output ])
433433
434- def test_sections (kernel_initrd , tmpdir ):
434+ def test_sections (kernel_initrd , tmp_path ):
435435 if kernel_initrd is None :
436436 pytest .skip ('linux+initrd not found' )
437437
438- output = f'{ tmpdir } /basic.efi'
438+ output = f'{ tmp_path } /basic.efi'
439439 opts = ukify .parse_args ([
440440 'build' ,
441441 * kernel_initrd ,
@@ -459,8 +459,8 @@ def test_sections(kernel_initrd, tmpdir):
459459 for sect in 'text osrel cmdline linux initrd uname test' .split ():
460460 assert re .search (fr'^\s*\d+\s+.{ sect } \s+0' , dump , re .MULTILINE )
461461
462- def test_addon (tmpdir ):
463- output = f'{ tmpdir } /addon.efi'
462+ def test_addon (tmp_path ):
463+ output = f'{ tmp_path } /addon.efi'
464464 args = [
465465 'build' ,
466466 f'--output={ output } ' ,
@@ -522,7 +522,7 @@ def test_uname_scraping(kernel_initrd):
522522 uname = ukify .Uname .scrape (kernel_initrd [1 ])
523523 assert re .match (r'\d+\.\d+\.\d+' , uname )
524524
525- def test_efi_signing_sbsign (kernel_initrd , tmpdir ):
525+ def test_efi_signing_sbsign (kernel_initrd , tmp_path ):
526526 if kernel_initrd is None :
527527 pytest .skip ('linux+initrd not found' )
528528 if not shutil .which ('sbsign' ):
@@ -532,7 +532,7 @@ def test_efi_signing_sbsign(kernel_initrd, tmpdir):
532532 cert = unbase64 (ourdir / 'example.signing.crt.base64' )
533533 key = unbase64 (ourdir / 'example.signing.key.base64' )
534534
535- output = f'{ tmpdir } /signed.efi'
535+ output = f'{ tmp_path } /signed.efi'
536536 opts = ukify .parse_args ([
537537 'build' ,
538538 * kernel_initrd ,
@@ -560,13 +560,13 @@ def test_efi_signing_sbsign(kernel_initrd, tmpdir):
560560
561561 assert 'Signature verification OK' in dump
562562
563- def test_efi_signing_pesign (kernel_initrd , tmpdir ):
563+ def test_efi_signing_pesign (kernel_initrd , tmp_path ):
564564 if kernel_initrd is None :
565565 pytest .skip ('linux+initrd not found' )
566566 if not shutil .which ('pesign' ):
567567 pytest .skip ('pesign not found' )
568568
569- nss_db = f'{ tmpdir } /nss_db'
569+ nss_db = f'{ tmp_path } /nss_db'
570570 name = 'Test_Secureboot'
571571 author = 'systemd'
572572
@@ -576,7 +576,7 @@ def test_efi_signing_pesign(kernel_initrd, tmpdir):
576576 cmd = f'efikeygen -d { nss_db } -S -k -c CN={ author } -n { name } ' .split (' ' )
577577 subprocess .check_call (cmd )
578578
579- output = f'{ tmpdir } /signed.efi'
579+ output = f'{ tmp_path } /signed.efi'
580580 opts = ukify .parse_args ([
581581 'build' ,
582582 * kernel_initrd ,
@@ -603,7 +603,7 @@ def test_efi_signing_pesign(kernel_initrd, tmpdir):
603603
604604 assert f"The signer's common name is { author } " in dump
605605
606- def test_pcr_signing (kernel_initrd , tmpdir ):
606+ def test_pcr_signing (kernel_initrd , tmp_path ):
607607 if kernel_initrd is None :
608608 pytest .skip ('linux+initrd not found' )
609609 if systemd_measure () is None :
@@ -613,7 +613,7 @@ def test_pcr_signing(kernel_initrd, tmpdir):
613613 pub = unbase64 (ourdir / 'example.tpm2-pcr-public.pem.base64' )
614614 priv = unbase64 (ourdir / 'example.tpm2-pcr-private.pem.base64' )
615615
616- output = f'{ tmpdir } /signed.efi'
616+ output = f'{ tmp_path } /signed.efi'
617617 args = [
618618 'build' ,
619619 * kernel_initrd ,
@@ -650,23 +650,23 @@ def test_pcr_signing(kernel_initrd, tmpdir):
650650 # So let's just call it with a dummy output argument.
651651 subprocess .check_call ([
652652 'objcopy' ,
653- * (f'--dump-section=.{ n } ={ tmpdir } /out.{ n } ' for n in (
653+ * (f'--dump-section=.{ n } ={ tmp_path } /out.{ n } ' for n in (
654654 'pcrpkey' , 'pcrsig' , 'osrel' , 'uname' , 'cmdline' )),
655655 output ,
656- tmpdir / 'dummy' ,
656+ tmp_path / 'dummy' ,
657657 ],
658658 text = True )
659659
660- assert open (tmpdir / 'out.pcrpkey' ).read () == open (pub .name ).read ()
661- assert open (tmpdir / 'out.osrel' ).read () == 'ID=foobar\n '
662- assert open (tmpdir / 'out.uname' ).read () == '1.2.3'
663- assert open (tmpdir / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
664- sig = open (tmpdir / 'out.pcrsig' ).read ()
660+ assert open (tmp_path / 'out.pcrpkey' ).read () == open (pub .name ).read ()
661+ assert open (tmp_path / 'out.osrel' ).read () == 'ID=foobar\n '
662+ assert open (tmp_path / 'out.uname' ).read () == '1.2.3'
663+ assert open (tmp_path / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
664+ sig = open (tmp_path / 'out.pcrsig' ).read ()
665665 sig = json .loads (sig )
666666 assert list (sig .keys ()) == ['sha1' ]
667667 assert len (sig ['sha1' ]) == 4 # four items for four phases
668668
669- def test_pcr_signing2 (kernel_initrd , tmpdir ):
669+ def test_pcr_signing2 (kernel_initrd , tmp_path ):
670670 if kernel_initrd is None :
671671 pytest .skip ('linux+initrd not found' )
672672 if systemd_measure () is None :
@@ -679,10 +679,10 @@ def test_pcr_signing2(kernel_initrd, tmpdir):
679679 priv2 = unbase64 (ourdir / 'example.tpm2-pcr-private2.pem.base64' )
680680
681681 # simulate a microcode file
682- with open (f'{ tmpdir } /microcode' , 'wb' ) as microcode :
682+ with open (f'{ tmp_path } /microcode' , 'wb' ) as microcode :
683683 microcode .write (b'1234567890' )
684684
685- output = f'{ tmpdir } /signed.efi'
685+ output = f'{ tmp_path } /signed.efi'
686686 assert kernel_initrd [0 ] == '--linux'
687687 opts = ukify .parse_args ([
688688 'build' ,
@@ -718,35 +718,35 @@ def test_pcr_signing2(kernel_initrd, tmpdir):
718718
719719 subprocess .check_call ([
720720 'objcopy' ,
721- * (f'--dump-section=.{ n } ={ tmpdir } /out.{ n } ' for n in (
721+ * (f'--dump-section=.{ n } ={ tmp_path } /out.{ n } ' for n in (
722722 'pcrpkey' , 'pcrsig' , 'osrel' , 'uname' , 'cmdline' , 'initrd' )),
723723 output ,
724- tmpdir / 'dummy' ,
724+ tmp_path / 'dummy' ,
725725 ],
726726 text = True )
727727
728- assert open (tmpdir / 'out.pcrpkey' ).read () == open (pub2 .name ).read ()
729- assert open (tmpdir / 'out.osrel' ).read () == 'ID=foobar\n '
730- assert open (tmpdir / 'out.uname' ).read () == '1.2.3'
731- assert open (tmpdir / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
732- assert open (tmpdir / 'out.initrd' , 'rb' ).read (10 ) == b'1234567890'
728+ assert open (tmp_path / 'out.pcrpkey' ).read () == open (pub2 .name ).read ()
729+ assert open (tmp_path / 'out.osrel' ).read () == 'ID=foobar\n '
730+ assert open (tmp_path / 'out.uname' ).read () == '1.2.3'
731+ assert open (tmp_path / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
732+ assert open (tmp_path / 'out.initrd' , 'rb' ).read (10 ) == b'1234567890'
733733
734- sig = open (tmpdir / 'out.pcrsig' ).read ()
734+ sig = open (tmp_path / 'out.pcrsig' ).read ()
735735 sig = json .loads (sig )
736736 assert list (sig .keys ()) == ['sha1' ]
737737 assert len (sig ['sha1' ]) == 6 # six items for six phases paths
738738
739- def test_key_cert_generation (tmpdir ):
739+ def test_key_cert_generation (tmp_path ):
740740 opts = ukify .parse_args ([
741741 'genkey' ,
742- f"--pcr-public-key={ tmpdir / 'pcr1.pub.pem' } " ,
743- f"--pcr-private-key={ tmpdir / 'pcr1.priv.pem' } " ,
742+ f"--pcr-public-key={ tmp_path / 'pcr1.pub.pem' } " ,
743+ f"--pcr-private-key={ tmp_path / 'pcr1.priv.pem' } " ,
744744 '--phases=enter-initrd enter-initrd:leave-initrd' ,
745- f"--pcr-public-key={ tmpdir / 'pcr2.pub.pem' } " ,
746- f"--pcr-private-key={ tmpdir / 'pcr2.priv.pem' } " ,
745+ f"--pcr-public-key={ tmp_path / 'pcr2.pub.pem' } " ,
746+ f"--pcr-private-key={ tmp_path / 'pcr2.priv.pem' } " ,
747747 '--phases=sysinit ready' ,
748- f"--secureboot-private-key={ tmpdir / 'sb.priv.pem' } " ,
749- f"--secureboot-certificate={ tmpdir / 'sb.cert.pem' } " ,
748+ f"--secureboot-private-key={ tmp_path / 'sb.priv.pem' } " ,
749+ f"--secureboot-certificate={ tmp_path / 'sb.cert.pem' } " ,
750750 ])
751751 assert opts .verb == 'genkey'
752752 ukify .check_cert_and_keys_nonexistent (opts )
@@ -758,9 +758,9 @@ def test_key_cert_generation(tmpdir):
758758 if not shutil .which ('openssl' ):
759759 return
760760
761- for key in (tmpdir / 'pcr1.priv.pem' ,
762- tmpdir / 'pcr2.priv.pem' ,
763- tmpdir / 'sb.priv.pem' ):
761+ for key in (tmp_path / 'pcr1.priv.pem' ,
762+ tmp_path / 'pcr2.priv.pem' ,
763+ tmp_path / 'sb.priv.pem' ):
764764 out = subprocess .check_output ([
765765 'openssl' , 'rsa' ,
766766 '-in' , key ,
@@ -770,8 +770,8 @@ def test_key_cert_generation(tmpdir):
770770 assert 'Private-Key' in out
771771 assert '2048 bit' in out
772772
773- for pub in (tmpdir / 'pcr1.pub.pem' ,
774- tmpdir / 'pcr2.pub.pem' ):
773+ for pub in (tmp_path / 'pcr1.pub.pem' ,
774+ tmp_path / 'pcr2.pub.pem' ):
775775 out = subprocess .check_output ([
776776 'openssl' , 'rsa' ,
777777 '-pubin' ,
@@ -784,7 +784,7 @@ def test_key_cert_generation(tmpdir):
784784
785785 out = subprocess .check_output ([
786786 'openssl' , 'x509' ,
787- '-in' , tmpdir / 'sb.cert.pem' ,
787+ '-in' , tmp_path / 'sb.cert.pem' ,
788788 '-text' ,
789789 '-noout' ,
790790 ], text = True )
0 commit comments