blob: a6e0203f5ab8065d29607ec1b493d7d61c1986ef [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001import os
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002import re
3import glob as g
Patrick Williamsd8c66bc2016-06-20 12:57:21 -05004import shutil
5import tempfile
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006from oeqa.selftest.base import oeSelfTest
7from oeqa.selftest.buildhistory import BuildhistoryBase
Brad Bishop6e60e8b2018-02-01 10:27:11 -05008from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
Patrick Williamsc124f4f2015-09-15 14:41:29 -05009import oeqa.utils.ftools as ftools
10from oeqa.utils.decorators import testcase
11
12class ImageOptionsTests(oeSelfTest):
13
14 @testcase(761)
15 def test_incremental_image_generation(self):
16 image_pkgtype = get_bb_var("IMAGE_PKGTYPE")
17 if image_pkgtype != 'rpm':
18 self.skipTest('Not using RPM as main package format')
Brad Bishop6e60e8b2018-02-01 10:27:11 -050019 bitbake("-c clean core-image-minimal")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050020 self.write_config('INC_RPM_IMAGE_GEN = "1"')
21 self.append_config('IMAGE_FEATURES += "ssh-server-openssh"')
22 bitbake("core-image-minimal")
23 log_data_file = os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs")
24 log_data_created = ftools.read_file(log_data_file)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050025 incremental_created = re.search("Installing : packagegroup-core-ssh-openssh", log_data_created)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026 self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"')
27 self.assertTrue(incremental_created, msg = "Match failed in:\n%s" % log_data_created)
28 bitbake("core-image-minimal")
29 log_data_removed = ftools.read_file(log_data_file)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050030 incremental_removed = re.search("Erasing : packagegroup-core-ssh-openssh", log_data_removed)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050031 self.assertTrue(incremental_removed, msg = "Match failed in:\n%s" % log_data_removed)
32
Patrick Williamsc124f4f2015-09-15 14:41:29 -050033 @testcase(286)
34 def test_ccache_tool(self):
35 bitbake("ccache-native")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050036 bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'ccache-native')
37 p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "ccache"
38 self.assertTrue(os.path.isfile(p), msg = "No ccache found (%s)" % p)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050039 self.write_config('INHERIT += "ccache"')
Brad Bishop37a0e4d2017-12-04 01:01:44 -050040 self.add_command_to_tearDown('bitbake -c clean m4')
41 bitbake("m4 -f -c compile")
Brad Bishop6e60e8b2018-02-01 10:27:11 -050042 log_compile = os.path.join(get_bb_var("WORKDIR","m4"), "temp/log.do_compile")
43 res = runCmd("grep ccache %s" % log_compile, ignore_status=True)
44 self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile. For further details: %s" % log_compile)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050045
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050046 @testcase(1435)
47 def test_read_only_image(self):
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048 distro_features = get_bb_var('DISTRO_FEATURES')
49 if not ('x11' in distro_features and 'opengl' in distro_features):
50 self.skipTest('core-image-sato requires x11 and opengl in distro features')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050051 self.write_config('IMAGE_FEATURES += "read-only-rootfs"')
52 bitbake("core-image-sato")
53 # do_image will fail if there are any pending postinsts
Patrick Williamsc124f4f2015-09-15 14:41:29 -050054
55class DiskMonTest(oeSelfTest):
56
57 @testcase(277)
58 def test_stoptask_behavior(self):
59 self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},100000G,100K"')
60 res = bitbake("m4", ignore_status = True)
61 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)
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 = "ABORT,${TMPDIR},100000G,100K"')
64 res = bitbake("m4", ignore_status = True)
65 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)
66 self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
67 self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},100000G,100K"')
68 res = bitbake("m4")
69 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)
70
71class SanityOptionsTest(oeSelfTest):
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050072 def getline(self, res, line):
73 for l in res.output.split('\n'):
74 if line in l:
75 return l
Patrick Williamsc124f4f2015-09-15 14:41:29 -050076
77 @testcase(927)
78 def test_options_warnqa_errorqa_switch(self):
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079
Patrick Williamsc0f7c042017-02-23 20:41:17 -060080 self.write_config("INHERIT_remove = \"report-error\"")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050081 if "packages-list" not in get_bb_var("ERROR_QA"):
Patrick Williamsc0f7c042017-02-23 20:41:17 -060082 self.append_config("ERROR_QA_append = \" packages-list\"")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050083
84 self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
Brad Bishop37a0e4d2017-12-04 01:01:44 -050085 self.add_command_to_tearDown('bitbake -c clean xcursor-transparent-theme')
86 res = bitbake("xcursor-transparent-theme -f -c package", ignore_status=True)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050087 self.delete_recipeinc('xcursor-transparent-theme')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050088 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("ERROR:"), msg=res.output)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050090 self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
91 self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
92 self.append_config('ERROR_QA_remove = "packages-list"')
93 self.append_config('WARN_QA_append = " packages-list"')
Brad Bishop37a0e4d2017-12-04 01:01:44 -050094 res = bitbake("xcursor-transparent-theme -f -c package")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050095 self.delete_recipeinc('xcursor-transparent-theme')
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050096 line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.")
97 self.assertTrue(line and line.startswith("WARNING:"), msg=res.output)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050098
99 @testcase(278)
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500100 def test_sanity_unsafe_script_references(self):
101 self.write_config('WARN_QA_append = " unsafe-references-in-scripts"')
102
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500103 self.add_command_to_tearDown('bitbake -c clean gzip')
104 res = bitbake("gzip -f -c package_qa")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500105 line = self.getline(res, "QA Issue: gzip")
106 self.assertFalse(line, "WARNING: QA Issue: gzip message is present in bitbake's output and shouldn't be: %s" % res.output)
107
108 self.append_config("""
109do_install_append_pn-gzip () {
110 echo "\n${bindir}/test" >> ${D}${bindir}/zcat
111}
112""")
Brad Bishop37a0e4d2017-12-04 01:01:44 -0500113 res = bitbake("gzip -f -c package_qa")
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500114 line = self.getline(res, "QA Issue: gzip")
115 self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: gzip message is not present in bitbake's output: %s" % res.output)
116
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500117 @testcase(1421)
118 def test_layer_without_git_dir(self):
119 """
120 Summary: Test that layer git revisions are displayed and do not fail without git repository
121 Expected: The build to be successful and without "fatal" errors
122 Product: oe-core
123 Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
124 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
125 """
126
127 dirpath = tempfile.mkdtemp()
128
129 dummy_layer_name = 'meta-dummy'
130 dummy_layer_path = os.path.join(dirpath, dummy_layer_name)
131 dummy_layer_conf_dir = os.path.join(dummy_layer_path, 'conf')
132 os.makedirs(dummy_layer_conf_dir)
133 dummy_layer_conf_path = os.path.join(dummy_layer_conf_dir, 'layer.conf')
134
135 dummy_layer_content = 'BBPATH .= ":${LAYERDIR}"\n' \
136 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' \
137 'BBFILE_COLLECTIONS += "%s"\n' \
138 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' \
139 'BBFILE_PRIORITY_%s = "6"\n' % (dummy_layer_name, dummy_layer_name, dummy_layer_name)
140
141 ftools.write_file(dummy_layer_conf_path, dummy_layer_content)
142
143 bblayers_conf = 'BBLAYERS += "%s"\n' % dummy_layer_path
144 self.write_bblayers_config(bblayers_conf)
145
146 test_recipe = 'ed'
147
148 ret = bitbake('-n %s' % test_recipe)
149
150 err = 'fatal: Not a git repository'
151
152 shutil.rmtree(dirpath)
153
154 self.assertNotIn(err, ret.output)
155
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500156
157class BuildhistoryTests(BuildhistoryBase):
158
159 @testcase(293)
160 def test_buildhistory_basic(self):
161 self.run_buildhistory_operation('xcursor-transparent-theme')
162 self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR')), "buildhistory dir was not created.")
163
164 @testcase(294)
165 def test_buildhistory_buildtime_pr_backwards(self):
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500166 target = 'xcursor-transparent-theme'
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500167 error = "ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1.* to .*-r0.*)" % target
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500168 self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True)
169 self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error)
170
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500171class ArchiverTest(oeSelfTest):
172 @testcase(926)
173 def test_arch_work_dir_and_export_source(self):
174 """
175 Test for archiving the work directory and exporting the source files.
176 """
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500177 self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500178 res = bitbake("xcursor-transparent-theme", ignore_status=True)
179 self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output)
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500180 deploy_dir_src = get_bb_var('DEPLOY_DIR_SRC')
181 pkgs_path = g.glob(str(deploy_dir_src) + "/allarch*/xcurs*")
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500182 src_file_glob = str(pkgs_path[0]) + "/xcursor*.src.rpm"
183 tar_file_glob = str(pkgs_path[0]) + "/xcursor*.tar.gz"
Brad Bishop6e60e8b2018-02-01 10:27:11 -0500184 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)