blob: 24597ac1925b681c2a3e600f93fd04062a24fcbd [file] [log] [blame]
Brad Bishopd7bf8c12018-02-25 22:55:05 -05001import os
2import re
3import glob as g
4import shutil
5import tempfile
6from oeqa.selftest.case import OESelftestTestCase
7from oeqa.selftest.cases.buildhistory import BuildhistoryBase
8from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars
9import oeqa.utils.ftools as ftools
10from oeqa.core.decorator.oeid import OETestID
11
12class ImageOptionsTests(OESelftestTestCase):
13
14 @OETestID(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')
19 bitbake("-c clean core-image-minimal")
20 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)
25 incremental_created = re.search(r"Installing\s*:\s*packagegroup-core-ssh-openssh", log_data_created)
26 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)
30 incremental_removed = re.search(r"Erasing\s*:\s*packagegroup-core-ssh-openssh", log_data_removed)
31 self.assertTrue(incremental_removed, msg = "Match failed in:\n%s" % log_data_removed)
32
33 @OETestID(286)
34 def test_ccache_tool(self):
35 bitbake("ccache-native")
36 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)
39 self.write_config('INHERIT += "ccache"')
40 self.add_command_to_tearDown('bitbake -c clean m4')
Brad Bishopf86d0552018-12-04 14:18:15 -080041 bitbake("m4 -c clean")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050042 bitbake("m4 -f -c compile")
43 log_compile = os.path.join(get_bb_var("WORKDIR","m4"), "temp/log.do_compile")
Brad Bishopf86d0552018-12-04 14:18:15 -080044 with open(log_compile, "r") as f:
45 loglines = "".join(f.readlines())
46 self.assertIn("ccache", loglines, msg="No match for ccache in m4 log.do_compile. For further details: %s" % log_compile)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050047
48 @OETestID(1435)
49 def test_read_only_image(self):
50 distro_features = get_bb_var('DISTRO_FEATURES')
51 if not ('x11' in distro_features and 'opengl' in distro_features):
52 self.skipTest('core-image-sato requires x11 and opengl in distro features')
53 self.write_config('IMAGE_FEATURES += "read-only-rootfs"')
54 bitbake("core-image-sato")
55 # do_image will fail if there are any pending postinsts
56
57class DiskMonTest(OESelftestTestCase):
58
59 @OETestID(277)
60 def test_stoptask_behavior(self):
61 self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},100000G,100K"')
Brad Bishopf86d0552018-12-04 14:18:15 -080062 res = bitbake("delay -c delay", ignore_status = True)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050063 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)
64 self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
65 self.write_config('BB_DISKMON_DIRS = "ABORT,${TMPDIR},100000G,100K"')
Brad Bishopf86d0552018-12-04 14:18:15 -080066 res = bitbake("delay -c delay", ignore_status = True)
Brad Bishopd7bf8c12018-02-25 22:55:05 -050067 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)
68 self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
69 self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},100000G,100K"')
Brad Bishopf86d0552018-12-04 14:18:15 -080070 res = bitbake("delay -c delay")
Brad Bishopd7bf8c12018-02-25 22:55:05 -050071 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)
72
73class SanityOptionsTest(OESelftestTestCase):
74 def getline(self, res, line):
75 for l in res.output.split('\n'):
76 if line in l:
77 return l
78
79 @OETestID(927)
80 def test_options_warnqa_errorqa_switch(self):
81
82 self.write_config("INHERIT_remove = \"report-error\"")
83 if "packages-list" not in get_bb_var("ERROR_QA"):
84 self.append_config("ERROR_QA_append = \" packages-list\"")
85
86 self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
87 self.add_command_to_tearDown('bitbake -c clean xcursor-transparent-theme')
88 res = bitbake("xcursor-transparent-theme -f -c package", ignore_status=True)
89 self.delete_recipeinc('xcursor-transparent-theme')
90 line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.")
91 self.assertTrue(line and line.startswith("ERROR:"), msg=res.output)
92 self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output))
93 self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"')
94 self.append_config('ERROR_QA_remove = "packages-list"')
95 self.append_config('WARN_QA_append = " packages-list"')
96 res = bitbake("xcursor-transparent-theme -f -c package")
97 self.delete_recipeinc('xcursor-transparent-theme')
98 line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.")
99 self.assertTrue(line and line.startswith("WARNING:"), msg=res.output)
100
101 @OETestID(1421)
102 def test_layer_without_git_dir(self):
103 """
104 Summary: Test that layer git revisions are displayed and do not fail without git repository
105 Expected: The build to be successful and without "fatal" errors
106 Product: oe-core
107 Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
108 AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com>
109 """
110
111 dirpath = tempfile.mkdtemp()
112
113 dummy_layer_name = 'meta-dummy'
114 dummy_layer_path = os.path.join(dirpath, dummy_layer_name)
115 dummy_layer_conf_dir = os.path.join(dummy_layer_path, 'conf')
116 os.makedirs(dummy_layer_conf_dir)
117 dummy_layer_conf_path = os.path.join(dummy_layer_conf_dir, 'layer.conf')
118
119 dummy_layer_content = 'BBPATH .= ":${LAYERDIR}"\n' \
120 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' \
121 'BBFILE_COLLECTIONS += "%s"\n' \
122 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' \
123 'BBFILE_PRIORITY_%s = "6"\n' % (dummy_layer_name, dummy_layer_name, dummy_layer_name)
124
125 ftools.write_file(dummy_layer_conf_path, dummy_layer_content)
126
127 bblayers_conf = 'BBLAYERS += "%s"\n' % dummy_layer_path
128 self.write_bblayers_config(bblayers_conf)
129
130 test_recipe = 'ed'
131
132 ret = bitbake('-n %s' % test_recipe)
133
134 err = 'fatal: Not a git repository'
135
136 shutil.rmtree(dirpath)
137
138 self.assertNotIn(err, ret.output)
139
140
141class BuildhistoryTests(BuildhistoryBase):
142
143 @OETestID(293)
144 def test_buildhistory_basic(self):
145 self.run_buildhistory_operation('xcursor-transparent-theme')
146 self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR')), "buildhistory dir was not created.")
147
148 @OETestID(294)
149 def test_buildhistory_buildtime_pr_backwards(self):
150 target = 'xcursor-transparent-theme'
151 error = "ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1.* to .*-r0.*)" % target
152 self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True)
153 self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error)
154
155class ArchiverTest(OESelftestTestCase):
156 @OETestID(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.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"")
162 res = bitbake("xcursor-transparent-theme", ignore_status=True)
163 self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output)
164 deploy_dir_src = get_bb_var('DEPLOY_DIR_SRC')
165 pkgs_path = g.glob(str(deploy_dir_src) + "/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 %s/allarch*/xcursor*" % deploy_dir_src)
Brad Bishop316dfdd2018-06-25 12:45:53 -0400169
170class ToolchainOptions(OESelftestTestCase):
171
172 def test_toolchain_fortran(self):
173 """
174 Test whether we can enable and build fortran and its supporting libraries
175 """
176
177 features = 'FORTRAN_forcevariable = ",fortran"\n'
178 features += 'RUNTIMETARGET_append_pn-gcc-runtime = " libquadmath"\n'
179 self.write_config(features)
180
181 bitbake('gcc-runtime libgfortran')
182