Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1 | # 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""" |
| 13 | import os |
| 14 | import shutil |
| 15 | |
| 16 | import oe.path |
| 17 | from oeqa.buildperf import BuildPerfTestCase |
Brad Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 18 | from oeqa.utils.commands import get_bb_var, get_bb_vars |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 19 | |
| 20 | class Test1P1(BuildPerfTestCase): |
| 21 | build_target = 'core-image-sato' |
| 22 | |
| 23 | def test1(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 24 | """Build core-image-sato""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 25 | 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 Bishop | 316dfdd | 2018-06-25 12:45:53 -0400 | [diff] [blame] | 32 | 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] | 33 | |
| 34 | |
| 35 | class Test1P2(BuildPerfTestCase): |
| 36 | build_target = 'virtual/kernel' |
| 37 | |
| 38 | def test12(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 39 | """Build virtual/kernel""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 40 | # Build and cleans state in order to get all dependencies pre-built |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 41 | self.run_cmd(['bitbake', self.build_target]) |
| 42 | self.run_cmd(['bitbake', self.build_target, '-c', 'cleansstate']) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 43 | |
| 44 | self.sync() |
| 45 | self.measure_cmd_resources(['bitbake', self.build_target], 'build', |
| 46 | 'bitbake ' + self.build_target) |
| 47 | |
| 48 | |
| 49 | class Test1P3(BuildPerfTestCase): |
| 50 | build_target = 'core-image-sato' |
| 51 | |
| 52 | def test13(self): |
| 53 | """Build core-image-sato with rm_work enabled""" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 54 | postfile = os.path.join(self.tmp_dir, 'postfile.conf') |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 55 | with open(postfile, 'w') as fobj: |
| 56 | fobj.write('INHERIT += "rm_work"\n') |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 57 | |
| 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 67 | |
| 68 | |
| 69 | class Test2(BuildPerfTestCase): |
| 70 | build_target = 'core-image-sato' |
| 71 | |
| 72 | def test2(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 73 | """Run core-image-sato do_rootfs with sstate""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 74 | # Build once in order to populate sstate cache |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 75 | self.run_cmd(['bitbake', self.build_target]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 76 | |
| 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 | |
| 84 | class Test3(BuildPerfTestCase): |
| 85 | |
| 86 | def test3(self): |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 87 | """Bitbake parsing (bitbake -p)""" |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 88 | # 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 | |
| 102 | class Test4(BuildPerfTestCase): |
| 103 | build_target = 'core-image-sato' |
| 104 | |
| 105 | def test4(self): |
| 106 | """eSDK metrics""" |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 107 | self.run_cmd(['bitbake', '-c', 'do_populate_sdk_ext', |
| 108 | self.build_target]) |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 109 | 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 Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame] | 124 | #make sure bitbake is unloaded |
| 125 | self.sync() |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 126 | self.measure_disk_usage(deploy_dir, 'deploy_dir', 'deploy dir', |
| 127 | apparent_size=True) |