summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-04 23:34:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-05 13:54:06 +0000
commitf2b847a29092533a66bdd3a7e13e1b1356055265 (patch)
tree96731cba7f8d3127a005387382068ed6184556eb
parentb359e926e238fd84362eb6c1232dfb35a66b59dd (diff)
downloadpoky-f2b847a29092533a66bdd3a7e13e1b1356055265.tar.gz
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. (From OE-Core rev: 689b676bbf2f1a5fadb04aeb41d5e68e35356545) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-xscripts/oe-selftest19
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():
111 help='Submit test results to a repository') 111 help='Submit test results to a repository')
112 return parser 112 return parser
113 113
114builddir = None
115
114 116
115def preflight_check(): 117def preflight_check():
116 118
119 global builddir
120
117 log.info("Checking that everything is in order before running the tests") 121 log.info("Checking that everything is in order before running the tests")
118 122
119 if not os.environ.get("BUILDDIR"): 123 if not os.environ.get("BUILDDIR"):
@@ -135,7 +139,7 @@ def preflight_check():
135 return True 139 return True
136 140
137def add_include(): 141def add_include():
138 builddir = os.environ.get("BUILDDIR") 142 global builddir
139 if "#include added by oe-selftest.py" \ 143 if "#include added by oe-selftest.py" \
140 not in ftools.read_file(os.path.join(builddir, "conf/local.conf")): 144 not in ftools.read_file(os.path.join(builddir, "conf/local.conf")):
141 log.info("Adding: \"include selftest.inc\" in local.conf") 145 log.info("Adding: \"include selftest.inc\" in local.conf")
@@ -149,7 +153,7 @@ def add_include():
149 "\n#include added by oe-selftest.py\ninclude bblayers.inc") 153 "\n#include added by oe-selftest.py\ninclude bblayers.inc")
150 154
151def remove_include(): 155def remove_include():
152 builddir = os.environ.get("BUILDDIR") 156 global builddir
153 if builddir is None: 157 if builddir is None:
154 return 158 return
155 if "#include added by oe-selftest.py" \ 159 if "#include added by oe-selftest.py" \
@@ -165,18 +169,21 @@ def remove_include():
165 "\n#include added by oe-selftest.py\ninclude bblayers.inc") 169 "\n#include added by oe-selftest.py\ninclude bblayers.inc")
166 170
167def remove_inc_files(): 171def remove_inc_files():
172 global builddir
173 if builddir is None:
174 return
168 try: 175 try:
169 os.remove(os.path.join(os.environ.get("BUILDDIR"), "conf/selftest.inc")) 176 os.remove(os.path.join(builddir, "conf/selftest.inc"))
170 for root, _, files in os.walk(get_test_layer()): 177 for root, _, files in os.walk(get_test_layer()):
171 for f in files: 178 for f in files:
172 if f == 'test_recipe.inc': 179 if f == 'test_recipe.inc':
173 os.remove(os.path.join(root, f)) 180 os.remove(os.path.join(root, f))
174 except (AttributeError, OSError,) as e: # AttributeError may happen if BUILDDIR is not set 181 except OSError as e:
175 pass 182 pass
176 183
177 for incl_file in ['conf/bblayers.inc', 'conf/machine.inc']: 184 for incl_file in ['conf/bblayers.inc', 'conf/machine.inc']:
178 try: 185 try:
179 os.remove(os.path.join(os.environ.get("BUILDDIR"), incl_file)) 186 os.remove(os.path.join(builddir, incl_file))
180 except: 187 except:
181 pass 188 pass
182 189
@@ -394,7 +401,7 @@ def coverage_setup(coverage_source, coverage_include, coverage_omit):
394 """ Set up the coverage measurement for the testcases to be run """ 401 """ Set up the coverage measurement for the testcases to be run """
395 import datetime 402 import datetime
396 import subprocess 403 import subprocess
397 builddir = os.environ.get("BUILDDIR") 404 global builddir
398 pokydir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) 405 pokydir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
399 curcommit= subprocess.check_output(["git", "--git-dir", os.path.join(pokydir, ".git"), "rev-parse", "HEAD"]).decode('utf-8') 406 curcommit= subprocess.check_output(["git", "--git-dir", os.path.join(pokydir, ".git"), "rev-parse", "HEAD"]).decode('utf-8')
400 coveragerc = "%s/.coveragerc" % builddir 407 coveragerc = "%s/.coveragerc" % builddir