diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/buildoptions.py')
-rw-r--r-- | meta/lib/oeqa/selftest/buildoptions.py | 120 |
1 files changed, 120 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..a250cae0e1 --- /dev/null +++ b/meta/lib/oeqa/selftest/buildoptions.py | |||
@@ -0,0 +1,120 @@ | |||
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 | from oeqa.utils.decorators import testcase | ||
11 | |||
12 | class ImageOptionsTests(oeSelfTest): | ||
13 | |||
14 | @testcase(761) | ||
15 | def test_incremental_image_generation(self): | ||
16 | bitbake("-c cleanall core-image-minimal") | ||
17 | self.write_config('INC_RPM_IMAGE_GEN = "1"') | ||
18 | self.append_config('IMAGE_FEATURES += "ssh-server-openssh"') | ||
19 | bitbake("core-image-minimal") | ||
20 | res = runCmd("grep 'Installing openssh-sshd' %s" % (os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs")), ignore_status=True) | ||
21 | self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"') | ||
22 | self.assertEqual(0, res.status, msg="No match for openssh-sshd in log.do_rootfs") | ||
23 | bitbake("core-image-minimal") | ||
24 | res = runCmd("grep 'Removing openssh-sshd' %s" %(os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs")),ignore_status=True) | ||
25 | self.assertEqual(0, res.status, msg="openssh-sshd was not removed from image") | ||
26 | |||
27 | @testcase(925) | ||
28 | def test_rm_old_image(self): | ||
29 | bitbake("core-image-minimal") | ||
30 | deploydir = get_bb_var("DEPLOY_DIR_IMAGE", target="core-image-minimal") | ||
31 | imagename = get_bb_var("IMAGE_LINK_NAME", target="core-image-minimal") | ||
32 | deploydir_files = os.listdir(deploydir) | ||
33 | track_original_files = [] | ||
34 | for image_file in deploydir_files: | ||
35 | if imagename in image_file and os.path.islink(os.path.join(deploydir, image_file)): | ||
36 | track_original_files.append(os.path.realpath(os.path.join(deploydir, image_file))) | ||
37 | self.append_config("RM_OLD_IMAGE = \"1\"") | ||
38 | bitbake("-C rootfs core-image-minimal") | ||
39 | deploydir_files = os.listdir(deploydir) | ||
40 | remaining_not_expected = [path for path in track_original_files if os.path.basename(path) in deploydir_files] | ||
41 | self.assertFalse(remaining_not_expected, msg="\nThe following image files ware not removed: %s" % ', '.join(map(str, remaining_not_expected))) | ||
42 | |||
43 | @testcase(286) | ||
44 | def test_ccache_tool(self): | ||
45 | bitbake("ccache-native") | ||
46 | self.assertTrue(os.path.isfile(os.path.join(get_bb_var('STAGING_BINDIR_NATIVE', 'ccache-native'), "ccache"))) | ||
47 | self.write_config('INHERIT += "ccache"') | ||
48 | bitbake("m4 -c cleansstate") | ||
49 | bitbake("m4 -c compile") | ||
50 | res = runCmd("grep ccache %s" % (os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")), ignore_status=True) | ||
51 | self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile") | ||
52 | bitbake("ccache-native -ccleansstate") | ||
53 | |||
54 | |||
55 | class 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) | ||
62 | self.assertEqual(res.status, 1) | ||
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) | ||
66 | self.assertEqual(res.status, 1) | ||
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) | ||
70 | |||
71 | class SanityOptionsTest(oeSelfTest): | ||
72 | |||
73 | @testcase(927) | ||
74 | def test_options_warnqa_errorqa_switch(self): | ||
75 | bitbake("xcursor-transparent-theme -ccleansstate") | ||
76 | |||
77 | if "packages-list" not in get_bb_var("ERROR_QA"): | ||
78 | self.write_config("ERROR_QA_append = \" packages-list\"") | ||
79 | |||
80 | self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') | ||
81 | res = bitbake("xcursor-transparent-theme", ignore_status=True) | ||
82 | self.delete_recipeinc('xcursor-transparent-theme') | ||
83 | 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) | ||
84 | self.assertEqual(res.status, 1) | ||
85 | self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') | ||
86 | self.append_config('ERROR_QA_remove = "packages-list"') | ||
87 | self.append_config('WARN_QA_append = " packages-list"') | ||
88 | bitbake("xcursor-transparent-theme -ccleansstate") | ||
89 | res = bitbake("xcursor-transparent-theme") | ||
90 | self.delete_recipeinc('xcursor-transparent-theme') | ||
91 | 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) | ||
92 | |||
93 | @testcase(278) | ||
94 | def test_sanity_userspace_dependency(self): | ||
95 | self.append_config('WARN_QA_append = " unsafe-references-in-binaries unsafe-references-in-scripts"') | ||
96 | bitbake("-ccleansstate gzip nfs-utils") | ||
97 | res = bitbake("gzip nfs-utils") | ||
98 | self.assertTrue("WARNING: QA Issue: gzip" in res.output) | ||
99 | self.assertTrue("WARNING: QA Issue: nfs-utils" in res.output) | ||
100 | |||
101 | class BuildhistoryTests(BuildhistoryBase): | ||
102 | |||
103 | @testcase(293) | ||
104 | def test_buildhistory_basic(self): | ||
105 | self.run_buildhistory_operation('xcursor-transparent-theme') | ||
106 | self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR'))) | ||
107 | |||
108 | @testcase(294) | ||
109 | def test_buildhistory_buildtime_pr_backwards(self): | ||
110 | self.add_command_to_tearDown('cleanup-workdir') | ||
111 | target = 'xcursor-transparent-theme' | ||
112 | error = "ERROR: QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1 to .*-r0)" % target | ||
113 | self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) | ||
114 | self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) | ||
115 | |||
116 | |||
117 | |||
118 | |||
119 | |||
120 | |||