From abb4076e4e1a6946485ae4a3834273e13a945bb3 Mon Sep 17 00:00:00 2001 From: ckyrouac Date: Thu, 8 Oct 2026 15:20:17 -0400 Subject: [PATCH] tmt: Print journals for failed units Include each failed unit's journal in test output to make failures easier to diagnose. Assisted-by: AI Signed-off-by: ckyrouac --- .../readonly/014-test-no-failed-units.nu | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tmt/tests/booted/readonly/014-test-no-failed-units.nu b/tmt/tests/booted/readonly/014-test-no-failed-units.nu index af71c86c9..8a4ca04ae 100644 --- a/tmt/tests/booted/readonly/014-test-no-failed-units.nu +++ b/tmt/tests/booted/readonly/014-test-no-failed-units.nu @@ -36,6 +36,27 @@ let failed = if $selinux_enabled { if ($failed | length) > 0 { print $"Failed units:\n($failed | str join "\n")" + for unit in ($failed | each { |l| $l | split row " " | first }) { + print $"Journal for ($unit):" + let journal = (try { + do { ^journalctl --boot --unit $unit --no-pager } | complete + } catch {|e| + null + }) + if $journal == null { + print "# Unable to collect journal output" + } else { + if ($journal.stdout | str trim) != "" { + print $journal.stdout + } + if ($journal.stderr | str trim) != "" { + print $"journalctl stderr: ($journal.stderr)" + } + if $journal.exit_code != 0 { + print $"journalctl exited with status ($journal.exit_code)" + } + } + } assert equal ($failed | length) 0 "Expected zero failed systemd-*/bootc-* units" }