path: root/scripts
diff options
authorRichard Purdie <>2017-01-04 23:34:30 +0000
committerRichard Purdie <>2017-01-05 13:53:44 +0000
commit689b676bbf2f1a5fadb04aeb41d5e68e35356545 (patch)
tree1cc35926308ed1c95e464632d5c0ba881fa87f54 /scripts
parentb6feb7578d60289c8b6e376cfaac8a3ee45e72f9 (diff)
oe-selftest: Improve BUILDDIR environment handling
Its possible something (like bitbake/tinfoil2) may mess around with the environment and using the enviroment as a global variable store isn't particularly nice anyway. This patch changes the BUILDDIR usages so that the environment isn't used as a global store and a global variable is used instead. Whilst that is still not perfect, it does avoid the current double and triple backtraces we're seeing where tinfoil2/bitbake has trampled the enviroment leading to failures of failures making debugging even harder. Signed-off-by: Richard Purdie <>
Diffstat (limited to 'scripts')
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/oe-selftest b/scripts/oe-selftest
index bfcea66f1c..e166521238 100755
--- a/scripts/oe-selftest
+++ b/scripts/oe-selftest
@@ -111,9 +111,13 @@ def get_args_parser():
help='Submit test results to a repository')
return parser
+builddir = None
def preflight_check():
+ global builddir
+"Checking that everything is in order before running the tests")
if not os.environ.get("BUILDDIR"):
@@ -135,7 +139,7 @@ def preflight_check():
return True
def add_include():
- builddir = os.environ.get("BUILDDIR")
+ global builddir
if "#include added by" \
not in ftools.read_file(os.path.join(builddir, "conf/local.conf")):"Adding: \"include\" in local.conf")
@@ -149,7 +153,7 @@ def add_include():
"\n#include added by\ninclude")
def remove_include():
- builddir = os.environ.get("BUILDDIR")
+ global builddir
if builddir is None:
if "#include added by" \
@@ -165,18 +169,21 @@ def remove_include():
"\n#include added by\ninclude")
def remove_inc_files():
+ global builddir
+ if builddir is None:
+ return
- os.remove(os.path.join(os.environ.get("BUILDDIR"), "conf/"))
+ os.remove(os.path.join(builddir, "conf/"))
for root, _, files in os.walk(get_test_layer()):
for f in files:
if f == '':
os.remove(os.path.join(root, f))
- except (AttributeError, OSError,) as e: # AttributeError may happen if BUILDDIR is not set
+ except OSError as e:
for incl_file in ['conf/', 'conf/']:
- os.remove(os.path.join(os.environ.get("BUILDDIR"), incl_file))
+ os.remove(os.path.join(builddir, incl_file))
@@ -394,7 +401,7 @@ def coverage_setup(coverage_source, coverage_include, coverage_omit):
""" Set up the coverage measurement for the testcases to be run """
import datetime
import subprocess
- builddir = os.environ.get("BUILDDIR")
+ global builddir
pokydir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
curcommit= subprocess.check_output(["git", "--git-dir", os.path.join(pokydir, ".git"), "rev-parse", "HEAD"]).decode('utf-8')
coveragerc = "%s/.coveragerc" % builddir