PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/meta/lib/oeqa/selftest/buildoptions.py

https://gitlab.com/actawithamana/poky
Python | 200 lines | 186 code | 13 blank | 1 comment | 9 complexity | 7f8bc98322f82a57f0f0406fd177bd70 MD5 | raw file
  1. import os
  2. import re
  3. import glob as g
  4. import shutil
  5. import tempfile
  6. from oeqa.selftest.base import oeSelfTest
  7. from oeqa.selftest.buildhistory import BuildhistoryBase
  8. from oeqa.utils.commands import runCmd, bitbake, get_bb_var
  9. import oeqa.utils.ftools as ftools
  10. from oeqa.utils.decorators import testcase
  11. class ImageOptionsTests(oeSelfTest):
  12. @testcase(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 cleanall 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("NOTE: load old install solution for incremental install\nNOTE: old install solution not exist\nNOTE: creating new install solution for incremental install(\n.*)*NOTE: Installing the following packages:.*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("NOTE: load old install solution for incremental install\nNOTE: creating new install solution for incremental install(\n.*)*NOTE: incremental removed:.*openssh-sshd-.*", log_data_removed)
  29. self.assertTrue(incremental_removed, msg = "Match failed in:\n%s" % log_data_removed)
  30. @testcase(286)
  31. def test_ccache_tool(self):
  32. bitbake("ccache-native")
  33. self.assertTrue(os.path.isfile(os.path.join(get_bb_var('STAGING_BINDIR_NATIVE', 'ccache-native'), "ccache")), msg = "No ccache found under %s" % str(get_bb_var('STAGING_BINDIR_NATIVE', 'ccache-native')))
  34. self.write_config('INHERIT += "ccache"')
  35. bitbake("m4 -c cleansstate")
  36. bitbake("m4 -c compile")
  37. self.addCleanup(bitbake, 'ccache-native -ccleansstate')
  38. res = runCmd("grep ccache %s" % (os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")), ignore_status=True)
  39. self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile. For further details: %s" % os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile"))
  40. @testcase(1435)
  41. def test_read_only_image(self):
  42. self.write_config('IMAGE_FEATURES += "read-only-rootfs"')
  43. bitbake("core-image-sato")
  44. # do_image will fail if there are any pending postinsts
  45. class DiskMonTest(oeSelfTest):
  46. @testcase(277)
  47. def test_stoptask_behavior(self):
  48. self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},100000G,100K"')
  49. res = bitbake("m4", ignore_status = True)
  50. 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)
  51. self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
  52. self.write_config('BB_DISKMON_DIRS = "ABORT,${TMPDIR},100000G,100K"')
  53. res = bitbake("m4", ignore_status = True)
  54. 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)
  55. self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
  56. self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},100000G,100K"')
  57. res = bitbake("m4")
  58. 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)
  59. class SanityOptionsTest(oeSelfTest):
  60. def getline(self, res, line):
  61. for l in res.output.split('\n'):
  62. if line in l:
  63. return l
  64. @testcase(927)
  65. def test_options_warnqa_errorqa_switch(self):
  66. bitbake("xcursor-transparent-theme -ccleansstate")
  67. self.write_config("INHERIT_remove = \"report-error\"")
  68. if "packages-list" not in get_bb_var("ERROR_QA"):
  69. self.append_config("ERROR_QA_append = \" packages-list\"")
  70. self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
  71. res = bitbake("xcursor-transparent-theme", ignore_status=True)
  72. self.delete_recipeinc('xcursor-transparent-theme')
  73. line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.")
  74. self.assertTrue(line and line.startswith("ERROR:"), msg=res.output)
  75. self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
  76. self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
  77. self.append_config('ERROR_QA_remove = "packages-list"')
  78. self.append_config('WARN_QA_append = " packages-list"')
  79. bitbake("xcursor-transparent-theme -ccleansstate")
  80. res = bitbake("xcursor-transparent-theme")
  81. self.delete_recipeinc('xcursor-transparent-theme')
  82. line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.")
  83. self.assertTrue(line and line.startswith("WARNING:"), msg=res.output)
  84. @testcase(278)
  85. def test_sanity_unsafe_script_references(self):
  86. self.write_config('WARN_QA_append = " unsafe-references-in-scripts"')
  87. bitbake("-ccleansstate gzip")
  88. res = bitbake("gzip")
  89. line = self.getline(res, "QA Issue: gzip")
  90. self.assertFalse(line, "WARNING: QA Issue: gzip message is present in bitbake's output and shouldn't be: %s" % res.output)
  91. self.append_config("""
  92. do_install_append_pn-gzip () {
  93. echo "\n${bindir}/test" >> ${D}${bindir}/zcat
  94. }
  95. """)
  96. res = bitbake("gzip")
  97. line = self.getline(res, "QA Issue: gzip")
  98. self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: gzip message is not present in bitbake's output: %s" % res.output)
  99. @testcase(1434)
  100. def test_sanity_unsafe_binary_references(self):
  101. self.write_config('WARN_QA_append = " unsafe-references-in-binaries"')
  102. bitbake("-ccleansstate nfs-utils")
  103. #res = bitbake("nfs-utils")
  104. # FIXME when nfs-utils passes this test
  105. #line = self.getline(res, "QA Issue: nfs-utils")
  106. #self.assertFalse(line, "WARNING: QA Issue: nfs-utils message is present in bitbake's output and shouldn't be: %s" % res.output)
  107. # self.append_config("""
  108. #do_install_append_pn-nfs-utils () {
  109. # echo "\n${bindir}/test" >> ${D}${base_sbindir}/osd_login
  110. #}
  111. #""")
  112. res = bitbake("nfs-utils")
  113. line = self.getline(res, "QA Issue: nfs-utils")
  114. self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output)
  115. @testcase(1421)
  116. def test_layer_without_git_dir(self):
  117. """
  118. Summary: Test that layer git revisions are displayed and do not fail without git repository
  119. Expected: The build to be successful and without "fatal" errors
  120. Product: oe-core
  121. Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
  122. AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
  123. """
  124. dirpath = tempfile.mkdtemp()
  125. dummy_layer_name = 'meta-dummy'
  126. dummy_layer_path = os.path.join(dirpath, dummy_layer_name)
  127. dummy_layer_conf_dir = os.path.join(dummy_layer_path, 'conf')
  128. os.makedirs(dummy_layer_conf_dir)
  129. dummy_layer_conf_path = os.path.join(dummy_layer_conf_dir, 'layer.conf')
  130. dummy_layer_content = 'BBPATH .= ":${LAYERDIR}"\n' \
  131. 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' \
  132. 'BBFILE_COLLECTIONS += "%s"\n' \
  133. 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' \
  134. 'BBFILE_PRIORITY_%s = "6"\n' % (dummy_layer_name, dummy_layer_name, dummy_layer_name)
  135. ftools.write_file(dummy_layer_conf_path, dummy_layer_content)
  136. bblayers_conf = 'BBLAYERS += "%s"\n' % dummy_layer_path
  137. self.write_bblayers_config(bblayers_conf)
  138. test_recipe = 'ed'
  139. ret = bitbake('-n %s' % test_recipe)
  140. err = 'fatal: Not a git repository'
  141. shutil.rmtree(dirpath)
  142. self.assertNotIn(err, ret.output)
  143. class BuildhistoryTests(BuildhistoryBase):
  144. @testcase(293)
  145. def test_buildhistory_basic(self):
  146. self.run_buildhistory_operation('xcursor-transparent-theme')
  147. self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR')), "buildhistory dir was not created.")
  148. @testcase(294)
  149. def test_buildhistory_buildtime_pr_backwards(self):
  150. self.add_command_to_tearDown('cleanup-workdir')
  151. target = 'xcursor-transparent-theme'
  152. error = "ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1.* to .*-r0.*)" % target
  153. self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True)
  154. self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error)
  155. class ArchiverTest(oeSelfTest):
  156. @testcase(926)
  157. def test_arch_work_dir_and_export_source(self):
  158. """
  159. Test for archiving the work directory and exporting the source files.
  160. """
  161. self.add_command_to_tearDown('cleanup-workdir')
  162. self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"")
  163. res = bitbake("xcursor-transparent-theme", ignore_status=True)
  164. self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output)
  165. pkgs_path = g.glob(str(self.builddir) + "/tmp/deploy/sources/allarch*/xcurs*")
  166. src_file_glob = str(pkgs_path[0]) + "/xcursor*.src.rpm"
  167. tar_file_glob = str(pkgs_path[0]) + "/xcursor*.tar.gz"
  168. self.assertTrue((g.glob(src_file_glob) and g.glob(tar_file_glob)), "Couldn't find .src.rpm and .tar.gz files under tmp/deploy/sources/allarch*/xcursor*")