Skip to content

Commit

Permalink
fixup! WIP: test: Run integration tests with mkosi-built image
Browse files Browse the repository at this point in the history
  • Loading branch information
richardmaw-codethink committed Feb 13, 2024
1 parent 03392ee commit 882249f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 2 additions & 0 deletions mkosi.images/system/mkosi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Dependencies=
app1
conf0
testsuite-04-journal-interactive-debug
testsuite-13-container-template

[Output]
@Format=directory
Expand Down Expand Up @@ -38,6 +39,7 @@ ExtraTrees=
../../test/test-journals:/usr/test-journals
../../mkosi.crt:/usr/lib/verity.d/mkosi.crt
%O/testsuite-04-journal-interactive-debug.raw:/usr/share/testsuite-04-journal-interactive-debug.raw
%O/testsuite-13-container-template.raw:/usr/share/testsuite-13-container-template.raw

Packages=
acl
Expand Down
35 changes: 19 additions & 16 deletions test/integration_test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,22 +191,25 @@ def run_mkosi(mkosi_args, **kwargs):
for image in summary['Images']
if image['Image'] == args.mkosi_image_name][0]
log.debug(f"Discovered disk image path {image_path}")
with dissect_mount(image_path) as mountpoint:
mountpoint = Path(mountpoint)

if hook is not None:
log.debug("Running check_result hook")
console_log.seek(0)
hook.check_result(mountpoint, console_log)

if not (mountpoint / "testok").exists():
log.debug("Test failed, running journalctl")
run_mkosi(['journalctl',
'--boot',
'--unit', args.test_unit_name,
])
exit(1)

try:
with dissect_mount(image_path) as mountpoint:
mountpoint = Path(mountpoint)

if hook is not None:
log.debug("Running check_result hook")
console_log.seek(0)
hook.check_result(mountpoint, console_log)

if not (mountpoint / "testok").exists():
log.debug("Test failed, /testok not present")
exit(1)
except BaseException:
log.debug("Attempting journalctl to discover test failure")
run_mkosi(['journalctl',
'--boot',
'--unit', args.test_unit_name,
])
else:
log.debug("Test succeeded, cleaning up")
rmtree(per_test_output_dir)

Expand Down
4 changes: 1 addition & 3 deletions test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,6 @@ endif
############################################################

if get_option('integration-tests') != false
copy_mkosi_output = find_program('copy-mkosi-output.sh')
#integration_test_wrapper = find_program('integration-test-wrapper.sh')
integration_test_wrapper = find_program('integration_test_wrapper.py')
integration_tests = {
'01': 'TEST-01-BASIC',
Expand All @@ -347,7 +345,7 @@ if get_option('integration-tests') != false
'07': 'TEST-07-PID1',
'08': 'TEST-08-INITRD',
'09': 'TEST-09-REBOOT',
#'13': 'TEST-13-NSPAWN', # requires customisation
'13': 'TEST-13-NSPAWN',
'15': 'TEST-15-DROPIN', # requires writable /usr, configured to not run under qemu
'16': 'TEST-16-EXTEND-TIMEOUT', # unclear why NO_QEMU
'17': 'TEST-17-UDEV', # Can be flaky when overloaded if timeout abort test is slow
Expand Down

0 comments on commit 882249f

Please sign in to comment.