From: Peter Tatrai <[email protected]> The failure summary path assumed the unsuffixed bootlog file always exists and unconditionally opened it.
This is not guaranteed when SERIAL_CONSOLES has fewer than two entries (including empty), where qemurunner can produce only bootlog suffix variants (for example .2 or .stdout). On test failures, collect snippets from all existing files matching bootlog and bootlog.* and prefix each snippet with its filename. Also skip creating a symlink for a missing bootlog path. This prevents FileNotFoundError from masking the original test failure and improves diagnostics across qemu serial configurations. Signed-off-by: Peter Tatrai <[email protected]> --- meta/classes-recipe/testimage.bbclass | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass index 9902b8a568..0f34d551e9 100644 --- a/meta/classes-recipe/testimage.bbclass +++ b/meta/classes-recipe/testimage.bbclass @@ -186,6 +186,7 @@ def get_testimage_boot_patterns(d): def testimage_main(d): import os + import glob import json import signal import logging @@ -409,15 +410,33 @@ def testimage_main(d): # Copy additional logs to tmp/log/oeqa so it's easier to find them targetdir = os.path.join(get_json_result_dir(d), d.getVar("PN")) os.makedirs(targetdir, exist_ok=True) - os.symlink(bootlog, os.path.join(targetdir, os.path.basename(bootlog))) + if os.path.exists(bootlog): + os.symlink(bootlog, os.path.join(targetdir, os.path.basename(bootlog))) + else: + bb.note("testimage: boot log not found at %s" % bootlog) + os.symlink(d.getVar("BB_LOGFILE"), os.path.join(targetdir, os.path.basename(d.getVar("BB_LOGFILE") + "." + d.getVar('DATETIME')))) 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)) + bootlog_files = [] + for candidate in [bootlog] + sorted(glob.glob(bootlog + ".*")): + if os.path.exists(candidate) and candidate not in bootlog_files: + bootlog_files.append(candidate) + + if bootlog_files: + snippets = [] + for bootlog_file in bootlog_files: + try: + with open(bootlog_file, 'r') as bootlogfile: + bootlines = "".join(bootlogfile.readlines()[-20:]) + except OSError as err: + bootlines = "<failed to read %s: %s>\n" % (bootlog_file, err) + snippets.append("--- %s ---\n%s" % (os.path.basename(bootlog_file), bootlines)) + bb.plain('%s - FAILED - Last lines of QEMU boot logs:\n%s' % (pn, "\n".join(snippets))) + else: + bb.plain('%s - FAILED - QEMU boot logs not available at %s or %s.*' % (pn, bootlog, bootlog)) bb.error('%s - FAILED - also check the logs in %s' % (pn, d.getVar("LOG_DIR")), forcelog=True) def get_runtime_paths(d): -- 2.39.5
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#241160): https://lists.openembedded.org/g/openembedded-core/message/241160 Mute This Topic: https://lists.openembedded.org/mt/120312637/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
