blob: 6d6b01b04b4f04ed782d7d7cfbfdd36017b1855c [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001# Copyright (c) 2016, Intel Corporation.
2#
3# This program is free software; you can redistribute it and/or modify it
4# under the terms and conditions of the GNU General Public License,
5# version 2, as published by the Free Software Foundation.
6#
7# This program is distributed in the hope it will be useful, but WITHOUT
8# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
10# more details.
11#
12"""Basic set of build performance tests"""
13import os
14import shutil
15
16import oe.path
17from oeqa.buildperf import BuildPerfTestCase
Brad Bishop316dfdd2018-06-25 12:45:53 -040018from oeqa.utils.commands import get_bb_var, get_bb_vars
Patrick Williamsc0f7c042017-02-23 20:41:17 -060019
20class Test1P1(BuildPerfTestCase):
21 build_target = 'core-image-sato'
22
23 def test1(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050024 """Build core-image-sato"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060025 self.rm_tmp()
26 self.rm_sstate()
27 self.rm_cache()
28 self.sync()
29 self.measure_cmd_resources(['bitbake', self.build_target], 'build',
30 'bitbake ' + self.build_target, save_bs=True)
31 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
Brad Bishop316dfdd2018-06-25 12:45:53 -040032 self.measure_disk_usage(get_bb_var("IMAGE_ROOTFS", self.build_target), 'rootfs', 'rootfs', True)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033
34
35class Test1P2(BuildPerfTestCase):
36 build_target = 'virtual/kernel'
37
38 def test12(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050039 """Build virtual/kernel"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060040 # Build and cleans state in order to get all dependencies pre-built
Brad Bishop6e60e8b2018-02-01 10:27:11 -050041 self.run_cmd(['bitbake', self.build_target])
42 self.run_cmd(['bitbake', self.build_target, '-c', 'cleansstate'])
Patrick Williamsc0f7c042017-02-23 20:41:17 -060043
44 self.sync()
45 self.measure_cmd_resources(['bitbake', self.build_target], 'build',
46 'bitbake ' + self.build_target)
47
48
49class Test1P3(BuildPerfTestCase):
50 build_target = 'core-image-sato'
51
52 def test13(self):
53 """Build core-image-sato with rm_work enabled"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050054 postfile = os.path.join(self.tmp_dir, 'postfile.conf')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060055 with open(postfile, 'w') as fobj:
56 fobj.write('INHERIT += "rm_work"\n')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050057
58 self.rm_tmp()
59 self.rm_sstate()
60 self.rm_cache()
61 self.sync()
62 cmd = ['bitbake', '-R', postfile, self.build_target]
63 self.measure_cmd_resources(cmd, 'build',
64 'bitbake' + self.build_target,
65 save_bs=True)
66 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060067
68
69class Test2(BuildPerfTestCase):
70 build_target = 'core-image-sato'
71
72 def test2(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050073 """Run core-image-sato do_rootfs with sstate"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060074 # Build once in order to populate sstate cache
Brad Bishop6e60e8b2018-02-01 10:27:11 -050075 self.run_cmd(['bitbake', self.build_target])
Patrick Williamsc0f7c042017-02-23 20:41:17 -060076
77 self.rm_tmp()
78 self.rm_cache()
79 self.sync()
80 cmd = ['bitbake', self.build_target, '-c', 'rootfs']
81 self.measure_cmd_resources(cmd, 'do_rootfs', 'bitbake do_rootfs')
82
83
84class Test3(BuildPerfTestCase):
85
86 def test3(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050087 """Bitbake parsing (bitbake -p)"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060088 # Drop all caches and parse
89 self.rm_cache()
90 oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
91 self.measure_cmd_resources(['bitbake', '-p'], 'parse_1',
92 'bitbake -p (no caches)')
93 # Drop tmp/cache
94 oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
95 self.measure_cmd_resources(['bitbake', '-p'], 'parse_2',
96 'bitbake -p (no tmp/cache)')
97 # Parse with fully cached data
98 self.measure_cmd_resources(['bitbake', '-p'], 'parse_3',
99 'bitbake -p (cached)')
100
101
102class Test4(BuildPerfTestCase):
103 build_target = 'core-image-sato'
104
105 def test4(self):
106 """eSDK metrics"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500107 self.run_cmd(['bitbake', '-c', 'do_populate_sdk_ext',
108 self.build_target])
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600109 self.bb_vars = get_bb_vars(None, self.build_target)
110 tmp_dir = self.bb_vars['TMPDIR']
111 installer = os.path.join(
112 self.bb_vars['SDK_DEPLOY'],
113 self.bb_vars['TOOLCHAINEXT_OUTPUTNAME'] + '.sh')
114 # Measure installer size
115 self.measure_disk_usage(installer, 'installer_bin', 'eSDK installer',
116 apparent_size=True)
117 # Measure deployment time and deployed size
118 deploy_dir = os.path.join(tmp_dir, 'esdk-deploy')
119 if os.path.exists(deploy_dir):
120 shutil.rmtree(deploy_dir)
121 self.sync()
122 self.measure_cmd_resources([installer, '-y', '-d', deploy_dir],
123 'deploy', 'eSDK deploy')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500124 #make sure bitbake is unloaded
125 self.sync()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600126 self.measure_disk_usage(deploy_dir, 'deploy_dir', 'deploy dir',
127 apparent_size=True)