diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/buildoptions.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/buildoptions.py | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py new file mode 100644 index 0000000000..8ff40baddc --- /dev/null +++ b/meta/lib/oeqa/selftest/buildoptions.py | |||
| @@ -0,0 +1,113 @@ | |||
| 1 | import unittest | ||
| 2 | import os | ||
| 3 | import logging | ||
| 4 | import re | ||
| 5 | |||
| 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 | |||
| 11 | class ImageOptionsTests(oeSelfTest): | ||
| 12 | |||
| 13 | def test_incremental_image_generation(self): | ||
| 14 | bitbake("-c cleanall core-image-minimal") | ||
| 15 | self.write_config('INC_RPM_IMAGE_GEN = "1"') | ||
| 16 | self.append_config('IMAGE_FEATURES += "ssh-server-openssh"') | ||
| 17 | bitbake("core-image-minimal") | ||
| 18 | res = runCmd("grep 'Installing openssh-sshd' %s" % (os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs")), ignore_status=True) | ||
| 19 | self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"') | ||
| 20 | self.assertEqual(0, res.status, msg="No match for openssh-sshd in log.do_rootfs") | ||
| 21 | bitbake("core-image-minimal") | ||
| 22 | res = runCmd("grep 'Removing openssh-sshd' %s" %(os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs")),ignore_status=True) | ||
| 23 | self.assertEqual(0, res.status, msg="openssh-sshd was not removed from image") | ||
| 24 | |||
| 25 | def test_rm_old_image(self): | ||
| 26 | bitbake("core-image-minimal") | ||
| 27 | deploydir = get_bb_var("DEPLOY_DIR_IMAGE", target="core-image-minimal") | ||
| 28 | imagename = get_bb_var("IMAGE_LINK_NAME", target="core-image-minimal") | ||
| 29 | deploydir_files = os.listdir(deploydir) | ||
| 30 | track_original_files = [] | ||
| 31 | for image_file in deploydir_files: | ||
| 32 | if imagename in image_file and os.path.islink(os.path.join(deploydir, image_file)): | ||
| 33 | track_original_files.append(os.path.realpath(os.path.join(deploydir, image_file))) | ||
| 34 | self.append_config("RM_OLD_IMAGE = \"1\"") | ||
| 35 | bitbake("-C rootfs core-image-minimal") | ||
| 36 | deploydir_files = os.listdir(deploydir) | ||
| 37 | remaining_not_expected = [path for path in track_original_files if os.path.basename(path) in deploydir_files] | ||
| 38 | self.assertFalse(remaining_not_expected, msg="\nThe following image files ware not removed: %s" % ', '.join(map(str, remaining_not_expected))) | ||
| 39 | |||
| 40 | def test_ccache_tool(self): | ||
| 41 | bitbake("ccache-native") | ||
| 42 | self.assertTrue(os.path.isfile(os.path.join(get_bb_var('STAGING_BINDIR_NATIVE', 'ccache-native'), "ccache"))) | ||
| 43 | self.write_config('INHERIT += "ccache"') | ||
| 44 | bitbake("m4 -c cleansstate") | ||
| 45 | bitbake("m4 -c compile") | ||
| 46 | res = runCmd("grep ccache %s" % (os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")), ignore_status=True) | ||
| 47 | self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile") | ||
| 48 | bitbake("ccache-native -ccleansstate") | ||
| 49 | |||
| 50 | |||
| 51 | class DiskMonTest(oeSelfTest): | ||
| 52 | |||
| 53 | def test_stoptask_behavior(self): | ||
| 54 | result = runCmd("df -Pk %s" % os.getcwd()) | ||
| 55 | size = result.output.split("\n")[1].split()[3] | ||
| 56 | self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},%sK,4510K"' % size) | ||
| 57 | res = bitbake("m4", ignore_status = True) | ||
| 58 | self.assertTrue('ERROR: No new tasks can be executed since the disk space monitor action is "STOPTASKS"!' in res.output) | ||
| 59 | self.assertEqual(res.status, 1) | ||
| 60 | self.write_config('BB_DISKMON_DIRS = "ABORT,${TMPDIR},%sK,4510K"' % size) | ||
| 61 | res = bitbake("m4", ignore_status = True) | ||
| 62 | self.assertTrue('ERROR: Immediately abort since the disk space monitor action is "ABORT"!' in res.output) | ||
| 63 | self.assertEqual(res.status, 1) | ||
| 64 | self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},%sK,4510K"' % size) | ||
| 65 | res = bitbake("m4") | ||
| 66 | self.assertTrue('WARNING: The free space' in res.output) | ||
| 67 | |||
| 68 | class SanityOptionsTest(oeSelfTest): | ||
| 69 | |||
| 70 | def test_options_warnqa_errorqa_switch(self): | ||
| 71 | bitbake("xcursor-transparent-theme -ccleansstate") | ||
| 72 | |||
| 73 | if "packages-list" not in get_bb_var("ERROR_QA"): | ||
| 74 | self.write_config("ERROR_QA_append = \" packages-list\"") | ||
| 75 | |||
| 76 | self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') | ||
| 77 | res = bitbake("xcursor-transparent-theme", ignore_status=True) | ||
| 78 | self.delete_recipeinc('xcursor-transparent-theme') | ||
| 79 | self.assertTrue("ERROR: QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors." in res.output) | ||
| 80 | self.assertEqual(res.status, 1) | ||
| 81 | self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') | ||
| 82 | self.append_config('ERROR_QA_remove = "packages-list"') | ||
| 83 | self.append_config('WARN_QA_append = " packages-list"') | ||
| 84 | res = bitbake("xcursor-transparent-theme") | ||
| 85 | bitbake("xcursor-transparent-theme -ccleansstate") | ||
| 86 | self.delete_recipeinc('xcursor-transparent-theme') | ||
| 87 | self.assertTrue("WARNING: QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors." in res.output) | ||
| 88 | |||
| 89 | def test_sanity_userspace_dependency(self): | ||
| 90 | self.append_config('WARN_QA_append = " unsafe-references-in-binaries unsafe-references-in-scripts"') | ||
| 91 | bitbake("-ccleansstate gzip nfs-utils") | ||
| 92 | res = bitbake("gzip nfs-utils") | ||
| 93 | self.assertTrue("WARNING: QA Issue: gzip" in res.output) | ||
| 94 | self.assertTrue("WARNING: QA Issue: nfs-utils" in res.output) | ||
| 95 | |||
| 96 | class BuildhistoryTests(BuildhistoryBase): | ||
| 97 | |||
| 98 | def test_buildhistory_basic(self): | ||
| 99 | self.run_buildhistory_operation('xcursor-transparent-theme') | ||
| 100 | self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR'))) | ||
| 101 | |||
| 102 | def test_buildhistory_buildtime_pr_backwards(self): | ||
| 103 | self.add_command_to_tearDown('cleanup-workdir') | ||
| 104 | target = 'xcursor-transparent-theme' | ||
| 105 | error = "ERROR: QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1 to .*-r0)" % target | ||
| 106 | self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) | ||
| 107 | self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) | ||
| 108 | |||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | |||
| 113 | |||
