]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mkosi: add support for TEST_SAVE_JOURNAL to integration test wrapper
authorLuca Boccassi <bluca@debian.org>
Mon, 24 Jun 2024 14:20:11 +0000 (15:20 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 25 Jun 2024 10:16:59 +0000 (12:16 +0200)
Same variable and values as supported by the shell suite

test/integration-test-wrapper.py

index b6a16aa3efef876c3f403c10d578299dc704faff..21ec00680f26dce58f55bd0b746afe25d053e70c 100755 (executable)
@@ -61,6 +61,8 @@ def main():
         print(f"TEST_NO_QEMU=1, skipping {args.name}", file=sys.stderr)
         exit(77)
 
+    keep_journal = os.getenv("TEST_SAVE_JOURNAL", "fail")
+
     name = args.name + (f"-{i}" if (i := os.getenv("MESON_TEST_ITERATION")) else "")
 
     dropin = textwrap.dedent(
@@ -152,11 +154,10 @@ def main():
 
     result = subprocess.run(cmd)
 
-    if result.returncode in (args.exit_code, 77):
-        # Do not keep journal files for tests that don't fail.
-        if journal_file:
-            journal_file.unlink(missing_ok=True)
+    if journal_file and (keep_journal == "0" or (result.returncode in (args.exit_code, 77) and keep_journal == "fail")):
+        journal_file.unlink(missing_ok=True)
 
+    if result.returncode in (args.exit_code, 77):
         exit(0 if result.returncode == args.exit_code else 77)
 
     if journal_file: