]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test-ukify: skip signing in tests when slow tests are disabled
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Feb 2024 10:26:53 +0000 (11:26 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 22 Feb 2024 10:37:17 +0000 (11:37 +0100)
I have a large initrd (built with mkosi-initrd) and the test-ukify takes 30 s.
Let's use the usual approach of skipping the slowests tests.

(pytest has marks, and it would be nicer to mark tests with pytest.mark.slow,
and then use "-m 'not slow'" in the meson test invocation. But markers must be
pre-registered, otherwise pytest emits a warning. There are a few ways to
register markers, but they all require "project configuration", but because of
how we invoke pytest, this is hard to do. So let's just use an environment
variable.)

src/test/meson.build
src/ukify/test/test_ukify.py

index ef741388d5524685a26dc4676e08cc7ebee8c835..877005e82f7cce064f69678047e7a7b0b7d886d1 100644 (file)
@@ -14,6 +14,7 @@ test_env = environment()
 test_env.set('SYSTEMD_LANGUAGE_FALLBACK_MAP', language_fallback_map)
 test_env.set('PATH', project_build_root + ':' + path)
 test_env.set('PROJECT_BUILD_ROOT', project_build_root)
+test_env.set('SYSTEMD_SLOW_TESTS', slow_tests ? '1' : '0')
 
 if efi_addon != ''
         test_env.set('EFI_ADDON', efi_addon)
index f50e88d2f49708e15bab571afc90a4fe5b0e8372..ec466393d3a6a200defe175725c991b4b5039aeb 100755 (executable)
@@ -36,6 +36,11 @@ sys.path.append(os.path.dirname(__file__) + '/..')
 import ukify
 
 build_root = os.getenv('PROJECT_BUILD_ROOT')
+try:
+    slow_tests = bool(int(os.getenv('SYSTEMD_SLOW_TESTS', '1')))
+except ValueError:
+    slow_tests = True
+
 arg_tools = ['--tools', build_root] if build_root else []
 
 def systemd_measure():
@@ -531,6 +536,7 @@ def test_uname_scraping(kernel_initrd):
     uname = ukify.Uname.scrape(kernel_initrd[1])
     assert re.match(r'\d+\.\d+\.\d+', uname)
 
+@pytest.mark.skipif(not slow_tests, reason='slow')
 @pytest.mark.parametrize("days", [365*10, None])
 def test_efi_signing_sbsign(days, kernel_initrd, tmp_path):
     if kernel_initrd is None:
@@ -576,6 +582,7 @@ def test_efi_signing_sbsign(days, kernel_initrd, tmp_path):
 
     shutil.rmtree(tmp_path)
 
+@pytest.mark.skipif(not slow_tests, reason='slow')
 def test_efi_signing_pesign(kernel_initrd, tmp_path):
     if kernel_initrd is None:
         pytest.skip('linux+initrd not found')
@@ -635,16 +642,22 @@ def test_inspect(kernel_initrd, tmp_path, capsys):
     uname_arg='1.2.3'
     osrel_arg='Linux'
     cmdline_arg='ARG1 ARG2 ARG3'
-    opts = ukify.parse_args([
+
+    args = [
         'build',
         *kernel_initrd,
         f'--cmdline={cmdline_arg}',
         f'--os-release={osrel_arg}',
         f'--uname={uname_arg}',
         f'--output={output}',
-        f'--secureboot-certificate={cert.name}',
-        f'--secureboot-private-key={key.name}',
-    ])
+    ]
+    if slow_tests:
+        args += [
+            f'--secureboot-certificate={cert.name}',
+            f'--secureboot-private-key={key.name}',
+        ]
+
+    opts = ukify.parse_args(args)
 
     ukify.check_inputs(opts)
     ukify.make_uki(opts)
@@ -668,6 +681,7 @@ def test_inspect(kernel_initrd, tmp_path, capsys):
 
     shutil.rmtree(tmp_path)
 
+@pytest.mark.skipif(not slow_tests, reason='slow')
 def test_pcr_signing(kernel_initrd, tmp_path):
     if kernel_initrd is None:
         pytest.skip('linux+initrd not found')
@@ -734,6 +748,7 @@ def test_pcr_signing(kernel_initrd, tmp_path):
 
     shutil.rmtree(tmp_path)
 
+@pytest.mark.skipif(not slow_tests, reason='slow')
 def test_pcr_signing2(kernel_initrd, tmp_path):
     if kernel_initrd is None:
         pytest.skip('linux+initrd not found')