Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | # Copyright (c) 2016, Intel Corporation. |
| 2 | # |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 3 | # SPDX-License-Identifier: GPL-2.0-only |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 4 | # |
| 5 | """Basic set of build performance tests""" |
| 6 | import os |
| 7 | import shutil |
| 8 | |
| 9 | import oe.path |
| 10 | from oeqa.buildperf import BuildPerfTestCase |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 11 | from oeqa.utils.commands import get_bb_var, get_bb_vars |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 12 | |
| 13 | class Test1P1(BuildPerfTestCase): |
| 14 | build_target = 'core-image-sato' |
| 15 | |
| 16 | def test1(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 17 | """Build core-image-sato""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 18 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 25 | self.measure_disk_usage(get_bb_var("IMAGE_ROOTFS", self.build_target), 'rootfs', 'rootfs', True) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 26 | |
| 27 | |
| 28 | class Test1P2(BuildPerfTestCase): |
| 29 | build_target = 'virtual/kernel' |
| 30 | |
| 31 | def test12(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 32 | """Build virtual/kernel""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | # Build and cleans state in order to get all dependencies pre-built |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 34 | self.run_cmd(['bitbake', self.build_target]) |
| 35 | self.run_cmd(['bitbake', self.build_target, '-c', 'cleansstate']) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 36 | |
| 37 | self.sync() |
| 38 | self.measure_cmd_resources(['bitbake', self.build_target], 'build', |
| 39 | 'bitbake ' + self.build_target) |
| 40 | |
| 41 | |
| 42 | class Test1P3(BuildPerfTestCase): |
| 43 | build_target = 'core-image-sato' |
| 44 | |
| 45 | def test13(self): |
| 46 | """Build core-image-sato with rm_work enabled""" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | postfile = os.path.join(self.tmp_dir, 'postfile.conf') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 48 | with open(postfile, 'w') as fobj: |
| 49 | fobj.write('INHERIT += "rm_work"\n') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 50 | |
| 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 60 | |
| 61 | |
| 62 | class Test2(BuildPerfTestCase): |
| 63 | build_target = 'core-image-sato' |
| 64 | |
| 65 | def test2(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 66 | """Run core-image-sato do_rootfs with sstate""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 67 | # Build once in order to populate sstate cache |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 68 | self.run_cmd(['bitbake', self.build_target]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 69 | |
| 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 | |
| 77 | class Test3(BuildPerfTestCase): |
| 78 | |
| 79 | def test3(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 80 | """Bitbake parsing (bitbake -p)""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 81 | # 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 | |
| 95 | class Test4(BuildPerfTestCase): |
| 96 | build_target = 'core-image-sato' |
| 97 | |
| 98 | def test4(self): |
| 99 | """eSDK metrics""" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 100 | self.run_cmd(['bitbake', '-c', 'do_populate_sdk_ext', |
| 101 | self.build_target]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 102 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 117 | #make sure bitbake is unloaded |
| 118 | self.sync() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 119 | self.measure_disk_usage(deploy_dir, 'deploy_dir', 'deploy dir', |
| 120 | apparent_size=True) |