test-ukify: skip signing in tests when slow tests are disabled
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.)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user