diff mbox series

[v2] testimage: Print last lines of kernel log on test fail

Message ID 20260108-mathieu-oeqa-15999-fixes-v2-1-8a8bc2d3ec7b@bootlin.com
State Under Review
Headers show
Series [v2] testimage: Print last lines of kernel log on test fail | expand

Commit Message

Mathieu Dubois-Briand Jan. 8, 2026, 1:54 p.m. UTC
Testimage test fails are often a consequence of issues inside of the
virtual machine, such as the OOM killer firing. Showing the last kernel
log lines on the main log output should help to debug these fails.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
---
These two patches have been sitting in my branch for a few weeks now,
trying to address a test timeout bug entry [1].

[1]: https://bugzilla.yoctoproject.org/show_bug.cgi?id=15999
---
Changes in v2:
- Fixing the kernel log patch, so the failure message is printed last.
- v1 of the test timeout patch was merged, so this series is down to
  only 1 patch.
- Link to v1: https://lore.kernel.org/r/20251229-mathieu-oeqa-15999-fixes-v1-0-b0681fa259a6@bootlin.com
---
 meta/classes-recipe/testimage.bbclass | 3 +++
 1 file changed, 3 insertions(+)


---
base-commit: 235e6d49e5888ad04416219e10b6df91a738661a
change-id: 20251229-mathieu-oeqa-15999-fixes-885a5d52fa88

Best regards,
diff mbox series

Patch

diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass
index 844c0f19ad02..b8685bc2b136 100644
--- a/meta/classes-recipe/testimage.bbclass
+++ b/meta/classes-recipe/testimage.bbclass
@@ -412,6 +412,9 @@  def testimage_main(d):
     if not results or not complete:
         bb.error('%s - FAILED - tests were interrupted during execution, check the logs in %s' % (pn, d.getVar("LOG_DIR")), forcelog=True)
     if results and not results.wasSuccessful():
+        with open(bootlog, 'r') as bootlogfile:
+            bootlines = "".join(bootlogfile.readlines()[-20:])
+        bb.plain('%s - FAILED - Last lines of QEMU boot log:\n%s' % (pn, bootlines))
         bb.error('%s - FAILED - also check the logs in %s' % (pn, d.getVar("LOG_DIR")), forcelog=True)
 
 def get_runtime_paths(d):