Skip to contentSkip to conversation

oeqa: Change the serial runner

PATCH In review Louis Rannou 4 participants 9 messages Apr 11, 2023 – May 9, 2023

lore
Share & tools
lore
#0 lore raw

v4 cover oeqa: Change the serial runner

The actual serial runner has a different usage compare to the ssh runner. The return status is different and failure are not raised as exceptions.

Initially, I wanted to create a new run_serial_socket and modify the old run_serial to use the former. And there was a second patch that changed every call to run_serial to run_serial_socket. But that is not easy as each test can have a different manner to handle the exception.

Therefore, the second patch only change dummy calls to the serial runner.

Louis Rannou (2):
oeqa/utils/qemurunner: change the serial runner oeqa/selftest: change deprecated usage of run_serial

 meta/lib/oeqa/selftest/cases/debuginfod.py |  3 +-
 meta/lib/oeqa/selftest/cases/gdbserver.py  |  7 +--
 meta/lib/oeqa/selftest/cases/locales.py    |  8 +--
 meta/lib/oeqa/selftest/cases/package.py    |  7 +--
 meta/lib/oeqa/selftest/cases/runqemu.py    |  2 +-
 meta/lib/oeqa/targetcontrol.py             |  3 ++
 meta/lib/oeqa/utils/qemurunner.py          | 57 ++++++++++++++++++++++
 7 files changed, 75 insertions(+), 12 deletions(-)
Signature · 1 line
2.40.0
#1 lore raw

PATCH v4 1/2 oeqa/utils/qemurunner: change the serial runner

[YOCTO #15021]

Create a new runner run_serial_socket which usage matches the traditional ssh runner. Its return status is 0 when the command succeeded or 0 when it failed. If an error is encountered, it raises an Exception.

The previous serial runner is maintained and marked as deprecated.

---
 meta/lib/oeqa/targetcontrol.py    |  3 ++
 meta/lib/oeqa/utils/qemurunner.py | 57 +++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+)
meta/lib/oeqa/targetcontrol.py +3 -0
index d686fe07ec..3707883da7 100644
@@ -206,6 +206,9 @@ class QemuTarget(BaseTarget):
     def run_serial(self, command, timeout=60):
         return self.runner.run_serial(command, timeout=timeout)
 
+    def run_serial_socket(self, command, timeout=60):
+        return self.runner.run_serial_socket(command, timeout=timeout)
+
 
 class SimpleRemoteTarget(BaseTarget):
 
meta/lib/oeqa/utils/qemurunner.py +57 -0

69 lines not on this page · raw message

Signature · 1 line
2.40.0
#2 lore raw

Re: [OE-core] [PATCH v4 1/2] oeqa/utils/qemurunner: change the serial runner

Hello Louis,

Quoted 3 lines · On Tue, 11 Apr 2023 17:05:02 +0200 "Louis Rannou" <[email protected]> wrote:

[YOCTO #15021]

Create a new runner run_serial_socket which usage matches the traditional ssh

Nit: I'm not a native English speaker, but I think "whose usage" is the correct form.

Quoted 2 lines

runner. Its return status is 0 when the command succeeded or 0 when it failed. If an error is encountered, it raises an Exception.

Should be "or a negative error when it fails"?

I'm taking the patch for testing with these two changes, let me know if I should do otherwise.

Luca

Signature · 3 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw

Re: [OE-core] [PATCH v4 1/2] oeqa/utils/qemurunner: change the serial runner

Hello Luca,

You are correct, thanks !

Louis

Quoted 22 lines · Luca Ceresoli

Hello Louis,

Quoted 3 lines · On Tue, 11 Apr 2023 17:05:02 +0200 "Louis Rannou" <[email protected]> wrote:

[YOCTO #15021]

Create a new runner run_serial_socket which usage matches the traditional ssh

Nit: I'm not a native English speaker, but I think "whose usage" is the correct form.

Quoted 2 lines

runner. Its return status is 0 when the command succeeded or 0 when it failed. If an error is encountered, it raises an Exception.

Should be "or a negative error when it fails"?

I'm taking the patch for testing with these two changes, let me know if I should do otherwise.

Luca

#4 lore raw

Re: [OE-core] [PATCH v4 1/2] oeqa/utils/qemurunner: change the serial runner

In reply to Louis Rannou
Quoted 5 lines · Louis Rannou via lists.openembedded.org

Create a new runner run_serial_socket which usage matches the traditional ssh runner. Its return status is 0 when the command succeeded or 0 when it failed. If an error is encountered, it raises an Exception.

The previous serial runner is maintained and marked as deprecated.

I absolutely love this because the existing run_serial has the most confusing behaviour. However, we’re now duplicating a large chunk of code: can the old function be implemented such that it calls the new function and adapts the return values?

Ross

#5 lore raw

Re: [OE-core] [PATCH v4 1/2] oeqa/utils/qemurunner: change the serial runner

Quoted 12 lines · Ross Burton
Quoted 5 lines · Louis Rannou via lists.openembedded.org

Create a new runner run_serial_socket which usage matches the traditional ssh runner. Its return status is 0 when the command succeeded or 0 when it failed. If an error is encountered, it raises an Exception.

The previous serial runner is maintained and marked as deprecated.

I absolutely love this because the existing run_serial has the most confusing behaviour. However, we’re now duplicating a large chunk of code: can the old function be implemented such that it calls the new function and adapts the return values?

Also, for bonus points, make the old function actual spit out a DeprecationWarning with warnings.warn.

Ross

#6 lore raw

Re: [OE-core] [PATCH v4 1/2] oeqa/utils/qemurunner: change the serial runner

In reply to Ross Burton
Quoted 11 lines · Ross Burton
Quoted 5 lines · Louis Rannou via lists.openembedded.org

Create a new runner run_serial_socket which usage matches the traditional ssh runner. Its return status is 0 when the command succeeded or 0 when it failed. If an error is encountered, it raises an Exception.

The previous serial runner is maintained and marked as deprecated.

I absolutely love this because the existing run_serial has the most confusing behaviour. However, we’re now duplicating a large chunk of
code: can the old function be implemented such that it calls the new function and adapts the return values?

This has hovered in the patch queue for that reason. I also love the idea of it, it just doesn't feel quite ready.

I've been hoping we could convert the existing users and be able to drop the old function but I'm not managed to see how much work is left for that.

Cheers,

Richard

#7 lore raw

Re: [OE-core] [PATCH v4 1/2] oeqa/utils/qemurunner: change the serial runner

Quoted 13 lines · Richard Purdie
Quoted 11 lines · Ross Burton
Quoted 5 lines · Louis Rannou via lists.openembedded.org

Create a new runner run_serial_socket which usage matches the traditional ssh runner. Its return status is 0 when the command succeeded or 0 when it failed. If an error is encountered, it raises an Exception.

The previous serial runner is maintained and marked as deprecated.

I absolutely love this because the existing run_serial has the most confusing behaviour. However, we’re now duplicating a large chunk of
code: can the old function be implemented such that it calls the new function and adapts the return values?

Quoted 6 lines

This has hovered in the patch queue for that reason. I also love the idea of it, it just doesn't feel quite ready.

I've been hoping we could convert the existing users and be able to drop the old function but I'm not managed to see how much work is left for that.

My initial idea was indeed to change the former run_serial to use the new run_serial_socket. The problem is that run_serial_socket can raise exceptions which are not handled by run_serial. It's not possible to catch them except if we create a very specific exception to this subject.

About the second question: how much work is left. serial_runner remains in:
- selftest/cases/wic.py
- selftest/cases/imagefeatures.py
- selftest/cases/overlayfs.py
- selftest/cases/runtime_test.py
- utils/dump.py

It seemed to me that fixing those is nos as easy. Further investigation is possible, but it would be much more comfortable for me to see the first stage validated. I would say this is a pretty good checkpoint for saving this work while I try to fix what can be.

Thanks,
Louis

#8 lore raw

PATCH v4 2/2 oeqa/selftest: change deprecated usage of run_serial

In reply to Louis Rannou

Prefer the new function run_serial_socket. Change calls where the modification is easy.

---
 meta/lib/oeqa/selftest/cases/debuginfod.py | 3 ++-
 meta/lib/oeqa/selftest/cases/gdbserver.py  | 7 ++++---
 meta/lib/oeqa/selftest/cases/locales.py    | 8 ++++----
 meta/lib/oeqa/selftest/cases/package.py    | 7 ++++---
 meta/lib/oeqa/selftest/cases/runqemu.py    | 2 +-
 5 files changed, 15 insertions(+), 12 deletions(-)
meta/lib/oeqa/selftest/cases/debuginfod.py +2 -1
index 37f51760fb..2571ce6989 100644
@@ -99,7 +99,8 @@ CORE_IMAGE_EXTRA_INSTALL += "elfutils"
                     % (qemu.server_ip, port)
                 )
                 self.logger.info(f"Starting client {cmd}")
-                status, output = qemu.run_serial(cmd)
+                status, output = qemu.run_serial_socket(cmd)
+                self.assertEqual(0, status)
                 # This should be more comprehensive
                 self.assertIn("/.cache/debuginfod_client/", output)
         finally:
meta/lib/oeqa/selftest/cases/gdbserver.py +4 -3
index 9da97ae780..4f8c7d620f 100644
@@ -43,7 +43,8 @@ CORE_IMAGE_EXTRA_INSTALL = "gdbserver"
             shutil.unpack_archive(filename, debugfs)
 
             with runqemu("core-image-minimal", runqemuparams="nographic") as qemu:
-                status, output = qemu.run_serial("kmod --help")
+                status, output = qemu.run_serial_socket("kmod --help")
+                self.assertEqual(status, 0)
                 self.assertIn("modprobe", output)
 
                 with concurrent.futures.ThreadPoolExecutor(max_workers=1) as executor:
@@ -61,7 +62,7 @@ CORE_IMAGE_EXTRA_INSTALL = "gdbserver"
                             self.fail("Timed out connecting to gdb")
                     future = executor.submit(run_gdb)
 
-                    status, output = qemu.run_serial("gdbserver --once :9999 kmod --help")
-                    self.assertEqual(status, 1)
+                    status, output = qemu.run_serial_socket("gdbserver --once :9999 kmod --help")
+                    self.assertEqual(status, 0)
                     # The future either returns None, or raises an exception
                     future.result()
meta/lib/oeqa/selftest/cases/locales.py +4 -4
index 4ca8ffb7aa..98026d2c80 100644
@@ -27,15 +27,15 @@ class LocalesTest(OESelftestTestCase):
 
         with runqemu("core-image-minimal", ssh=False, runqemuparams='nographic') as qemu:
             cmd = "locale -a"
-            status, output = qemu.run_serial(cmd)
+            status, output = qemu.run_serial_socket(cmd)
             # output must includes fr_FR or fr_FR.UTF-8
-            self.assertEqual(status, 1, msg='locale test command failed: output: %s' % output)
+            self.assertEqual(status, 0, msg='locale test command failed: output: %s' % output)
             self.assertIn("fr_FR", output, msg='locale -a test failed: output: %s' % output)
 
             cmd = "localedef --list-archive -v"
-            status, output = qemu.run_serial(cmd)
+            status, output = qemu.run_serial_socket(cmd)
             # output must includes fr_FR.utf8
-            self.assertEqual(status, 1, msg='localedef test command failed: output: %s' % output)
+            self.assertEqual(status, 0, msg='localedef test command failed: output: %s' % output)
             self.assertIn("fr_FR.utf8", output, msg='localedef test failed: output: %s' % output)
 
     def test_locales_on(self):
meta/lib/oeqa/selftest/cases/package.py +4 -3
index 1aa6c03f8a..78e8a4c26b 100644
@@ -135,7 +135,8 @@ class PackageTests(OESelftestTestCase):
             Check that gdb ``binary`` to read symbols from separated debug file
             """
             self.logger.info("gdbtest %s" % binary)
-            status, output = qemu.run_serial('/usr/bin/gdb.sh %s' % binary, timeout=60)
+            status, output = qemu.run_serial_socket('/usr/bin/gdb.sh %s' % binary, timeout=60)
+            self.assertEqual(0, status)
             for l in output.split('\n'):
                 # Check debugging symbols exists
                 if '(no debugging symbols found)' in l:
@@ -166,8 +167,8 @@ class PackageTests(OESelftestTestCase):
 
         def check_ownership(qemu, expected_gid, expected_uid, path):
             self.logger.info("Check ownership of %s", path)
-            status, output = qemu.run_serial('stat -c "%U %G" ' + path)
-            self.assertEqual(status, 1, "stat failed: " + output)
+            status, output = qemu.run_serial_socket('stat -c "%U %G" ' + path)
+            self.assertEqual(status, 0, "stat failed: " + output)
             try:
                 uid, gid = output.split()
                 self.assertEqual(uid, expected_uid)
meta/lib/oeqa/selftest/cases/runqemu.py +1 -1
index f01e1eec66..be1481a82e 100644
@@ -183,7 +183,7 @@ class QemuTest(OESelftestTestCase):
         # (such as the exception "Console connection closed unexpectedly")
         # as qemu will disappear when we shut it down
         qemu.runner.allowexit()
-        qemu.run_serial("shutdown -h now")
+        qemu.run_serial_socket("shutdown -h now")
         time_track = 0
         try:
             while True:
Signature · 1 line
2.40.0