Skip to contentSkip to conversation

oeqa/selftest/{context, case}: Handle KeyboardInterrupt/SIGINT and SIGTERM

PATCH In review Aníbal Limón 2 participants 3 messages Jun 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/2 oeqa/selftest/{context, case}: Handle KeyboardInterrupt/SIGINT and SIGTERM

In order to avoid corrupt local.conf and bblayers.conf adds signal handler for SIGTERM and use try/finally (KeyboardIntrrupt) block to restore previously backuped configuration.

[YOCTO #11650]

---
 meta/lib/oeqa/selftest/case.py    |  36 +++++++------
 meta/lib/oeqa/selftest/context.py | 107 +++++++++++++++++++++++++++-----------
 2 files changed, 97 insertions(+), 46 deletions(-)
meta/lib/oeqa/selftest/case.py +21 -15
index 31a11fddda9..871009c568b 100644
@@ -13,28 +13,34 @@ from oeqa.utils.commands import runCmd, bitbake, get_bb_var
 from oeqa.core.case import OETestCase
 
 class OESelftestTestCase(OETestCase):
-    builddir = os.environ.get("BUILDDIR") or ""
-    localconf_path = os.path.join(builddir, "conf/local.conf")
-    localconf_backup = os.path.join(builddir, "conf/local.bk")
-    testinc_path = os.path.join(builddir, "conf/selftest.inc")
-    local_bblayers_path = os.path.join(builddir, "conf/bblayers.conf")
-    local_bblayers_backup = os.path.join(builddir, "conf/bblayers.bk")
-    testinc_bblayers_path = os.path.join(builddir, "conf/bblayers.inc")
-    machineinc_path = os.path.join(builddir, "conf/machine.inc")
-
     def __init__(self, methodName="runTest"):
         self._extra_tear_down_commands = []
-        self._track_for_cleanup = [
-            self.testinc_path, self.testinc_bblayers_path,
-            self.machineinc_path, self.localconf_backup,
-            self.local_bblayers_backup]
-
         super(OESelftestTestCase, self).__init__(methodName)
 
     @classmethod
     def setUpClass(cls):
         super(OESelftestTestCase, cls).setUpClass()
-        cls.testlayer_path = cls.tc.testlayer_path
+
+        cls.testlayer_path = cls.tc.config_paths['testlayer_path']
+        cls.builddir = cls.tc.config_paths['builddir']
+
+        cls.localconf_path = cls.tc.config_paths['localconf']
+        cls.localconf_backup = cls.tc.config_paths['localconf_class_backup']
+        cls.local_bblayers_path = cls.tc.config_paths['bblayers']
+        cls.local_bblayers_backup = cls.tc.config_paths['bblayers_class_backup']
+
+        cls.testinc_path = os.path.join(cls.tc.config_paths['builddir'],
+                "conf/selftest.inc")
+        cls.testinc_bblayers_path = os.path.join(cls.tc.config_paths['builddir'],
+                "conf/bblayers.inc")
+        cls.machineinc_path = os.path.join(cls.tc.config_paths['builddir'],
+                "conf/machine.inc")
+
+        cls._track_for_cleanup = [
+            cls.testinc_path, cls.testinc_bblayers_path,
+            cls.machineinc_path, cls.localconf_backup,
+            cls.local_bblayers_backup]
+
         cls.add_include()
 
     @classmethod
meta/lib/oeqa/selftest/context.py +76 -31

150 lines not on this page · raw message

Signature · 1 line
2.11.0
#1 lore raw

PATCH v3 2/2 selftest/cases/package: Call parent setUpClass method

Since config paths are now passed in Test context the setUpClass method is expected to be call.

---
 meta/lib/oeqa/selftest/cases/package.py | 2 ++
 1 file changed, 2 insertions(+)
meta/lib/oeqa/selftest/cases/package.py +2 -0
index 5b9a6d15851..b07d6ed0abe 100644
@@ -17,6 +17,8 @@ class VersionOrdering(OESelftestTestCase):
 
     @classmethod
     def setUpClass(cls):
+        super(VersionOrdering, cls).setUpClass()
+
         # Build the tools we need and populate a sysroot
         bitbake("dpkg-native opkg-native rpm-native python3-native")
         bitbake("build-sysroots -c build_native_sysroot")
Signature · 1 line
2.11.0
#2 lore raw
In reply to Aníbal Limón
Quoted 3 lines · Aníbal Limón

In order to avoid corrupt local.conf and bblayers.conf adds signal handler for SIGTERM and use try/finally (KeyboardIntrrupt) block to restore previously backuped configuration.

Looks good to me now, with one minor nitpick which I should have noticed
earlier: the second patch fixes a problem introduced by the first one (right?), so when applied in this order, bisecting gets broken. I think they should be merged the other way around to avoid that (calling the parent's setUpClass was fine before, it just wasn't required).

Signature · 6 lines
Best Regards, Patrick Ohly

The content of this message is my personal opinion only and although
I am an employee of Intel, the statements I make here in no way
represent Intel's position on the issue, nor am I authorized to speak
on behalf of Intel on this matter.