buildoptions.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. import os
  2. import re
  3. import glob as g
  4. import shutil
  5. import tempfile
  6. from oeqa.selftest.case import OESelftestTestCase
  7. from oeqa.selftest.cases.buildhistory import BuildhistoryBase
  8. from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
  9. import oeqa.utils.ftools as ftools
  10. from oeqa.core.decorator.oeid import OETestID
  11. class ImageOptionsTests(OESelftestTestCase):
  12. @OETestID(761)
  13. def test_incremental_image_generation(self):
  14. image_pkgtype = get_bb_var("IMAGE_PKGTYPE")
  15. if image_pkgtype != 'rpm':
  16. self.skipTest('Not using RPM as main package format')
  17. bitbake("-c clean core-image-minimal")
  18. self.write_config('INC_RPM_IMAGE_GEN = "1"')
  19. self.append_config('IMAGE_FEATURES += "ssh-server-openssh"')
  20. bitbake("core-image-minimal")
  21. log_data_file = os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs")
  22. log_data_created = ftools.read_file(log_data_file)
  23. incremental_created = re.search(r"Installing\s*:\s*packagegroup-core-ssh-openssh", log_data_created)
  24. self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"')
  25. self.assertTrue(incremental_created, msg = "Match failed in:\n%s" % log_data_created)
  26. bitbake("core-image-minimal")
  27. log_data_removed = ftools.read_file(log_data_file)
  28. incremental_removed = re.search(r"Erasing\s*:\s*packagegroup-core-ssh-openssh", log_data_removed)
  29. self.assertTrue(incremental_removed, msg = "Match failed in:\n%s" % log_data_removed)
  30. @OETestID(286)
  31. def test_ccache_tool(self):
  32. bitbake("ccache-native")
  33. bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'ccache-native')
  34. p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "ccache"
  35. self.assertTrue(os.path.isfile(p), msg = "No ccache found (%s)" % p)
  36. self.write_config('INHERIT += "ccache"')
  37. self.add_command_to_tearDown('bitbake -c clean m4')
  38. bitbake("m4 -c clean")
  39. bitbake("m4 -f -c compile")
  40. log_compile = os.path.join(get_bb_var("WORKDIR","m4"), "temp/log.do_compile")
  41. with open(log_compile, "r") as f:
  42. loglines = "".join(f.readlines())
  43. self.assertIn("ccache", loglines, msg="No match for ccache in m4 log.do_compile. For further details: %s" % log_compile)
  44. @OETestID(1435)
  45. def test_read_only_image(self):
  46. distro_features = get_bb_var('DISTRO_FEATURES')
  47. if not ('x11' in distro_features and 'opengl' in distro_features):
  48. self.skipTest('core-image-sato requires x11 and opengl in distro features')
  49. self.write_config('IMAGE_FEATURES += "read-only-rootfs"')
  50. bitbake("core-image-sato")
  51. # do_image will fail if there are any pending postinsts
  52. class DiskMonTest(OESelftestTestCase):
  53. @OETestID(277)
  54. def test_stoptask_behavior(self):
  55. self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},100000G,100K"')
  56. res = bitbake("delay -c delay", ignore_status = True)
  57. self.assertTrue('ERROR: No new tasks can be executed since the disk space monitor action is "STOPTASKS"!' in res.output, msg = "Tasks should have stopped. Disk monitor is set to STOPTASK: %s" % res.output)
  58. self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
  59. self.write_config('BB_DISKMON_DIRS = "ABORT,${TMPDIR},100000G,100K"')
  60. res = bitbake("delay -c delay", ignore_status = True)
  61. self.assertTrue('ERROR: Immediately abort since the disk space monitor action is "ABORT"!' in res.output, "Tasks should have been aborted immediatelly. Disk monitor is set to ABORT: %s" % res.output)
  62. self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
  63. self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},100000G,100K"')
  64. res = bitbake("delay -c delay")
  65. self.assertTrue('WARNING: The free space' in res.output, msg = "A warning should have been displayed for disk monitor is set to WARN: %s" %res.output)
  66. class SanityOptionsTest(OESelftestTestCase):
  67. def getline(self, res, line):
  68. for l in res.output.split('\n'):
  69. if line in l:
  70. return l
  71. @OETestID(927)
  72. def test_options_warnqa_errorqa_switch(self):
  73. self.write_config("INHERIT_remove = \"report-error\"")
  74. if "packages-list" not in get_bb_var("ERROR_QA"):
  75. self.append_config("ERROR_QA_append = \" packages-list\"")
  76. self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
  77. self.add_command_to_tearDown('bitbake -c clean xcursor-transparent-theme')
  78. res = bitbake("xcursor-transparent-theme -f -c package", ignore_status=True)
  79. self.delete_recipeinc('xcursor-transparent-theme')
  80. line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.")
  81. self.assertTrue(line and line.startswith("ERROR:"), msg=res.output)
  82. self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
  83. self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
  84. self.append_config('ERROR_QA_remove = "packages-list"')
  85. self.append_config('WARN_QA_append = " packages-list"')
  86. res = bitbake("xcursor-transparent-theme -f -c package")
  87. self.delete_recipeinc('xcursor-transparent-theme')
  88. line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.")
  89. self.assertTrue(line and line.startswith("WARNING:"), msg=res.output)
  90. @OETestID(1421)
  91. def test_layer_without_git_dir(self):
  92. """
  93. Summary: Test that layer git revisions are displayed and do not fail without git repository
  94. Expected: The build to be successful and without "fatal" errors
  95. Product: oe-core
  96. Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
  97. AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
  98. """
  99. dirpath = tempfile.mkdtemp()
  100. dummy_layer_name = 'meta-dummy'
  101. dummy_layer_path = os.path.join(dirpath, dummy_layer_name)
  102. dummy_layer_conf_dir = os.path.join(dummy_layer_path, 'conf')
  103. os.makedirs(dummy_layer_conf_dir)
  104. dummy_layer_conf_path = os.path.join(dummy_layer_conf_dir, 'layer.conf')
  105. dummy_layer_content = 'BBPATH .= ":${LAYERDIR}"\n' \
  106. 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' \
  107. 'BBFILE_COLLECTIONS += "%s"\n' \
  108. 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' \
  109. 'BBFILE_PRIORITY_%s = "6"\n' % (dummy_layer_name, dummy_layer_name, dummy_layer_name)
  110. ftools.write_file(dummy_layer_conf_path, dummy_layer_content)
  111. bblayers_conf = 'BBLAYERS += "%s"\n' % dummy_layer_path
  112. self.write_bblayers_config(bblayers_conf)
  113. test_recipe = 'ed'
  114. ret = bitbake('-n %s' % test_recipe)
  115. err = 'fatal: Not a git repository'
  116. shutil.rmtree(dirpath)
  117. self.assertNotIn(err, ret.output)
  118. class BuildhistoryTests(BuildhistoryBase):
  119. @OETestID(293)
  120. def test_buildhistory_basic(self):
  121. self.run_buildhistory_operation('xcursor-transparent-theme')
  122. self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR')), "buildhistory dir was not created.")
  123. @OETestID(294)
  124. def test_buildhistory_buildtime_pr_backwards(self):
  125. target = 'xcursor-transparent-theme'
  126. error = "ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1.* to .*-r0.*)" % target
  127. self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True)
  128. self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error)
  129. class ArchiverTest(OESelftestTestCase):
  130. @OETestID(926)
  131. def test_arch_work_dir_and_export_source(self):
  132. """
  133. Test for archiving the work directory and exporting the source files.
  134. """
  135. self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"")
  136. res = bitbake("xcursor-transparent-theme", ignore_status=True)
  137. self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output)
  138. deploy_dir_src = get_bb_var('DEPLOY_DIR_SRC')
  139. pkgs_path = g.glob(str(deploy_dir_src) + "/allarch*/xcurs*")
  140. src_file_glob = str(pkgs_path[0]) + "/xcursor*.src.rpm"
  141. tar_file_glob = str(pkgs_path[0]) + "/xcursor*.tar.gz"
  142. self.assertTrue((g.glob(src_file_glob) and g.glob(tar_file_glob)), "Couldn't find .src.rpm and .tar.gz files under %s/allarch*/xcursor*" % deploy_dir_src)
  143. class ToolchainOptions(OESelftestTestCase):
  144. def test_toolchain_fortran(self):
  145. """
  146. Test whether we can enable and build fortran and its supporting libraries
  147. """
  148. features = 'FORTRAN_forcevariable = ",fortran"\n'
  149. features += 'RUNTIMETARGET_append_pn-gcc-runtime = " libquadmath"\n'
  150. self.write_config(features)
  151. bitbake('gcc-runtime libgfortran')
  152. class SourceMirroring(OESelftestTestCase):
  153. # Can we download everything from the Yocto Sources Mirror over http only
  154. def test_yocto_source_mirror(self):
  155. self.write_config("""
  156. BB_ALLOWED_NETWORKS = "downloads.yoctoproject.org"
  157. MIRRORS = ""
  158. DL_DIR = "${TMPDIR}/test_downloads"
  159. PREMIRRORS = "\\
  160. bzr://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  161. cvs://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  162. git://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  163. gitsm://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  164. hg://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  165. osc://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  166. p4://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  167. svn://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  168. ftp://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  169. http://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n \\
  170. https://.*/.* http://downloads.yoctoproject.org/mirror/sources/ \\n"
  171. """)
  172. bitbake("world --runall fetch")