On Wed, 2024-02-21 at 13:30 +0530, Yash Shinde wrote:
> 
>  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
>   
>  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" 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
>  


I had a look at this and tried an experiment locally. This seemed to
work:

diff --git a/meta/lib/oeqa/selftest/cases/rust.py 
b/meta/lib/oeqa/selftest/cases/rust.py
index 120be6454fa..ad14189c6df 100644
--- a/meta/lib/oeqa/selftest/cases/rust.py
+++ b/meta/lib/oeqa/selftest/cases/rust.py
@@ -216,13 +216,16 @@ 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)
-            runCmd(cmd)
+            cmd = cmd + " cd %s; python3 src/bootstrap/bootstrap.py test %s 
--target %s" % (builddir, testargs, targetsys)
+            retval = runCmd(cmd)
             end_time = time.time()
 
+            resultlog = rustlibpath + "/results-log.txt"
+            with open(resultlog, "w") as f:
+                f.write(retval.output)
+
             ptestsuite = "rust"
-            self.ptest_section(ptestsuite, duration = int(end_time - 
start_time), logfile = builddir + "/summary.txt")
-            filename = builddir + "/summary.txt"
-            test_results = parse_results(filename)
+            self.ptest_section(ptestsuite, duration = int(end_time - 
start_time), logfile=resultlog)
+            test_results = parse_results(resultlog)
             for test in test_results:
                 self.ptest_result(ptestsuite, test, test_results[test])


I'm fairly sure we could improve it further but this does start that
process.

Cheers,

Richard

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#195969): 
https://lists.openembedded.org/g/openembedded-core/message/195969
Mute This Topic: https://lists.openembedded.org/mt/104331501/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to