blob: 2104617ba314b79f6b445d5f7d7f1e87d8c87142 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001# Copyright (c) 2016, Intel Corporation.
2#
Brad Bishopc342db32019-05-15 21:57:59 -04003# SPDX-License-Identifier: GPL-2.0-only
Patrick Williamsc0f7c042017-02-23 20:41:17 -06004#
5"""Basic set of build performance tests"""
6import os
7import shutil
8
9import oe.path
10from oeqa.buildperf import BuildPerfTestCase
Brad Bishop316dfdd2018-06-25 12:45:53 -040011from oeqa.utils.commands import get_bb_var, get_bb_vars
Patrick Williamsc0f7c042017-02-23 20:41:17 -060012
13class Test1P1(BuildPerfTestCase):
14 build_target = 'core-image-sato'
15
16 def test1(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050017 """Build core-image-sato"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060018 self.rm_tmp()
19 self.rm_sstate()
20 self.rm_cache()
21 self.sync()
22 self.measure_cmd_resources(['bitbake', self.build_target], 'build',
23 'bitbake ' + self.build_target, save_bs=True)
24 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
Brad Bishop316dfdd2018-06-25 12:45:53 -040025 self.measure_disk_usage(get_bb_var("IMAGE_ROOTFS", self.build_target), 'rootfs', 'rootfs', True)
Patrick Williamsc0f7c042017-02-23 20:41:17 -060026
27
28class Test1P2(BuildPerfTestCase):
29 build_target = 'virtual/kernel'
30
31 def test12(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050032 """Build virtual/kernel"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060033 # Build and cleans state in order to get all dependencies pre-built
Brad Bishop6e60e8b2018-02-01 10:27:11 -050034 self.run_cmd(['bitbake', self.build_target])
35 self.run_cmd(['bitbake', self.build_target, '-c', 'cleansstate'])
Patrick Williamsc0f7c042017-02-23 20:41:17 -060036
37 self.sync()
38 self.measure_cmd_resources(['bitbake', self.build_target], 'build',
39 'bitbake ' + self.build_target)
40
41
42class Test1P3(BuildPerfTestCase):
43 build_target = 'core-image-sato'
44
45 def test13(self):
46 """Build core-image-sato with rm_work enabled"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -050047 postfile = os.path.join(self.tmp_dir, 'postfile.conf')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060048 with open(postfile, 'w') as fobj:
49 fobj.write('INHERIT += "rm_work"\n')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050
51 self.rm_tmp()
52 self.rm_sstate()
53 self.rm_cache()
54 self.sync()
55 cmd = ['bitbake', '-R', postfile, self.build_target]
56 self.measure_cmd_resources(cmd, 'build',
57 'bitbake' + self.build_target,
58 save_bs=True)
59 self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
Patrick Williamsc0f7c042017-02-23 20:41:17 -060060
61
62class Test2(BuildPerfTestCase):
63 build_target = 'core-image-sato'
64
65 def test2(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050066 """Run core-image-sato do_rootfs with sstate"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060067 # Build once in order to populate sstate cache
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068 self.run_cmd(['bitbake', self.build_target])
Patrick Williamsc0f7c042017-02-23 20:41:17 -060069
70 self.rm_tmp()
71 self.rm_cache()
72 self.sync()
73 cmd = ['bitbake', self.build_target, '-c', 'rootfs']
74 self.measure_cmd_resources(cmd, 'do_rootfs', 'bitbake do_rootfs')
75
76
77class Test3(BuildPerfTestCase):
78
79 def test3(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050080 """Bitbake parsing (bitbake -p)"""
Patrick Williamsc0f7c042017-02-23 20:41:17 -060081 # Drop all caches and parse
82 self.rm_cache()
83 oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
84 self.measure_cmd_resources(['bitbake', '-p'], 'parse_1',
85 'bitbake -p (no caches)')
86 # Drop tmp/cache
87 oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
88 self.measure_cmd_resources(['bitbake', '-p'], 'parse_2',
89 'bitbake -p (no tmp/cache)')
90 # Parse with fully cached data
91 self.measure_cmd_resources(['bitbake', '-p'], 'parse_3',
92 'bitbake -p (cached)')
93
94
95class Test4(BuildPerfTestCase):
96 build_target = 'core-image-sato'
97
98 def test4(self):
99 """eSDK metrics"""
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500100 self.run_cmd(['bitbake', '-c', 'do_populate_sdk_ext',
101 self.build_target])
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600102 self.bb_vars = get_bb_vars(None, self.build_target)
103 tmp_dir = self.bb_vars['TMPDIR']
104 installer = os.path.join(
105 self.bb_vars['SDK_DEPLOY'],
106 self.bb_vars['TOOLCHAINEXT_OUTPUTNAME'] + '.sh')
107 # Measure installer size
108 self.measure_disk_usage(installer, 'installer_bin', 'eSDK installer',
109 apparent_size=True)
110 # Measure deployment time and deployed size
111 deploy_dir = os.path.join(tmp_dir, 'esdk-deploy')
112 if os.path.exists(deploy_dir):
113 shutil.rmtree(deploy_dir)
114 self.sync()
115 self.measure_cmd_resources([installer, '-y', '-d', deploy_dir],
116 'deploy', 'eSDK deploy')
Brad Bishopd7bf8c12018-02-25 22:55:05 -0500117 #make sure bitbake is unloaded
118 self.sync()
Patrick Williamsc0f7c042017-02-23 20:41:17 -0600119 self.measure_disk_usage(deploy_dir, 'deploy_dir', 'deploy dir',
120 apparent_size=True)