diff options
Diffstat (limited to 'yocto-poky/meta/lib/oeqa/selftest/buildoptions.py')
-rw-r--r-- | yocto-poky/meta/lib/oeqa/selftest/buildoptions.py | 163 |
1 files changed, 152 insertions, 11 deletions
diff --git a/yocto-poky/meta/lib/oeqa/selftest/buildoptions.py b/yocto-poky/meta/lib/oeqa/selftest/buildoptions.py index acf481f7b..35d5dfd29 100644 --- a/yocto-poky/meta/lib/oeqa/selftest/buildoptions.py +++ b/yocto-poky/meta/lib/oeqa/selftest/buildoptions.py @@ -1,7 +1,8 @@ import os import re import glob as g - +import shutil +import tempfile from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase from oeqa.utils.commands import runCmd, bitbake, get_bb_var @@ -56,6 +57,11 @@ class ImageOptionsTests(oeSelfTest): res = runCmd("grep ccache %s" % (os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")), ignore_status=True) 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")) + @testcase(1435) + def test_read_only_image(self): + self.write_config('IMAGE_FEATURES += "read-only-rootfs"') + bitbake("core-image-sato") + # do_image will fail if there are any pending postinsts class DiskMonTest(oeSelfTest): @@ -74,6 +80,10 @@ class DiskMonTest(oeSelfTest): 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) class SanityOptionsTest(oeSelfTest): + def getline(self, res, line): + for l in res.output.split('\n'): + if line in l: + return l @testcase(927) def test_options_warnqa_errorqa_switch(self): @@ -85,7 +95,8 @@ class SanityOptionsTest(oeSelfTest): self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') res = bitbake("xcursor-transparent-theme", ignore_status=True) self.delete_recipeinc('xcursor-transparent-theme') - self.assertTrue("ERROR: QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors." in res.output, msg=res.output) + line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.") + self.assertTrue(line and line.startswith("ERROR:"), msg=res.output) self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output)) self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') self.append_config('ERROR_QA_remove = "packages-list"') @@ -93,15 +104,85 @@ class SanityOptionsTest(oeSelfTest): bitbake("xcursor-transparent-theme -ccleansstate") res = bitbake("xcursor-transparent-theme") self.delete_recipeinc('xcursor-transparent-theme') - self.assertTrue("WARNING: QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors." in res.output, msg=res.output) + line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.") + self.assertTrue(line and line.startswith("WARNING:"), msg=res.output) @testcase(278) - def test_sanity_userspace_dependency(self): - self.write_config('WARN_QA_append = " unsafe-references-in-binaries unsafe-references-in-scripts"') - bitbake("-ccleansstate gzip nfs-utils") - res = bitbake("gzip nfs-utils") - self.assertTrue("WARNING: QA Issue: gzip" in res.output, "WARNING: QA Issue: gzip message is not present in bitbake's output: %s" % res.output) - self.assertTrue("WARNING: QA Issue: nfs-utils" in res.output, "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output) + def test_sanity_unsafe_script_references(self): + self.write_config('WARN_QA_append = " unsafe-references-in-scripts"') + + bitbake("-ccleansstate gzip") + res = bitbake("gzip") + line = self.getline(res, "QA Issue: gzip") + self.assertFalse(line, "WARNING: QA Issue: gzip message is present in bitbake's output and shouldn't be: %s" % res.output) + + self.append_config(""" +do_install_append_pn-gzip () { + echo "\n${bindir}/test" >> ${D}${bindir}/zcat +} +""") + res = bitbake("gzip") + line = self.getline(res, "QA Issue: gzip") + self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: gzip message is not present in bitbake's output: %s" % res.output) + + @testcase(1434) + def test_sanity_unsafe_binary_references(self): + self.write_config('WARN_QA_append = " unsafe-references-in-binaries"') + + bitbake("-ccleansstate nfs-utils") + #res = bitbake("nfs-utils") + # FIXME when nfs-utils passes this test + #line = self.getline(res, "QA Issue: nfs-utils") + #self.assertFalse(line, "WARNING: QA Issue: nfs-utils message is present in bitbake's output and shouldn't be: %s" % res.output) + +# self.append_config(""" +#do_install_append_pn-nfs-utils () { +# echo "\n${bindir}/test" >> ${D}${base_sbindir}/osd_login +#} +#""") + res = bitbake("nfs-utils") + line = self.getline(res, "QA Issue: nfs-utils") + self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output) + + @testcase(1421) + def test_layer_without_git_dir(self): + """ + Summary: Test that layer git revisions are displayed and do not fail without git repository + Expected: The build to be successful and without "fatal" errors + Product: oe-core + Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com> + AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> + """ + + dirpath = tempfile.mkdtemp() + + dummy_layer_name = 'meta-dummy' + dummy_layer_path = os.path.join(dirpath, dummy_layer_name) + dummy_layer_conf_dir = os.path.join(dummy_layer_path, 'conf') + os.makedirs(dummy_layer_conf_dir) + dummy_layer_conf_path = os.path.join(dummy_layer_conf_dir, 'layer.conf') + + dummy_layer_content = 'BBPATH .= ":${LAYERDIR}"\n' \ + 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' \ + 'BBFILE_COLLECTIONS += "%s"\n' \ + 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' \ + 'BBFILE_PRIORITY_%s = "6"\n' % (dummy_layer_name, dummy_layer_name, dummy_layer_name) + + ftools.write_file(dummy_layer_conf_path, dummy_layer_content) + + bblayers_conf = 'BBLAYERS += "%s"\n' % dummy_layer_path + self.write_bblayers_config(bblayers_conf) + + test_recipe = 'ed' + + ret = bitbake('-n %s' % test_recipe) + + err = 'fatal: Not a git repository' + + shutil.rmtree(dirpath) + + self.assertNotIn(err, ret.output) + class BuildhistoryTests(BuildhistoryBase): @@ -114,10 +195,70 @@ class BuildhistoryTests(BuildhistoryBase): def test_buildhistory_buildtime_pr_backwards(self): self.add_command_to_tearDown('cleanup-workdir') target = 'xcursor-transparent-theme' - error = "ERROR: QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1 to .*-r0)" % target + error = "ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1.* to .*-r0.*)" % target self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) + @testcase(1386) + def test_buildhistory_does_not_change_signatures(self): + """ + Summary: Ensure that buildhistory does not change signatures + Expected: Only 'do_rootfs' task should be rerun + Product: oe-core + Author: Daniel Istrate <daniel.alexandrux.istrate@intel.com> + AutomatedBy: Daniel Istrate <daniel.alexandrux.istrate@intel.com> + """ + + tmpdir1_name = 'tmpsig1' + tmpdir2_name = 'tmpsig2' + builddir = os.environ.get('BUILDDIR') + tmpdir1 = os.path.join(builddir, tmpdir1_name) + tmpdir2 = os.path.join(builddir, tmpdir2_name) + + self.track_for_cleanup(tmpdir1) + self.track_for_cleanup(tmpdir2) + + features = 'TMPDIR = "%s"\n' % tmpdir1 + self.write_config(features) + bitbake('core-image-minimal -S none -c rootfs') + + features = 'TMPDIR = "%s"\n' % tmpdir2 + features += 'INHERIT += "buildhistory"\n' + self.write_config(features) + bitbake('core-image-minimal -S none -c rootfs') + + def get_files(d): + f = [] + for root, dirs, files in os.walk(d): + for name in files: + f.append(os.path.join(root, name)) + return f + + files1 = get_files(tmpdir1 + '/stamps') + files2 = get_files(tmpdir2 + '/stamps') + files2 = [x.replace(tmpdir2_name, tmpdir1_name) for x in files2] + + f1 = set(files1) + f2 = set(files2) + sigdiff = f1 - f2 + + self.assertEqual(len(sigdiff), 1, 'Expected 1 signature differences. Out: %s' % list(sigdiff)) + + unexpected_diff = [] + + # No new signatures should appear apart from do_rootfs + found_do_rootfs_flag = False + + for sig in sigdiff: + if 'do_rootfs' in sig: + found_do_rootfs_flag = True + else: + unexpected_diff.append(sig) + + self.assertTrue(found_do_rootfs_flag, 'Task do_rootfs did not rerun.') + self.assertFalse(unexpected_diff, 'Found unexpected signature differences. Out: %s' % unexpected_diff) + + class BuildImagesTest(oeSelfTest): @testcase(563) def test_directfb(self): @@ -137,7 +278,7 @@ class ArchiverTest(oeSelfTest): Test for archiving the work directory and exporting the source files. """ self.add_command_to_tearDown('cleanup-workdir') - self.write_config("INHERIT = \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") + self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") res = bitbake("xcursor-transparent-theme", ignore_status=True) self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output) pkgs_path = g.glob(str(self.builddir) + "/tmp/deploy/sources/allarch*/xcurs*") |