test_basic.py 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. import oe.path
  16. from oeqa.buildperf import BuildPerfTestCase
  17. from oeqa.utils.commands import get_bb_vars
  18. class Test1P1(BuildPerfTestCase):
  19. build_target = 'core-image-sato'
  20. def test1(self):
  21. """Build core-image-sato"""
  22. self.rm_tmp()
  23. self.rm_sstate()
  24. self.rm_cache()
  25. self.sync()
  26. self.measure_cmd_resources(['bitbake', self.build_target], 'build',
  27. 'bitbake ' + self.build_target, save_bs=True)
  28. self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
  29. class Test1P2(BuildPerfTestCase):
  30. build_target = 'virtual/kernel'
  31. def test12(self):
  32. """Build virtual/kernel"""
  33. # Build and cleans state in order to get all dependencies pre-built
  34. self.run_cmd(['bitbake', self.build_target])
  35. self.run_cmd(['bitbake', self.build_target, '-c', 'cleansstate'])
  36. self.sync()
  37. self.measure_cmd_resources(['bitbake', self.build_target], 'build',
  38. 'bitbake ' + self.build_target)
  39. class Test1P3(BuildPerfTestCase):
  40. build_target = 'core-image-sato'
  41. def test13(self):
  42. """Build core-image-sato with rm_work enabled"""
  43. postfile = os.path.join(self.tmp_dir, 'postfile.conf')
  44. with open(postfile, 'w') as fobj:
  45. fobj.write('INHERIT += "rm_work"\n')
  46. self.rm_tmp()
  47. self.rm_sstate()
  48. self.rm_cache()
  49. self.sync()
  50. cmd = ['bitbake', '-R', postfile, self.build_target]
  51. self.measure_cmd_resources(cmd, 'build',
  52. 'bitbake' + self.build_target,
  53. save_bs=True)
  54. self.measure_disk_usage(self.bb_vars['TMPDIR'], 'tmpdir', 'tmpdir')
  55. class Test2(BuildPerfTestCase):
  56. build_target = 'core-image-sato'
  57. def test2(self):
  58. """Run core-image-sato do_rootfs with sstate"""
  59. # Build once in order to populate sstate cache
  60. self.run_cmd(['bitbake', self.build_target])
  61. self.rm_tmp()
  62. self.rm_cache()
  63. self.sync()
  64. cmd = ['bitbake', self.build_target, '-c', 'rootfs']
  65. self.measure_cmd_resources(cmd, 'do_rootfs', 'bitbake do_rootfs')
  66. class Test3(BuildPerfTestCase):
  67. def test3(self):
  68. """Bitbake parsing (bitbake -p)"""
  69. # Drop all caches and parse
  70. self.rm_cache()
  71. oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
  72. self.measure_cmd_resources(['bitbake', '-p'], 'parse_1',
  73. 'bitbake -p (no caches)')
  74. # Drop tmp/cache
  75. oe.path.remove(os.path.join(self.bb_vars['TMPDIR'], 'cache'), True)
  76. self.measure_cmd_resources(['bitbake', '-p'], 'parse_2',
  77. 'bitbake -p (no tmp/cache)')
  78. # Parse with fully cached data
  79. self.measure_cmd_resources(['bitbake', '-p'], 'parse_3',
  80. 'bitbake -p (cached)')
  81. class Test4(BuildPerfTestCase):
  82. build_target = 'core-image-sato'
  83. def test4(self):
  84. """eSDK metrics"""
  85. self.run_cmd(['bitbake', '-c', 'do_populate_sdk_ext',
  86. self.build_target])
  87. self.bb_vars = get_bb_vars(None, self.build_target)
  88. tmp_dir = self.bb_vars['TMPDIR']
  89. installer = os.path.join(
  90. self.bb_vars['SDK_DEPLOY'],
  91. self.bb_vars['TOOLCHAINEXT_OUTPUTNAME'] + '.sh')
  92. # Measure installer size
  93. self.measure_disk_usage(installer, 'installer_bin', 'eSDK installer',
  94. apparent_size=True)
  95. # Measure deployment time and deployed size
  96. deploy_dir = os.path.join(tmp_dir, 'esdk-deploy')
  97. if os.path.exists(deploy_dir):
  98. shutil.rmtree(deploy_dir)
  99. self.sync()
  100. self.measure_cmd_resources([installer, '-y', '-d', deploy_dir],
  101. 'deploy', 'eSDK deploy')
  102. self.measure_disk_usage(deploy_dir, 'deploy_dir', 'deploy dir',
  103. apparent_size=True)