The runCmd() returns the 'Result' object containing information about the command execution. It has the following attributes: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 (info): Make sure not to read and write the same file in the same pipeline.
>> ^-- SC3001 (warning): In POSIX sh, process substitution is undefined.
>> ^-- 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
Perhaps Richard or Joshua can recommend some code that you can reference when making this change.
it seems that we would have a simpler solution if we handle the IO redirection from python.
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.
Thanks,
../Randy
-- # Randy MacLeod # Wind River Linux