summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/buildperf/base.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/buildperf/base.py')
-rw-r--r--meta/lib/oeqa/buildperf/base.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/meta/lib/oeqa/buildperf/base.py b/meta/lib/oeqa/buildperf/base.py
index 49da8f6161..0b2c0f8e73 100644
--- a/meta/lib/oeqa/buildperf/base.py
+++ b/meta/lib/oeqa/buildperf/base.py
@@ -141,7 +141,7 @@ class BuildPerfTestResult(unittest.TextTestResult):
141 141
142 def startTest(self, test): 142 def startTest(self, test):
143 """Pre-test hook""" 143 """Pre-test hook"""
144 test.out_dir = os.path.join(self.out_dir, test.name) 144 test.base_dir = self.out_dir
145 os.mkdir(test.out_dir) 145 os.mkdir(test.out_dir)
146 log.info("Executing test %s: %s", test.name, test.shortDescription()) 146 log.info("Executing test %s: %s", test.name, test.shortDescription())
147 self.stream.write(datetime.now().strftime("[%Y-%m-%d %H:%M:%S] ")) 147 self.stream.write(datetime.now().strftime("[%Y-%m-%d %H:%M:%S] "))
@@ -298,7 +298,7 @@ class BuildPerfTestCase(unittest.TestCase):
298 def __init__(self, *args, **kwargs): 298 def __init__(self, *args, **kwargs):
299 super(BuildPerfTestCase, self).__init__(*args, **kwargs) 299 super(BuildPerfTestCase, self).__init__(*args, **kwargs)
300 self.name = self._testMethodName 300 self.name = self._testMethodName
301 self.out_dir = None 301 self.base_dir = None
302 self.start_time = None 302 self.start_time = None
303 self.elapsed_time = None 303 self.elapsed_time = None
304 self.measurements = [] 304 self.measurements = []
@@ -308,6 +308,10 @@ class BuildPerfTestCase(unittest.TestCase):
308 self.times = [] 308 self.times = []
309 self.sizes = [] 309 self.sizes = []
310 310
311 @property
312 def out_dir(self):
313 return os.path.join(self.base_dir, self.name)
314
311 def setUp(self): 315 def setUp(self):
312 """Set-up fixture for each test""" 316 """Set-up fixture for each test"""
313 if self.build_target: 317 if self.build_target:
@@ -332,7 +336,7 @@ class BuildPerfTestCase(unittest.TestCase):
332 log.error("Command failed: %s", err.retcode) 336 log.error("Command failed: %s", err.retcode)
333 raise 337 raise
334 338
335 def measure_cmd_resources(self, cmd, name, legend): 339 def measure_cmd_resources(self, cmd, name, legend, save_bs=False):
336 """Measure system resource usage of a command""" 340 """Measure system resource usage of a command"""
337 def _worker(data_q, cmd, **kwargs): 341 def _worker(data_q, cmd, **kwargs):
338 """Worker process for measuring resources""" 342 """Worker process for measuring resources"""
@@ -387,6 +391,11 @@ class BuildPerfTestCase(unittest.TestCase):
387 'elapsed_time': etime, 391 'elapsed_time': etime,
388 'rusage': data['rusage'], 392 'rusage': data['rusage'],
389 'iostat': data['iostat']} 393 'iostat': data['iostat']}
394 if save_bs:
395 bs_file = self.save_buildstats(legend)
396 measurement['values']['buildstats_file'] = \
397 os.path.relpath(bs_file, self.base_dir)
398
390 self.measurements.append(measurement) 399 self.measurements.append(measurement)
391 400
392 # Append to 'times' array for globalres log 401 # Append to 'times' array for globalres log
@@ -474,12 +483,13 @@ class BuildPerfTestCase(unittest.TestCase):
474 buildstats.append(recipe_bs) 483 buildstats.append(recipe_bs)
475 484
476 # Write buildstats into json file 485 # Write buildstats into json file
477 postfix = '.' + label if label else '' 486 postfix = '.' + str_to_fn(label) if label else ''
478 postfix += '.json' 487 postfix += '.json'
479 outfile = os.path.join(self.out_dir, 'buildstats' + postfix) 488 outfile = os.path.join(self.out_dir, 'buildstats' + postfix)
480 with open(outfile, 'w') as fobj: 489 with open(outfile, 'w') as fobj:
481 json.dump(buildstats, fobj, indent=4, sort_keys=True, 490 json.dump(buildstats, fobj, indent=4, sort_keys=True,
482 cls=ResultsJsonEncoder) 491 cls=ResultsJsonEncoder)
492 return outfile
483 493
484 def rm_tmp(self): 494 def rm_tmp(self):
485 """Cleanup temporary/intermediate files and directories""" 495 """Cleanup temporary/intermediate files and directories"""