diff options
Diffstat (limited to 'meta/lib/oeqa/buildperf/base.py')
-rw-r--r-- | meta/lib/oeqa/buildperf/base.py | 29 |
1 files changed, 9 insertions, 20 deletions
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py index 975524c6de..dd473a0bdc 100644 --- a/meta/lib/oeqa/buildperf/base.py +++ b/meta/lib/oeqa/buildperf/base.py | |||
@@ -163,8 +163,6 @@ class BuildPerfTestResult(unittest.TextTestResult): | |||
163 | ('status', status), | 163 | ('status', status), |
164 | ('start_time', test.start_time), | 164 | ('start_time', test.start_time), |
165 | ('elapsed_time', test.elapsed_time), | 165 | ('elapsed_time', test.elapsed_time), |
166 | ('cmd_log_file', os.path.relpath(test.cmd_log_file, | ||
167 | self.out_dir)), | ||
168 | ('measurements', test.measurements)]) | 166 | ('measurements', test.measurements)]) |
169 | if status in ('ERROR', 'FAILURE', 'EXPECTED_FAILURE'): | 167 | if status in ('ERROR', 'FAILURE', 'EXPECTED_FAILURE'): |
170 | test_result['message'] = str(test.err[1]) | 168 | test_result['message'] = str(test.err[1]) |
@@ -268,18 +266,13 @@ class BuildPerfTestCase(unittest.TestCase): | |||
268 | def out_dir(self): | 266 | def out_dir(self): |
269 | return os.path.join(self.base_dir, self.name) | 267 | return os.path.join(self.base_dir, self.name) |
270 | 268 | ||
271 | @property | ||
272 | def cmd_log_file(self): | ||
273 | return os.path.join(self.out_dir, 'commands.log') | ||
274 | |||
275 | def shortDescription(self): | 269 | def shortDescription(self): |
276 | return super(BuildPerfTestCase, self).shortDescription() or "" | 270 | return super(BuildPerfTestCase, self).shortDescription() or "" |
277 | 271 | ||
278 | def setUp(self): | 272 | def setUp(self): |
279 | """Set-up fixture for each test""" | 273 | """Set-up fixture for each test""" |
280 | if self.build_target: | 274 | if self.build_target: |
281 | self.log_cmd_output(['bitbake', self.build_target, | 275 | self.run_cmd(['bitbake', self.build_target, '-c', 'fetchall']) |
282 | '-c', 'fetchall']) | ||
283 | 276 | ||
284 | def run(self, *args, **kwargs): | 277 | def run(self, *args, **kwargs): |
285 | """Run test""" | 278 | """Run test""" |
@@ -287,13 +280,12 @@ class BuildPerfTestCase(unittest.TestCase): | |||
287 | super(BuildPerfTestCase, self).run(*args, **kwargs) | 280 | super(BuildPerfTestCase, self).run(*args, **kwargs) |
288 | self.elapsed_time = datetime.now() - self.start_time | 281 | self.elapsed_time = datetime.now() - self.start_time |
289 | 282 | ||
290 | def log_cmd_output(self, cmd): | 283 | def run_cmd(self, cmd): |
291 | """Run a command and log it's output""" | 284 | """Convenience method for running a command""" |
292 | cmd_str = cmd if isinstance(cmd, str) else ' '.join(cmd) | 285 | cmd_str = cmd if isinstance(cmd, str) else ' '.join(cmd) |
293 | log.info("Logging command: %s", cmd_str) | 286 | log.info("Logging command: %s", cmd_str) |
294 | try: | 287 | try: |
295 | with open(self.cmd_log_file, 'a') as fobj: | 288 | runCmd2(cmd) |
296 | runCmd2(cmd, stdout=fobj) | ||
297 | except CommandError as err: | 289 | except CommandError as err: |
298 | log.error("Command failed: %s", err.retcode) | 290 | log.error("Command failed: %s", err.retcode) |
299 | raise | 291 | raise |
@@ -338,17 +330,14 @@ class BuildPerfTestCase(unittest.TestCase): | |||
338 | log.info("Timing command: %s", cmd_str) | 330 | log.info("Timing command: %s", cmd_str) |
339 | data_q = SimpleQueue() | 331 | data_q = SimpleQueue() |
340 | try: | 332 | try: |
341 | with open(self.cmd_log_file, 'a') as fobj: | 333 | proc = Process(target=_worker, args=(data_q, cmd,)) |
342 | proc = Process(target=_worker, args=(data_q, cmd,), | 334 | proc.start() |
343 | kwargs={'stdout': fobj}) | 335 | data = data_q.get() |
344 | proc.start() | 336 | proc.join() |
345 | data = data_q.get() | ||
346 | proc.join() | ||
347 | if isinstance(data, Exception): | 337 | if isinstance(data, Exception): |
348 | raise data | 338 | raise data |
349 | except CommandError: | 339 | except CommandError: |
350 | log.error("Command '%s' failed, see %s for more details", cmd_str, | 340 | log.error("Command '%s' failed", cmd_str) |
351 | self.cmd_log_file) | ||
352 | raise | 341 | raise |
353 | etime = data['elapsed_time'] | 342 | etime = data['elapsed_time'] |
354 | 343 | ||