summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJose Lamego <jose.a.lamego@linux.intel.com>2016-09-21 12:54:59 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-23 14:56:39 +0100
commitc902e7b93700e56245d8f04397ff01fa278183a3 (patch)
tree5cee12e9020a1e9ede52686f9de5a32316118518 /meta
parent659fab429176eb4278626dee881cb8952dff96ae (diff)
downloadpoky-c902e7b93700e56245d8f04397ff01fa278183a3.tar.gz
oeqa/selftest/base: backup and restore local configuration files
Selftests' cleanup method during test setup is not capable of restoring local configuration files that remain modified after aborting a test through a keyboard interruption. This change creates backups for local.conf and bblayers.conf at test setup, restore them when found, and deletes them at cleanup. [YOCTO #9390] (From OE-Core rev: 0877278e07e4c2494c4c23199490dc47a5cee69d) Signed-off-by: Jose Lamego <jose.a.lamego@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/base.py32
1 files changed, 31 insertions, 1 deletions
diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py
index b5a52fe57a..26c93f905a 100644
--- a/meta/lib/oeqa/selftest/base.py
+++ b/meta/lib/oeqa/selftest/base.py
@@ -28,17 +28,47 @@ class oeSelfTest(unittest.TestCase):
28 def __init__(self, methodName="runTest"): 28 def __init__(self, methodName="runTest"):
29 self.builddir = os.environ.get("BUILDDIR") 29 self.builddir = os.environ.get("BUILDDIR")
30 self.localconf_path = os.path.join(self.builddir, "conf/local.conf") 30 self.localconf_path = os.path.join(self.builddir, "conf/local.conf")
31 self.localconf_backup = os.path.join(self.builddir, "conf/local.bk")
31 self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") 32 self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc")
32 self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") 33 self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf")
34 self.local_bblayers_backup = os.path.join(self.builddir,
35 "conf/bblayers.bk")
33 self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") 36 self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc")
34 self.machineinc_path = os.path.join(self.builddir, "conf/machine.inc") 37 self.machineinc_path = os.path.join(self.builddir, "conf/machine.inc")
35 self.testlayer_path = oeSelfTest.testlayer_path 38 self.testlayer_path = oeSelfTest.testlayer_path
36 self._extra_tear_down_commands = [] 39 self._extra_tear_down_commands = []
37 self._track_for_cleanup = [self.testinc_path, self.testinc_bblayers_path, self.machineinc_path] 40 self._track_for_cleanup = [
41 self.testinc_path, self.testinc_bblayers_path,
42 self.machineinc_path, self.localconf_backup,
43 self.local_bblayers_backup]
38 super(oeSelfTest, self).__init__(methodName) 44 super(oeSelfTest, self).__init__(methodName)
39 45
40 def setUp(self): 46 def setUp(self):
41 os.chdir(self.builddir) 47 os.chdir(self.builddir)
48 # Check if local.conf or bblayers.conf files backup exists
49 # from a previous failed test and restore them
50 if os.path.isfile(self.localconf_backup) or os.path.isfile(
51 self.local_bblayers_backup):
52 self.log.debug("Found a local.conf and/or bblayers.conf backup \
53from a previously aborted test. Restoring these files now, but tests should \
54be re-executed from a clean environment to ensure accurate results.")
55 try:
56 shutil.copyfile(self.localconf_backup, self.localconf_path)
57 except OSError as e:
58 if e.errno != errno.ENOENT:
59 raise
60 try:
61 shutil.copyfile(self.local_bblayers_backup,
62 self.local_bblayers_path)
63 except OSError as e:
64 if e.errno != errno.ENOENT:
65 raise
66 else:
67 # backup local.conf and bblayers.conf
68 shutil.copyfile(self.localconf_path, self.localconf_backup)
69 shutil.copyfile(self.local_bblayers_path,
70 self.local_bblayers_backup)
71 self.log.debug("Creating local.conf and bblayers.conf backups.")
42 # we don't know what the previous test left around in config or inc files 72 # we don't know what the previous test left around in config or inc files
43 # if it failed so we need a fresh start 73 # if it failed so we need a fresh start
44 try: 74 try: