summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/buildperf
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/buildperf')
-rw-r--r--meta/lib/oeqa/buildperf/base.py18
-rw-r--r--meta/lib/oeqa/buildperf/test_basic.py7
2 files changed, 17 insertions, 8 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"""
diff --git a/meta/lib/oeqa/buildperf/test_basic.py b/meta/lib/oeqa/buildperf/test_basic.py
index 25dbfb0bf7..e448ed18c9 100644
--- a/meta/lib/oeqa/buildperf/test_basic.py
+++ b/meta/lib/oeqa/buildperf/test_basic.py
@@ -28,9 +28,8 @@ class Test1P1(BuildPerfTestCase):
28 self.rm_cache() 28 self.rm_cache()
29 self.sync() 29 self.sync()
30 self.measure_cmd_resources(['bitbake', self.build_target], 'build', 30 self.measure_cmd_resources(['bitbake', self.build_target], 'build',
31 'bitbake ' + self.build_target) 31 'bitbake ' + self.build_target, save_bs=True)
32 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir') 32 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
33 self.save_buildstats()
34 33
35 34
36class Test1P2(BuildPerfTestCase): 35class Test1P2(BuildPerfTestCase):
@@ -62,11 +61,11 @@ class Test1P3(BuildPerfTestCase):
62 self.sync() 61 self.sync()
63 cmd = ['bitbake', '-R', postfile, self.build_target] 62 cmd = ['bitbake', '-R', postfile, self.build_target]
64 self.measure_cmd_resources(cmd, 'build', 63 self.measure_cmd_resources(cmd, 'build',
65 'bitbake' + self.build_target) 64 'bitbake' + self.build_target,
65 save_bs=True)
66 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir') 66 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
67 finally: 67 finally:
68 os.unlink(postfile) 68 os.unlink(postfile)
69 self.save_buildstats()
70 69
71 70
72class Test2(BuildPerfTestCase): 71class Test2(BuildPerfTestCase):