[OE-core] [PATCH 2/3] Added methods for manipulating bblayer.conf file in the same manner as local.conf file: - write_bblayers_config - append_bblayers_config - remove_bblayers_config
Daniel Istrate
daniel.alexandrux.istrate at intel.com
Fri Jun 26 15:07:06 UTC 2015
---
meta/lib/oeqa/selftest/base.py | 22 ++++++++++++++++++++++
scripts/oe-selftest | 16 +++++++++++++++-
2 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py
index 80b9b4b..b2faa66 100644
--- a/meta/lib/oeqa/selftest/base.py
+++ b/meta/lib/oeqa/selftest/base.py
@@ -27,6 +27,8 @@ class oeSelfTest(unittest.TestCase):
self.builddir = os.environ.get("BUILDDIR")
self.localconf_path = os.path.join(self.builddir, "conf/local.conf")
self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc")
+ self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf")
+ self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc")
self.testlayer_path = oeSelfTest.testlayer_path
self._extra_tear_down_commands = []
self._track_for_cleanup = []
@@ -45,6 +47,11 @@ class oeSelfTest(unittest.TestCase):
for f in files:
if f == 'test_recipe.inc':
os.remove(os.path.join(root, f))
+ try:
+ os.remove(self.testinc_bblayers_path)
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
# tests might need their own setup
# but if they overwrite this one they have to call
# super each time, so let's give them an alternative
@@ -129,3 +136,18 @@ class oeSelfTest(unittest.TestCase):
except OSError as e:
if e.errno != errno.ENOENT:
raise
+
+ # write to <builddir>/conf/bblayers.inc
+ def write_bblayers_config(self, data):
+ self.log.debug("Writing to: %s\n%s\n" % (self.testinc_bblayers_path, data))
+ ftools.write_file(self.testinc_bblayers_path, data)
+
+ # append to <builddir>/conf/bblayers.inc
+ def append_bblayers_config(self, data):
+ self.log.debug("Appending to: %s\n%s\n" % (self.testinc_bblayers_path, data))
+ ftools.append_file(self.testinc_bblayers_path, data)
+
+ # remove data from <builddir>/conf/bblayers.inc
+ def remove_bblayers_config(self, data):
+ self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data))
+ ftools.remove_from_file(self.testinc_bblayers_path, data)
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index a04e9fc..049a94e 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -100,6 +100,11 @@ def add_include():
ftools.append_file(os.path.join(builddir, "conf/local.conf"), \
"\n#include added by oe-selftest.py\ninclude selftest.inc")
+ if "#include added by oe-selftest.py" \
+ not in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")):
+ log.info("Adding: \"include bblayers.inc\" in bblayers.conf")
+ ftools.append_file(os.path.join(builddir, "conf/bblayers.conf"), \
+ "\n#include added by oe-selftest.py\ninclude bblayers.inc")
def remove_include():
builddir = os.environ.get("BUILDDIR")
@@ -111,6 +116,11 @@ def remove_include():
ftools.remove_from_file(os.path.join(builddir, "conf/local.conf"), \
"#include added by oe-selftest.py\ninclude selftest.inc")
+ if "#include added by oe-selftest.py" \
+ in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")):
+ log.info("Removing the include from bblayers.conf")
+ ftools.remove_from_file(os.path.join(builddir, "conf/bblayers.conf"), \
+ "#include added by oe-selftest.py\ninclude bblayers.inc")
def remove_inc_files():
try:
@@ -122,6 +132,11 @@ def remove_inc_files():
except (AttributeError, OSError,) as e: # AttributeError may happen if BUILDDIR is not set
pass
+ try:
+ os.remove(os.path.join(os.environ.get("BUILDDIR"), "conf/bblayers.inc"))
+ except:
+ pass
+
def get_tests(exclusive_modules=[], include_hidden=False):
testslist = []
for x in exclusive_modules:
@@ -167,7 +182,6 @@ def main():
print e
pass
-
if args.run_tests or args.run_all_tests:
if not preflight_check():
return 1
--
2.1.4
More information about the Openembedded-core
mailing list