public inbox for openembedded-core@lists.openembedded.org
 help / color / mirror / Atom feed
From: Yash Shinde <Yash.Shinde@windriver.com>
To: Randy MacLeod <randy.macleod@windriver.com>,
	openembedded-core@lists.openembedded.org
Cc: Umesh.Kallapa@windriver.com, Naveen.Gowda@windriver.com,
	Sundeep.Kokkonda@windriver.com,
	Shivaprasad.Moodalappa@windriver.com,
	Joshua Watt <JPEWhacker@gmail.com>,
	Richard Purdie <richard.purdie@linuxfoundation.org>
Subject: Re: [PATCH] rust: Oe-selftest error log on console when it fails.
Date: Wed, 21 Feb 2024 13:30:21 +0530	[thread overview]
Message-ID: <3e26d31e-b8bd-4549-8c04-540dd36c2f69@windriver.com> (raw)
In-Reply-To: <0a8900ca-34e0-4c2d-af94-bf6b54f18956@windriver.com>

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


On 13-02-2024 23:42, Randy MacLeod wrote:
> On 2024-02-13 8:04 a.m., Yash.Shinde@windriver.com wrote:
>> From: Yash Shinde<Yash.Shinde@windriver.com>
>>
>> The rust oe-selftest output error log doesn't show any information on console when it fails.
>> The following changes emit stderr logs in terminal along with re-directing stdout and stderr to "summary.txt" file.
>>
>> Changes made::
>> - cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s > summary.txt 2>&1;" % (builddir, testargs, targetsys)
>> + cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s  > summary.txt 2> >(tee summary.txt >&2);" % (builddir, testargs, targetsys)
>>
>>> summary.txt:                  Redirects the standard output (stdout) of the command to a file 'summary.txt'
>> 2> >(tee summary.txt >&2):      Redirects stderr & stdout to summary.txt & writes stderr on terminal
>>
>> The overall effect is that both stdout and stderr are captured in the summary.txt file, while stderr still being displayed in the terminal.
>>
>> Signed-off-by: Yash Shinde<Yash.Shinde@windriver.com>
>> ---
>>   meta/lib/oeqa/selftest/cases/rust.py | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/meta/lib/oeqa/selftest/cases/rust.py b/meta/lib/oeqa/selftest/cases/rust.py
>> index 164ad11ecd..07f1b5706c 100644
>> --- a/meta/lib/oeqa/selftest/cases/rust.py
>> +++ b/meta/lib/oeqa/selftest/cases/rust.py
>> @@ -213,7 +213,7 @@ class RustSelfTestSystemEmulated(OESelftestTestCase, OEPTestResultTestCase):
>>               cmd = cmd + " export RUST_TARGET_PATH=%s/rust-targets;" % rustlibpath
>>               # Trigger testing.
>>               cmd = cmd + " export TEST_DEVICE_ADDR=\"%s:12345\";" % qemu.ip
>> -            cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s > summary.txt 2>&1;" % (builddir, testargs, targetsys)
>> +            cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s --target %s  > summary.txt 2> >(tee summary.txt >&2);" % (builddir, testargs, targetsys)
>>               runCmd(cmd)
>>               end_time = time.time()
>>   
>
> Hi Yash,
>
> We talked about this change and decided that it's just too odd a shell 
> pipeline to merge!
>
> Also, it depends on the bash shell as you can tell by pasting:
>
>    #!/bin/sh
>    python3 src/bootstrap/bootstrap.py test %s --target %s  > 
> summary.txt 2> >(tee summary.txt >&2);
>
> into https://www.shellcheck.net/ . You'll see the following log and error:
>
> $ shellcheck myscript
>
> Line 2:
> python3 src/bootstrap/bootstrap.py test %s --target %s  > summary.txt 
> 2> >(tee summary.txt >&2);
>                                                           ^-- SC2094 
> <https://www.shellcheck.net/wiki/SC2094> (info): Make sure not to read 
> and write the same file in the same pipeline.
> >>                                                                       ^-- SC3001 <https://www.shellcheck.net/wiki/SC3001> (warning): In POSIX 
> sh, process substitution is undefined.
> >>                                                                             ^-- SC2094 <https://www.shellcheck.net/wiki/SC2094> (info): Make sure not 
> to read and write the same file in the same pipeline.
>
>
> The YP goal / requirement is to avoid bash dependencies since user may 
> be using dash or some other shell for /bin/sh.
>
>
> I think that the command is being run locally (not on target), and we 
> are already in a python context so
> it seems that we would have a simpler solution if we handle the IO 
> redirection from python.
>
> Perhaps Richard or Joshua can recommend some code that you can 
> reference when making this change.
>
> Did you have time to look at the log file handling in runCmd()
>
> https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/utils/commands.py#n168
>
> Please do some analysis and reply here every day or so as  you learn 
> things or have questions.
>
>
The runCmd() returns the 'Result' object containing information about 
the command execution. It has the following attributes:
    result.command = command
    result.status = cmd.status
    result.output = cmd.output
    result.error = cmd.error
    result.pid = cmd.process.pid
https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/utils/commands.py#n198 
<https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/utils/commands.py#n198>

I tried to capture the return object value (stderr i.e result.error) and 
print it to the terminal, but that didn't work as expected.
Even I tried to print some debug statements in rust.py file and it also 
didn't show up in the terminal or in the summary.txt file.
I assume there's something in oe-selftest framework that doesn't print 
statements directly.

Also, I see there's a "output_log 
<https://git.openembedded.org/openembedded-core/tree/meta/lib/oeqa/utils/commands.py#n198:~:text=%3D0%2C-,output_log%3DNone,-%2C%20**options>" 
parameter in the runCmd function parameters, which I understand is used 
to redirect stdout of the
command being executed. Currently, I am checking with different values 
by referring to other oe-selftests and their corresponding behavior with it.

I am checking with some functions and procedures from unittest and 
subprocess.Popen frameworks to get the error logs:

https://docs.python.org/3/library/unittest.html
https://docs.python.org/3/library/subprocess.html#subprocess.Popen

Regards,
Yash

> Thanks,
>
> ../Randy
>
>
>
> -- 
> # Randy MacLeod
> # Wind River Linux

[-- Attachment #2: Type: text/html, Size: 9702 bytes --]

  parent reply	other threads:[~2024-02-21  8:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 13:04 [PATCH] rust: Oe-selftest error log on console when it fails Yash.Shinde
2024-02-13 18:12 ` Randy MacLeod
2024-02-13 18:21   ` [OE-core] " Alexander Kanavin
2024-02-21  8:00   ` Yash Shinde [this message]
2024-02-21 12:21     ` Richard Purdie

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3e26d31e-b8bd-4549-8c04-540dd36c2f69@windriver.com \
    --to=yash.shinde@windriver.com \
    --cc=JPEWhacker@gmail.com \
    --cc=Naveen.Gowda@windriver.com \
    --cc=Shivaprasad.Moodalappa@windriver.com \
    --cc=Sundeep.Kokkonda@windriver.com \
    --cc=Umesh.Kallapa@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=randy.macleod@windriver.com \
    --cc=richard.purdie@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox