All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] qemurunner: Remove the signal handler before stopping qemu
@ 2018-10-09 12:48 Richard Purdie
  2018-10-09 12:48 ` [PATCH 2/2] selftest/runqemu: Handle SystemExit Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Purdie @ 2018-10-09 12:48 UTC (permalink / raw)
  To: openembedded-core

The qemu shutdown can race with the signal handler removal leading to
confusing tracebacks on slower/loaded systems.

Remove the signal handler first before shutting down.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/utils/qemurunner.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index c3c643d7107..dfab1bd5f11 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -350,10 +350,10 @@ class QemuRunner:
         return True
 
     def stop(self):
-        self.stop_thread()
-        self.stop_qemu_system()
         if hasattr(self, "origchldhandler"):
             signal.signal(signal.SIGCHLD, self.origchldhandler)
+        self.stop_thread()
+        self.stop_qemu_system()
         if self.runqemu:
             if hasattr(self, "monitorpid"):
                 os.kill(self.monitorpid, signal.SIGKILL)
-- 
2.17.1



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

* [PATCH 2/2] selftest/runqemu: Handle SystemExit
  2018-10-09 12:48 [PATCH 1/2] qemurunner: Remove the signal handler before stopping qemu Richard Purdie
@ 2018-10-09 12:48 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2018-10-09 12:48 UTC (permalink / raw)
  To: openembedded-core

The sigchld handler in runqemu can raise a SystemExit when qemu shuts down.
Rather than backtracing, accept this as a successful test result.

ERROR: runqemu.QemuTest.test_qemu_can_shutdown (subunit.RemotedTestCase)
testtools.testresult.real._StringException: Traceback (most recent call last):
  File "/home/pokybuild/yocto-worker/nightly-oe-selftest/build/meta/lib/oeqa/selftest/cases/runqemu.py", line 183, in test_qemu_can_shutdown
    qemu_shutdown_succeeded = self._start_qemu_shutdown_check_if_shutdown_succeeded(qemu, shutdown_timeout)
  File "/home/pokybuild/yocto-worker/nightly-oe-selftest/build/meta/lib/oeqa/selftest/cases/runqemu.py", line 175, in _start_qemu_shutdown_check_if_shutdown_succeeded
    time.sleep(1)
  File "/home/pokybuild/yocto-worker/nightly-oe-selftest/build/meta/lib/oeqa/utils/qemurunner.py", line 100, in handleSIGCHLD
    raise SystemExit
SystemExit

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/lib/oeqa/selftest/cases/runqemu.py | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/meta/lib/oeqa/selftest/cases/runqemu.py b/meta/lib/oeqa/selftest/cases/runqemu.py
index e57f503a577..edc2e424e6e 100644
--- a/meta/lib/oeqa/selftest/cases/runqemu.py
+++ b/meta/lib/oeqa/selftest/cases/runqemu.py
@@ -166,14 +166,17 @@ class QemuTest(OESelftestTestCase):
         # when qemu was shutdown by the above shutdown command
         qemu.runner.stop_thread()
         time_track = 0
-        while True:
-            is_alive = qemu.check()
-            if not is_alive:
-                return True
-            if time_track > timeout:
-                return False
-            time.sleep(1)
-            time_track += 1
+        try:
+            while True:
+                is_alive = qemu.check()
+                if not is_alive:
+                    return True
+                if time_track > timeout:
+                    return False
+                time.sleep(1)
+                time_track += 1
+        except SystemExit:
+            return True
 
     def test_qemu_can_shutdown(self):
         self.assertExists(self.qemuboot_conf)
-- 
2.17.1



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

end of thread, other threads:[~2018-10-09 12:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-09 12:48 [PATCH 1/2] qemurunner: Remove the signal handler before stopping qemu Richard Purdie
2018-10-09 12:48 ` [PATCH 2/2] selftest/runqemu: Handle SystemExit Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.