summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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())