@@ -418,11 +418,11 @@ def test_check_splash():
418418 with pytest .raises (OSError ):
419419 ukify .check_splash (os .devnull )
420420
421- def test_basic_operation (kernel_initrd , tmpdir ):
421+ def test_basic_operation (kernel_initrd , tmp_path ):
422422 if kernel_initrd is None :
423423 pytest .skip ('linux+initrd not found' )
424424
425- output = f'{ tmpdir } /basic.efi'
425+ output = f'{ tmp_path } /basic.efi'
426426 opts = ukify .parse_args ([
427427 'build' ,
428428 * kernel_initrd ,
@@ -438,11 +438,11 @@ def test_basic_operation(kernel_initrd, tmpdir):
438438 # let's check that objdump likes the resulting file
439439 subprocess .check_output (['objdump' , '-h' , output ])
440440
441- def test_sections (kernel_initrd , tmpdir ):
441+ def test_sections (kernel_initrd , tmp_path ):
442442 if kernel_initrd is None :
443443 pytest .skip ('linux+initrd not found' )
444444
445- output = f'{ tmpdir } /basic.efi'
445+ output = f'{ tmp_path } /basic.efi'
446446 opts = ukify .parse_args ([
447447 'build' ,
448448 * kernel_initrd ,
@@ -466,8 +466,8 @@ def test_sections(kernel_initrd, tmpdir):
466466 for sect in 'text osrel cmdline linux initrd uname test' .split ():
467467 assert re .search (fr'^\s*\d+\s+\.{ sect } \s+[0-9a-f]+' , dump , re .MULTILINE )
468468
469- def test_addon (tmpdir ):
470- output = f'{ tmpdir } /addon.efi'
469+ def test_addon (tmp_path ):
470+ output = f'{ tmp_path } /addon.efi'
471471 args = [
472472 'build' ,
473473 f'--output={ output } ' ,
@@ -529,7 +529,7 @@ def test_uname_scraping(kernel_initrd):
529529 uname = ukify .Uname .scrape (kernel_initrd [1 ])
530530 assert re .match (r'\d+\.\d+\.\d+' , uname )
531531
532- def test_efi_signing_sbsign (kernel_initrd , tmpdir ):
532+ def test_efi_signing_sbsign (kernel_initrd , tmp_path ):
533533 if kernel_initrd is None :
534534 pytest .skip ('linux+initrd not found' )
535535 if not shutil .which ('sbsign' ):
@@ -539,7 +539,7 @@ def test_efi_signing_sbsign(kernel_initrd, tmpdir):
539539 cert = unbase64 (ourdir / 'example.signing.crt.base64' )
540540 key = unbase64 (ourdir / 'example.signing.key.base64' )
541541
542- output = f'{ tmpdir } /signed.efi'
542+ output = f'{ tmp_path } /signed.efi'
543543 opts = ukify .parse_args ([
544544 'build' ,
545545 * kernel_initrd ,
@@ -567,13 +567,13 @@ def test_efi_signing_sbsign(kernel_initrd, tmpdir):
567567
568568 assert 'Signature verification OK' in dump
569569
570- def test_efi_signing_pesign (kernel_initrd , tmpdir ):
570+ def test_efi_signing_pesign (kernel_initrd , tmp_path ):
571571 if kernel_initrd is None :
572572 pytest .skip ('linux+initrd not found' )
573573 if not shutil .which ('pesign' ):
574574 pytest .skip ('pesign not found' )
575575
576- nss_db = f'{ tmpdir } /nss_db'
576+ nss_db = f'{ tmp_path } /nss_db'
577577 name = 'Test_Secureboot'
578578 author = 'systemd'
579579
@@ -583,7 +583,7 @@ def test_efi_signing_pesign(kernel_initrd, tmpdir):
583583 cmd = f'efikeygen -d { nss_db } -S -k -c CN={ author } -n { name } ' .split (' ' )
584584 subprocess .check_call (cmd )
585585
586- output = f'{ tmpdir } /signed.efi'
586+ output = f'{ tmp_path } /signed.efi'
587587 opts = ukify .parse_args ([
588588 'build' ,
589589 * kernel_initrd ,
@@ -610,7 +610,7 @@ def test_efi_signing_pesign(kernel_initrd, tmpdir):
610610
611611 assert f"The signer's common name is { author } " in dump
612612
613- def test_inspect (kernel_initrd , tmpdir , capsys ):
613+ def test_inspect (kernel_initrd , tmp_path , capsys ):
614614 if kernel_initrd is None :
615615 pytest .skip ('linux+initrd not found' )
616616 if not shutil .which ('sbsign' ):
@@ -620,7 +620,7 @@ def test_inspect(kernel_initrd, tmpdir, capsys):
620620 cert = unbase64 (ourdir / 'example.signing.crt.base64' )
621621 key = unbase64 (ourdir / 'example.signing.key.base64' )
622622
623- output = f'{ tmpdir } /signed2.efi'
623+ output = f'{ tmp_path } /signed2.efi'
624624 uname_arg = '1.2.3'
625625 osrel_arg = 'Linux'
626626 cmdline_arg = 'ARG1 ARG2 ARG3'
@@ -656,7 +656,7 @@ def test_inspect(kernel_initrd, tmpdir, capsys):
656656 assert expected_linux in text
657657
658658
659- def test_pcr_signing (kernel_initrd , tmpdir ):
659+ def test_pcr_signing (kernel_initrd , tmp_path ):
660660 if kernel_initrd is None :
661661 pytest .skip ('linux+initrd not found' )
662662 if systemd_measure () is None :
@@ -666,7 +666,7 @@ def test_pcr_signing(kernel_initrd, tmpdir):
666666 pub = unbase64 (ourdir / 'example.tpm2-pcr-public.pem.base64' )
667667 priv = unbase64 (ourdir / 'example.tpm2-pcr-private.pem.base64' )
668668
669- output = f'{ tmpdir } /signed.efi'
669+ output = f'{ tmp_path } /signed.efi'
670670 args = [
671671 'build' ,
672672 * kernel_initrd ,
@@ -703,23 +703,23 @@ def test_pcr_signing(kernel_initrd, tmpdir):
703703 # So let's just call it with a dummy output argument.
704704 subprocess .check_call ([
705705 'objcopy' ,
706- * (f'--dump-section=.{ n } ={ tmpdir } /out.{ n } ' for n in (
706+ * (f'--dump-section=.{ n } ={ tmp_path } /out.{ n } ' for n in (
707707 'pcrpkey' , 'pcrsig' , 'osrel' , 'uname' , 'cmdline' )),
708708 output ,
709- tmpdir / 'dummy' ,
709+ tmp_path / 'dummy' ,
710710 ],
711711 text = True )
712712
713- assert open (tmpdir / 'out.pcrpkey' ).read () == open (pub .name ).read ()
714- assert open (tmpdir / 'out.osrel' ).read () == 'ID=foobar\n '
715- assert open (tmpdir / 'out.uname' ).read () == '1.2.3'
716- assert open (tmpdir / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
717- sig = open (tmpdir / 'out.pcrsig' ).read ()
713+ assert open (tmp_path / 'out.pcrpkey' ).read () == open (pub .name ).read ()
714+ assert open (tmp_path / 'out.osrel' ).read () == 'ID=foobar\n '
715+ assert open (tmp_path / 'out.uname' ).read () == '1.2.3'
716+ assert open (tmp_path / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
717+ sig = open (tmp_path / 'out.pcrsig' ).read ()
718718 sig = json .loads (sig )
719719 assert list (sig .keys ()) == ['sha1' ]
720720 assert len (sig ['sha1' ]) == 4 # four items for four phases
721721
722- def test_pcr_signing2 (kernel_initrd , tmpdir ):
722+ def test_pcr_signing2 (kernel_initrd , tmp_path ):
723723 if kernel_initrd is None :
724724 pytest .skip ('linux+initrd not found' )
725725 if systemd_measure () is None :
@@ -732,10 +732,10 @@ def test_pcr_signing2(kernel_initrd, tmpdir):
732732 priv2 = unbase64 (ourdir / 'example.tpm2-pcr-private2.pem.base64' )
733733
734734 # simulate a microcode file
735- with open (f'{ tmpdir } /microcode' , 'wb' ) as microcode :
735+ with open (f'{ tmp_path } /microcode' , 'wb' ) as microcode :
736736 microcode .write (b'1234567890' )
737737
738- output = f'{ tmpdir } /signed.efi'
738+ output = f'{ tmp_path } /signed.efi'
739739 assert kernel_initrd [0 ] == '--linux'
740740 opts = ukify .parse_args ([
741741 'build' ,
@@ -771,35 +771,35 @@ def test_pcr_signing2(kernel_initrd, tmpdir):
771771
772772 subprocess .check_call ([
773773 'objcopy' ,
774- * (f'--dump-section=.{ n } ={ tmpdir } /out.{ n } ' for n in (
774+ * (f'--dump-section=.{ n } ={ tmp_path } /out.{ n } ' for n in (
775775 'pcrpkey' , 'pcrsig' , 'osrel' , 'uname' , 'cmdline' , 'initrd' )),
776776 output ,
777- tmpdir / 'dummy' ,
777+ tmp_path / 'dummy' ,
778778 ],
779779 text = True )
780780
781- assert open (tmpdir / 'out.pcrpkey' ).read () == open (pub2 .name ).read ()
782- assert open (tmpdir / 'out.osrel' ).read () == 'ID=foobar\n '
783- assert open (tmpdir / 'out.uname' ).read () == '1.2.3'
784- assert open (tmpdir / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
785- assert open (tmpdir / 'out.initrd' , 'rb' ).read (10 ) == b'1234567890'
781+ assert open (tmp_path / 'out.pcrpkey' ).read () == open (pub2 .name ).read ()
782+ assert open (tmp_path / 'out.osrel' ).read () == 'ID=foobar\n '
783+ assert open (tmp_path / 'out.uname' ).read () == '1.2.3'
784+ assert open (tmp_path / 'out.cmdline' ).read () == 'ARG1 ARG2 ARG3'
785+ assert open (tmp_path / 'out.initrd' , 'rb' ).read (10 ) == b'1234567890'
786786
787- sig = open (tmpdir / 'out.pcrsig' ).read ()
787+ sig = open (tmp_path / 'out.pcrsig' ).read ()
788788 sig = json .loads (sig )
789789 assert list (sig .keys ()) == ['sha1' ]
790790 assert len (sig ['sha1' ]) == 6 # six items for six phases paths
791791
792- def test_key_cert_generation (tmpdir ):
792+ def test_key_cert_generation (tmp_path ):
793793 opts = ukify .parse_args ([
794794 'genkey' ,
795- f"--pcr-public-key={ tmpdir / 'pcr1.pub.pem' } " ,
796- f"--pcr-private-key={ tmpdir / 'pcr1.priv.pem' } " ,
795+ f"--pcr-public-key={ tmp_path / 'pcr1.pub.pem' } " ,
796+ f"--pcr-private-key={ tmp_path / 'pcr1.priv.pem' } " ,
797797 '--phases=enter-initrd enter-initrd:leave-initrd' ,
798- f"--pcr-public-key={ tmpdir / 'pcr2.pub.pem' } " ,
799- f"--pcr-private-key={ tmpdir / 'pcr2.priv.pem' } " ,
798+ f"--pcr-public-key={ tmp_path / 'pcr2.pub.pem' } " ,
799+ f"--pcr-private-key={ tmp_path / 'pcr2.priv.pem' } " ,
800800 '--phases=sysinit ready' ,
801- f"--secureboot-private-key={ tmpdir / 'sb.priv.pem' } " ,
802- f"--secureboot-certificate={ tmpdir / 'sb.cert.pem' } " ,
801+ f"--secureboot-private-key={ tmp_path / 'sb.priv.pem' } " ,
802+ f"--secureboot-certificate={ tmp_path / 'sb.cert.pem' } " ,
803803 ])
804804 assert opts .verb == 'genkey'
805805 ukify .check_cert_and_keys_nonexistent (opts )
@@ -811,9 +811,9 @@ def test_key_cert_generation(tmpdir):
811811 if not shutil .which ('openssl' ):
812812 return
813813
814- for key in (tmpdir / 'pcr1.priv.pem' ,
815- tmpdir / 'pcr2.priv.pem' ,
816- tmpdir / 'sb.priv.pem' ):
814+ for key in (tmp_path / 'pcr1.priv.pem' ,
815+ tmp_path / 'pcr2.priv.pem' ,
816+ tmp_path / 'sb.priv.pem' ):
817817 out = subprocess .check_output ([
818818 'openssl' , 'rsa' ,
819819 '-in' , key ,
@@ -823,8 +823,8 @@ def test_key_cert_generation(tmpdir):
823823 assert 'Private-Key' in out
824824 assert '2048 bit' in out
825825
826- for pub in (tmpdir / 'pcr1.pub.pem' ,
827- tmpdir / 'pcr2.pub.pem' ):
826+ for pub in (tmp_path / 'pcr1.pub.pem' ,
827+ tmp_path / 'pcr2.pub.pem' ):
828828 out = subprocess .check_output ([
829829 'openssl' , 'rsa' ,
830830 '-pubin' ,
@@ -837,7 +837,7 @@ def test_key_cert_generation(tmpdir):
837837
838838 out = subprocess .check_output ([
839839 'openssl' , 'x509' ,
840- '-in' , tmpdir / 'sb.cert.pem' ,
840+ '-in' , tmp_path / 'sb.cert.pem' ,
841841 '-text' ,
842842 '-noout' ,
843843 ], text = True )
0 commit comments