summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorLeonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>2017-05-25 14:54:14 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-06 19:02:43 +0100
commit5633866ea57edf64f789c5aec4963aea9341db09 (patch)
treeeb396044f2c3c0eca5c1912065f32f45f10bbce2 /meta
parent628ba5801b2a7bcf1a3fb7249667976c342abe43 (diff)
downloadpoky-5633866ea57edf64f789c5aec4963aea9341db09.tar.gz
oeqa/selftest/case.py: Remove machine selection logic
The machine selection is an operation that needs to be made in every test run, the best place to it is on the context module. Use self.tc.custommachine variable instead of use environment. SIgned-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> (From OE-Core rev: f295b70ace0ffc28256140a21af5c3a8903297cb) Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/selftest/case.py37
1 files changed, 4 insertions, 33 deletions
diff --git a/meta/lib/oeqa/selftest/case.py b/meta/lib/oeqa/selftest/case.py
index ca95b7e8b5..1e6754a160 100644
--- a/meta/lib/oeqa/selftest/case.py
+++ b/meta/lib/oeqa/selftest/case.py
@@ -6,7 +6,6 @@ import os
6import shutil 6import shutil
7import glob 7import glob
8import errno 8import errno
9from random import choice
10from unittest.util import safe_repr 9from unittest.util import safe_repr
11 10
12import oeqa.utils.ftools as ftools 11import oeqa.utils.ftools as ftools
@@ -135,16 +134,9 @@ to ensure accurate results.")
135 if e.errno != errno.ENOENT: 134 if e.errno != errno.ENOENT:
136 raise 135 raise
137 136
138 # Get CUSTOMMACHINE from env (set by --machine argument to oe-selftest) 137 if self.tc.custommachine:
139 custommachine = os.getenv('CUSTOMMACHINE') 138 machine_conf = 'MACHINE ??= "%s"\n' % self.tc.custommachine
140 if custommachine:
141 if custommachine == 'random':
142 machine = get_random_machine()
143 else:
144 machine = custommachine
145 machine_conf = 'MACHINE ??= "%s"\n' % machine
146 self.set_machine_config(machine_conf) 139 self.set_machine_config(machine_conf)
147 print('MACHINE: %s' % machine)
148 140
149 # tests might need their own setup 141 # tests might need their own setup
150 # but if they overwrite this one they have to call 142 # but if they overwrite this one they have to call
@@ -196,8 +188,7 @@ to ensure accurate results.")
196 self.logger.debug("Writing to: %s\n%s\n" % (self.testinc_path, data)) 188 self.logger.debug("Writing to: %s\n%s\n" % (self.testinc_path, data))
197 ftools.write_file(self.testinc_path, data) 189 ftools.write_file(self.testinc_path, data)
198 190
199 custommachine = os.getenv('CUSTOMMACHINE') 191 if self.tc.custommachine and 'MACHINE' in data:
200 if custommachine and 'MACHINE' in data:
201 machine = get_bb_var('MACHINE') 192 machine = get_bb_var('MACHINE')
202 self.logger.warning('MACHINE overridden: %s' % machine) 193 self.logger.warning('MACHINE overridden: %s' % machine)
203 194
@@ -206,8 +197,7 @@ to ensure accurate results.")
206 self.logger.debug("Appending to: %s\n%s\n" % (self.testinc_path, data)) 197 self.logger.debug("Appending to: %s\n%s\n" % (self.testinc_path, data))
207 ftools.append_file(self.testinc_path, data) 198 ftools.append_file(self.testinc_path, data)
208 199
209 custommachine = os.getenv('CUSTOMMACHINE') 200 if self.tc.custommachine and 'MACHINE' in data:
210 if custommachine and 'MACHINE' in data:
211 machine = get_bb_var('MACHINE') 201 machine = get_bb_var('MACHINE')
212 self.logger.warning('MACHINE overridden: %s' % machine) 202 self.logger.warning('MACHINE overridden: %s' % machine)
213 203
@@ -274,22 +264,3 @@ to ensure accurate results.")
274 if os.path.exists(expr): 264 if os.path.exists(expr):
275 msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr)) 265 msg = self._formatMessage(msg, "%s exists when it should not" % safe_repr(expr))
276 raise self.failureException(msg) 266 raise self.failureException(msg)
277
278def get_available_machines():
279 # Get a list of all available machines
280 bbpath = get_bb_var('BBPATH').split(':')
281 machines = []
282
283 for path in bbpath:
284 found_machines = glob.glob(os.path.join(path, 'conf', 'machine', '*.conf'))
285 if found_machines:
286 for i in found_machines:
287 # eg: '/home/<user>/poky/meta-intel/conf/machine/intel-core2-32.conf'
288 machines.append(os.path.splitext(os.path.basename(i))[0])
289
290 return machines
291
292
293def get_random_machine():
294 # Get a random machine
295 return choice(get_available_machines())