From: Peter Tatrai <[email protected]> QemuRunner writes boot console output to logfile + '.2' (the primary serial port). The primary logfile path (without extension) is used for the secondary serial port and may not exist if QEMU does not open it.
testimage_main crashed with FileNotFoundError at open(bootlog) when results.wasSuccessful() returned False, because the file was absent. Fall back to the '.2' variant when the primary file does not exist. Wrap open() in a try/except OSError so a missing log emits a warning instead of aborting the task. Signed-off-by: Peter Tatrai <[email protected]> --- meta/classes-recipe/testimage.bbclass | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/meta/classes-recipe/testimage.bbclass b/meta/classes-recipe/testimage.bbclass index 9902b8a568..1af060342f 100644 --- a/meta/classes-recipe/testimage.bbclass +++ b/meta/classes-recipe/testimage.bbclass @@ -415,9 +415,14 @@ 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)) + # QemuRunner writes boot output to bootlog + ".2"; the primary file may not exist + bootlog_actual = bootlog if os.path.exists(bootlog) else bootlog + ".2" + try: + with open(bootlog_actual, 'r') as bootlogfile: + bootlines = "".join(bootlogfile.readlines()[-20:]) + bb.plain('%s - FAILED - Last lines of QEMU boot log:\n%s' % (pn, bootlines)) + except OSError as e: + bb.warn('%s - could not read boot log: %s' % (pn, e)) 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 (#237248): https://lists.openembedded.org/g/openembedded-core/message/237248 Mute This Topic: https://lists.openembedded.org/mt/119373684/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
