Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 0/1 v2] handle SIGTERM to conclude runqemu
@ 2015-09-05 10:17 mariano.lopez
  2015-09-05 10:17 ` [PATCH 1/1 v2] testimage: " mariano.lopez
  0 siblings, 1 reply; 2+ messages in thread
From: mariano.lopez @ 2015-09-05 10:17 UTC (permalink / raw)
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

This is a rebase for the current master-next,
please ignore the previous patch.

This also provides a way to cherry pick the commit.


The following changes since commit 68e18e10aba819df576fcadfaa5c9e244d70d112:

  pseudo_1.7.3.bb: New version of pseudo (2015-09-05 06:29:22 +0100)

are available in the git repository at:

  git://git.yoctoproject.org/poky-contrib mariano/bug8239v3
  http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=mariano/bug8239v3

Mariano Lopez (1):
  testimage: handle SIGTERM to conclude runqemu

 meta/classes/testimage.bbclass | 12 +++++++++++-
 meta/lib/oeqa/oetest.py        |  6 +++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

-- 
1.8.4.5



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

* [PATCH 1/1 v2] testimage: handle SIGTERM to conclude runqemu
  2015-09-05 10:17 [PATCH 0/1 v2] handle SIGTERM to conclude runqemu mariano.lopez
@ 2015-09-05 10:17 ` mariano.lopez
  0 siblings, 0 replies; 2+ messages in thread
From: mariano.lopez @ 2015-09-05 10:17 UTC (permalink / raw)
  To: openembedded-core

From: Mariano Lopez <mariano.lopez@linux.intel.com>

In the current state if a SIGTERM is sent to
the testimage worker, the worker will exit but
runqemu and qemu won't exit and the processes
need to be killed manually to free the
bitbake lock.

This allows to catch the SIGTERM signal in
testimage, this way it is possible to stop
runqemu and qemu and allow to free the bitbake lock.

Also this allows to skip the rest of the tests
when running the tests in qemu or real hardware.

This also solves minimal breaks in the setup of the
runtime test when checking if qemu is alive.

[YOCTO #8239]

Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com>
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
---
 meta/classes/testimage.bbclass | 12 +++++++++++-
 meta/lib/oeqa/oetest.py        |  6 +++++-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 7c783ea..19a37cb 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -236,6 +236,7 @@ def testimage_main(d):
     import os
     import oeqa.runtime
     import time
+    import signal
     from oeqa.oetest import loadTests, runTests
     from oeqa.targetcontrol import get_target_controller
     from oeqa.utils.dump import get_host_dumper
@@ -273,12 +274,20 @@ def testimage_main(d):
             self.imagefeatures = d.getVar("IMAGE_FEATURES", True).split()
             self.distrofeatures = d.getVar("DISTRO_FEATURES", True).split()
             manifest = os.path.join(d.getVar("DEPLOY_DIR_IMAGE", True), d.getVar("IMAGE_LINK_NAME", True) + ".manifest")
+            self.sigterm = False
+            self.origsigtermhandler = signal.getsignal(signal.SIGTERM)
+            signal.signal(signal.SIGTERM, self.sigterm_exception)
             try:
                 with open(manifest) as f:
                     self.pkgmanifest = f.read()
             except IOError as e:
                 bb.fatal("No package manifest file found. Did you build the image?\n%s" % e)
 
+        def sigterm_exception(self, signum, stackframe):
+            bb.warn("TestImage received SIGTERM, shutting down...")
+            self.sigterm = True
+            self.target.stop()
+
     # test context
     tc = TestContext()
 
@@ -293,8 +302,8 @@ def testimage_main(d):
 
     target.deploy()
 
-    target.start()
     try:
+        target.start()
         if export:
             exportTests(d,tc)
         else:
@@ -311,6 +320,7 @@ def testimage_main(d):
             else:
                 raise bb.build.FuncFailed("%s - FAILED - check the task log and the ssh log" % pn )
     finally:
+        signal.signal(signal.SIGTERM, tc.origsigtermhandler)
         target.stop()
 
 testimage_main[vardepsexclude] =+ "BB_ORIGENV"
diff --git a/meta/lib/oeqa/oetest.py b/meta/lib/oeqa/oetest.py
index ff62c30..0fe68d4 100644
--- a/meta/lib/oeqa/oetest.py
+++ b/meta/lib/oeqa/oetest.py
@@ -145,7 +145,11 @@ class oeRuntimeTest(oeTest):
         super(oeRuntimeTest, self).__init__(methodName)
 
     def setUp(self):
-        self.assertTrue(self.target.check(), msg = "Qemu not running?")
+        # Check if test needs to run
+        if self.tc.sigterm:
+            self.fail("Got SIGTERM")
+        elif (type(self.target).__name__ == "QemuTarget"):
+            self.assertTrue(self.target.check(), msg = "Qemu not running?")
 
     def tearDown(self):
         # If a test fails or there is an exception
-- 
1.8.4.5



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

end of thread, other threads:[~2015-09-05 18:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-05 10:17 [PATCH 0/1 v2] handle SIGTERM to conclude runqemu mariano.lopez
2015-09-05 10:17 ` [PATCH 1/1 v2] testimage: " mariano.lopez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox