Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH v2] kernel-yocto.bbclass: capture stderr from subprocess.check_output()
@ 2026-11-13 12:53 Mikko Rapeli
  2026-11-13 13:01 ` Patchtest results for " patchtest
  2026-11-23 16:21 ` [OE-core] " Bruce Ashfield
  0 siblings, 2 replies; 3+ messages in thread
From: Mikko Rapeli @ 2026-11-13 12:53 UTC (permalink / raw)
  To: openembedded-core; +Cc: Mikko Rapeli

Hard to debug failures without stderr in output.

Signed-off-by: Mikko Rapeli <mikko.rapeli@linaro.org>
---
 meta/classes-recipe/kernel-yocto.bbclass | 29 +++++++++++++-----------
 1 file changed, 16 insertions(+), 13 deletions(-)

v2: using text=True, removed utf-8 decoding, capturing stderr to pipe and
    printing separately in error case

v1: https://lists.openembedded.org/g/openembedded-core/message/249371

diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index 43674e8bcb..86fa2a9954 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -548,17 +548,17 @@ python do_config_analysis() {
         for action in ["analysis","audit"]:
             if action == "analysis":
                 try:
-                    analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--blame', c], cwd=s, env=env ).decode('utf-8')
+                    analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--blame', c], cwd=s, stderr=subprocess.PIPE, text=True, env=env)
                 except subprocess.CalledProcessError as e:
-                    bb.fatal( "config analysis failed when running '%s': %s" % (" ".join(e.cmd), e.output.decode('utf-8')))
+                    bb.fatal( "config analysis failed when running '%s': %s\n%s" % (" ".join(e.cmd), e.output, e.stderr))
 
                 outfile = d.getVar( 'CONFIG_ANALYSIS_FILE' )
 
             if action == "audit":
                 try:
-                    analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--summary', '--extended', '--sanity', c], cwd=s, env=env ).decode('utf-8')
+                    analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--summary', '--extended', '--sanity', c], cwd=s, stderr=subprocess.PIPE, text=True, env=env )
                 except subprocess.CalledProcessError as e:
-                    bb.fatal( "config analysis failed when running '%s': %s" % (" ".join(e.cmd), e.output.decode('utf-8')))
+                    bb.fatal( "config analysis failed when running '%s': %s\n%s" % (" ".join(e.cmd), e.output, e.stderr))
 
                 outfile = d.getVar( 'CONFIG_AUDIT_FILE' )
 
@@ -593,7 +593,10 @@ python do_kernel_configcheck() {
     # passed a valid meta-series for processing
     kmeta = d.getVar("KMETA")
     if not kmeta or not os.path.exists('{}/{}'.format(s,kmeta)):
-        kmeta = subprocess.check_output(['kgit', '--meta'], cwd=d.getVar('S')).decode('utf-8').rstrip()
+        try:
+            kmeta = subprocess.check_output(['kgit', '--meta'], cwd=d.getVar('S'), stderr=subprocess.PIPE, text=True).rstrip()
+        except subprocess.CalledProcessError as e:
+            bb.fatal( "configcheck failed: %s\n%s" % (e.output, e.stderr))
 
     env = os.environ.copy()
     env['PATH'] = "%s:%s%s" % (d.getVar('PATH'), s, "/scripts/util/")
@@ -608,9 +611,9 @@ python do_kernel_configcheck() {
         env['CLANG_FLAGS'] = " -fintegrated-as"
 
     try:
-        configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], env=env).decode('utf-8')
+        configs = subprocess.check_output(['scc', '--configs', '-o', s + '/.kernel-meta'], stderr=subprocess.PIPE, text=True, env=env)
     except subprocess.CalledProcessError as e:
-        bb.fatal( "Cannot gather config fragments for audit: %s" % e.output.decode("utf-8") )
+        bb.fatal( "Cannot gather config fragments for audit: %s\n%s" % (e.output, e.stderr))
 
     config_check_visibility = int(d.getVar("KCONF_AUDIT_LEVEL") or 0)
     bsp_check_visibility = int(d.getVar("KCONF_BSP_AUDIT_LEVEL") or 0)
@@ -627,9 +630,9 @@ python do_kernel_configcheck() {
 
     # category #1: mismatches
     try:
-        analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--mismatches', extra_params], cwd=s, env=env ).decode('utf-8')
+        analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--mismatches', extra_params], cwd=s, stderr=subprocess.PIPE, env=env, text=True )
     except subprocess.CalledProcessError as e:
-        bb.fatal( "config analysis failed when running '%s': %s" % (" ".join(e.cmd), e.output.decode('utf-8')))
+        bb.fatal( "config analysis failed when running '%s': %s\n%s" % (" ".join(e.cmd), e.output, e.stderr))
 
     if analysis:
         outfile = "{}/{}/cfg/mismatch.txt".format( s, kmeta )
@@ -649,9 +652,9 @@ python do_kernel_configcheck() {
     if bsp_check_visibility > 1:
         extra_params = "--strict"
     try:
-        analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--invalid', extra_params], cwd=s, env=env ).decode('utf-8')
+        analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--invalid', extra_params], cwd=s, stderr=subprocess.PIPE, env=env, text=True )
     except subprocess.CalledProcessError as e:
-        bb.fatal( "config analysis failed when running '%s': %s" % (" ".join(e.cmd), e.output.decode('utf-8')))
+        bb.fatal( "config analysis failed when running '%s': %s\n%s" % (" ".join(e.cmd), e.output, e.stderr))
 
     if analysis:
         outfile = "{}/{}/cfg/invalid.txt".format(s,kmeta)
@@ -668,9 +671,9 @@ python do_kernel_configcheck() {
 
     # category #3: redefined options (this is pretty verbose and is debug only)
     try:
-        analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--sanity'], cwd=s, env=env ).decode('utf-8')
+        analysis = subprocess.check_output(['symbol_why.py', '--dotconfig',  '{}'.format( d.getVar('B') + '/.config' ), '--sanity'], cwd=s, stderr=subprocess.PIPE, env=env, text=True)
     except subprocess.CalledProcessError as e:
-        bb.fatal( "config analysis failed when running '%s': %s" % (" ".join(e.cmd), e.output.decode('utf-8')))
+        bb.fatal( "config analysis failed when running '%s': %s\n%s" % (" ".join(e.cmd), e.output, e.stderr))
 
     if analysis:
         outfile = "{}/{}/cfg/redefinition.txt".format(s,kmeta)
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Patchtest results for [PATCH v2] kernel-yocto.bbclass: capture stderr from subprocess.check_output()
  2026-11-13 12:53 [PATCH v2] kernel-yocto.bbclass: capture stderr from subprocess.check_output() Mikko Rapeli
@ 2026-11-13 13:01 ` patchtest
  2026-11-23 16:21 ` [OE-core] " Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: patchtest @ 2026-11-13 13:01 UTC (permalink / raw)
  To: Mikko Rapeli; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3295 bytes --]

Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/v2-kernel-yocto.bbclass-capture-stderr-from-subprocess.check_output.patch

FAIL: test max line length: Patch line too long (current length 207, maximum is 200) (test_metadata.TestMetadata.test_max_line_length)

PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test auh changelog truncation notice (test_mbox.TestMbox.test_auh_changelog_truncation_notice)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: pretest src uri left files: No modified recipes, skipping pretest (test_metadata.TestMetadata.pretest_src_uri_left_files)
SKIP: test CVE check ignore: No modified recipes or older target branch, skipping test (test_metadata.TestMetadata.test_cve_check_ignore)
SKIP: test CVE tag format: No new source patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new source patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new source patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum modified not mentioned: No modified recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test src uri left files: No modified recipes, skipping test (test_metadata.TestMetadata.test_src_uri_left_files)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [OE-core] [PATCH v2] kernel-yocto.bbclass: capture stderr from subprocess.check_output()
  2026-11-13 12:53 [PATCH v2] kernel-yocto.bbclass: capture stderr from subprocess.check_output() Mikko Rapeli
  2026-11-13 13:01 ` Patchtest results for " patchtest
@ 2026-11-23 16:21 ` Bruce Ashfield
  1 sibling, 0 replies; 3+ messages in thread
From: Bruce Ashfield @ 2026-11-23 16:21 UTC (permalink / raw)
  To: Mikko Rapeli; +Cc: openembedded-core

On Fri, Nov 13, 2026 at 7:53 AM Mikko Rapeli via openembedded-core
<mikko.rapeli=linaro.org@lists.openembedded.org> wrote:
>
> Hard to debug failures without stderr in output.

I went and looked at what the tools actually send to stderr, to see
how much this would help.

Not a lot, as it turns out .. symbol_why.py and scc report their
errors on stdout (with a non-zero exit), which the existing exception
handling already prints. kgit --meta always exits 0, so that new
try/except won't ever trigger. Where this does help is a python
traceback out of symbol_why.py (Kconfig parse errors, etc), and
previously that was only in the task log, so it is still an
improvement (which is what bit Mikko).

One minor thing: with stderr=subprocess.PIPE, anything written to
stderr on a successful run is now captured and dropped, where before
it ended up in the task log. Nothing important goes there today, so
I'm not worried about it, but if you do a v3 for any other reason,
it might be worth logging it on success.

To be clear, I'm actually working on modernizing symbol_why (I wrote a
lot of that code fairly early in my python hacking career). So there's
an opportunity to make it throw exceptions, fix exit codes and better
separate stderr/sdout.

As a first step I'll look at having the tools send their errors to
stderr, so this gets more useful over time.

Acked-by: Bruce Ashfield <bruce.ashfield@gmail.com>

Bruce

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-23 16:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-13 12:53 [PATCH v2] kernel-yocto.bbclass: capture stderr from subprocess.check_output() Mikko Rapeli
2026-11-13 13:01 ` Patchtest results for " patchtest
2026-11-23 16:21 ` [OE-core] " Bruce Ashfield

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox