diff options
Diffstat (limited to 'meta/lib/oeqa/selftest/bbtests.py')
-rw-r--r-- | meta/lib/oeqa/selftest/bbtests.py | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py new file mode 100644 index 0000000000..68f97bd8e3 --- /dev/null +++ b/meta/lib/oeqa/selftest/bbtests.py | |||
@@ -0,0 +1,178 @@ | |||
1 | import unittest | ||
2 | import os | ||
3 | import logging | ||
4 | import re | ||
5 | import shutil | ||
6 | |||
7 | import oeqa.utils.ftools as ftools | ||
8 | from oeqa.selftest.base import oeSelfTest | ||
9 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var | ||
10 | from oeqa.utils.decorators import testcase | ||
11 | |||
12 | class BitbakeTests(oeSelfTest): | ||
13 | |||
14 | @testcase(789) | ||
15 | def test_run_bitbake_from_dir_1(self): | ||
16 | os.chdir(os.path.join(self.builddir, 'conf')) | ||
17 | bitbake('-e') | ||
18 | |||
19 | @testcase(790) | ||
20 | def test_run_bitbake_from_dir_2(self): | ||
21 | my_env = os.environ.copy() | ||
22 | my_env['BBPATH'] = my_env['BUILDDIR'] | ||
23 | os.chdir(os.path.dirname(os.environ['BUILDDIR'])) | ||
24 | bitbake('-e', env=my_env) | ||
25 | |||
26 | @testcase(806) | ||
27 | def test_event_handler(self): | ||
28 | self.write_config("INHERIT += \"test_events\"") | ||
29 | result = bitbake('m4-native') | ||
30 | find_build_started = re.search("NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Preparing runqueue", result.output) | ||
31 | find_build_completed = re.search("Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output) | ||
32 | self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output) | ||
33 | self.assertTrue(find_build_completed, msg = "Match failed in:\n%s" % result.output) | ||
34 | self.assertFalse('Test for bb.event.InvalidEvent' in result.output) | ||
35 | |||
36 | @testcase(103) | ||
37 | def test_local_sstate(self): | ||
38 | bitbake('m4-native -ccleansstate') | ||
39 | bitbake('m4-native') | ||
40 | bitbake('m4-native -cclean') | ||
41 | result = bitbake('m4-native') | ||
42 | find_setscene = re.search("m4-native.*do_.*_setscene", result.output) | ||
43 | self.assertTrue(find_setscene) | ||
44 | |||
45 | @testcase(105) | ||
46 | def test_bitbake_invalid_recipe(self): | ||
47 | result = bitbake('-b asdf', ignore_status=True) | ||
48 | self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output) | ||
49 | |||
50 | @testcase(107) | ||
51 | def test_bitbake_invalid_target(self): | ||
52 | result = bitbake('asdf', ignore_status=True) | ||
53 | self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output) | ||
54 | |||
55 | @testcase(106) | ||
56 | def test_warnings_errors(self): | ||
57 | result = bitbake('-b asdf', ignore_status=True) | ||
58 | find_warnings = re.search("Summary: There w.{2,3}? [1-9][0-9]* WARNING messages* shown", result.output) | ||
59 | find_errors = re.search("Summary: There w.{2,3}? [1-9][0-9]* ERROR messages* shown", result.output) | ||
60 | self.assertTrue(find_warnings, msg="Did not find the mumber of warnings at the end of the build:\n" + result.output) | ||
61 | self.assertTrue(find_errors, msg="Did not find the mumber of errors at the end of the build:\n" + result.output) | ||
62 | |||
63 | @testcase(108) | ||
64 | def test_invalid_patch(self): | ||
65 | self.write_recipeinc('man', 'SRC_URI += "file://man-1.5h1-make.patch"') | ||
66 | result = bitbake('man -c patch', ignore_status=True) | ||
67 | self.delete_recipeinc('man') | ||
68 | bitbake('-cclean man') | ||
69 | self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output) | ||
70 | |||
71 | @testcase(163) | ||
72 | def test_force_task(self): | ||
73 | bitbake('m4-native') | ||
74 | result = bitbake('-C compile m4-native') | ||
75 | look_for_tasks = ['do_compile', 'do_install', 'do_populate_sysroot'] | ||
76 | for task in look_for_tasks: | ||
77 | find_task = re.search("m4-native.*%s" % task, result.output) | ||
78 | self.assertTrue(find_task) | ||
79 | |||
80 | @testcase(167) | ||
81 | def test_bitbake_g(self): | ||
82 | result = bitbake('-g core-image-full-cmdline') | ||
83 | self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output) | ||
84 | self.assertTrue('openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist'))) | ||
85 | for f in ['pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot']: | ||
86 | os.remove(f) | ||
87 | |||
88 | @testcase(899) | ||
89 | def test_image_manifest(self): | ||
90 | bitbake('core-image-minimal') | ||
91 | deploydir = get_bb_var("DEPLOY_DIR_IMAGE", target="core-image-minimal") | ||
92 | imagename = get_bb_var("IMAGE_LINK_NAME", target="core-image-minimal") | ||
93 | manifest = os.path.join(deploydir, imagename + ".manifest") | ||
94 | self.assertTrue(os.path.islink(manifest), msg="No manifest file created for image") | ||
95 | |||
96 | @testcase(168) | ||
97 | def test_invalid_recipe_src_uri(self): | ||
98 | data = 'SRC_URI = "file://invalid"' | ||
99 | self.write_recipeinc('man', data) | ||
100 | bitbake('-ccleanall man') | ||
101 | result = bitbake('-c fetch man', ignore_status=True) | ||
102 | bitbake('-ccleanall man') | ||
103 | self.delete_recipeinc('man') | ||
104 | self.assertEqual(result.status, 1, msg='Command succeded when it should have failed') | ||
105 | self.assertTrue('Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were:' in result.output) | ||
106 | self.assertTrue('ERROR: Function failed: Fetcher failure for URL: \'file://invalid\'. Unable to fetch URL from any source.' in result.output) | ||
107 | |||
108 | @testcase(171) | ||
109 | def test_rename_downloaded_file(self): | ||
110 | data = 'SRC_URI_append = ";downloadfilename=test-aspell.tar.gz"' | ||
111 | self.write_recipeinc('aspell', data) | ||
112 | bitbake('-ccleanall aspell') | ||
113 | result = bitbake('-c fetch aspell', ignore_status=True) | ||
114 | self.delete_recipeinc('aspell') | ||
115 | self.assertEqual(result.status, 0) | ||
116 | self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz'))) | ||
117 | self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz.done'))) | ||
118 | bitbake('-ccleanall aspell') | ||
119 | |||
120 | @testcase(1028) | ||
121 | def test_environment(self): | ||
122 | self.append_config("TEST_ENV=\"localconf\"") | ||
123 | result = runCmd('bitbake -e | grep TEST_ENV=') | ||
124 | self.assertTrue('localconf' in result.output) | ||
125 | self.remove_config("TEST_ENV=\"localconf\"") | ||
126 | |||
127 | @testcase(1029) | ||
128 | def test_dry_run(self): | ||
129 | result = runCmd('bitbake -n m4-native') | ||
130 | self.assertEqual(0, result.status) | ||
131 | |||
132 | @testcase(1030) | ||
133 | def test_just_parse(self): | ||
134 | result = runCmd('bitbake -p') | ||
135 | self.assertEqual(0, result.status) | ||
136 | |||
137 | @testcase(1031) | ||
138 | def test_version(self): | ||
139 | result = runCmd('bitbake -s | grep wget') | ||
140 | find = re.search("wget *:([0-9a-zA-Z\.\-]+)", result.output) | ||
141 | self.assertTrue(find) | ||
142 | |||
143 | @testcase(1032) | ||
144 | def test_prefile(self): | ||
145 | preconf = os.path.join(self.builddir, 'conf/prefile.conf') | ||
146 | self.track_for_cleanup(preconf) | ||
147 | ftools.write_file(preconf ,"TEST_PREFILE=\"prefile\"") | ||
148 | result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=') | ||
149 | self.assertTrue('prefile' in result.output) | ||
150 | self.append_config("TEST_PREFILE=\"localconf\"") | ||
151 | result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=') | ||
152 | self.assertTrue('localconf' in result.output) | ||
153 | self.remove_config("TEST_PREFILE=\"localconf\"") | ||
154 | |||
155 | @testcase(1033) | ||
156 | def test_postfile(self): | ||
157 | postconf = os.path.join(self.builddir, 'conf/postfile.conf') | ||
158 | self.track_for_cleanup(postconf) | ||
159 | ftools.write_file(postconf , "TEST_POSTFILE=\"postfile\"") | ||
160 | self.append_config("TEST_POSTFILE=\"localconf\"") | ||
161 | result = runCmd('bitbake -R conf/postfile.conf -e | grep TEST_POSTFILE=') | ||
162 | self.assertTrue('postfile' in result.output) | ||
163 | self.remove_config("TEST_POSTFILE=\"localconf\"") | ||
164 | |||
165 | @testcase(1034) | ||
166 | def test_checkuri(self): | ||
167 | result = runCmd('bitbake -c checkuri m4') | ||
168 | self.assertEqual(0, result.status) | ||
169 | |||
170 | @testcase(1035) | ||
171 | def test_continue(self): | ||
172 | self.write_recipeinc('man',"\ndo_fail_task () {\nexit 1 \n}\n\naddtask do_fail_task before do_fetch\n" ) | ||
173 | runCmd('bitbake -c cleanall man xcursor-transparent-theme') | ||
174 | result = runCmd('bitbake man xcursor-transparent-theme -k', ignore_status=True) | ||
175 | errorpos = result.output.find('ERROR: Function failed: do_fail_task') | ||
176 | manver = re.search("NOTE: recipe xcursor-transparent-theme-(.*?): task do_unpack: Started", result.output) | ||
177 | continuepos = result.output.find('NOTE: recipe xcursor-transparent-theme-%s: task do_unpack: Started' % manver.group(1)) | ||
178 | self.assertLess(errorpos,continuepos) | ||