diff options
| author | Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com> | 2017-05-12 14:40:21 -0700 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-06 19:02:43 +0100 |
| commit | 157c3be2ca93f076033f725ec1ee912df91f7488 (patch) | |
| tree | 8ef896ff7adf78d63b34059cd5b017a4f0a3419a /meta/lib/oeqa/selftest/bbtests.py | |
| parent | 10c512b60d1167122b5fe778b93838dca3def717 (diff) | |
| download | poky-157c3be2ca93f076033f725ec1ee912df91f7488.tar.gz | |
oeqa/selftest/cases: Migrate test cases into the new oe-qa framework
New framework has different classes/decorators so adapt current test cases to
support these. Changes include changes on base classes and decorators.
Also include paths in selftest/__init__.py isn't needed because the
loader is the standard unittest one.
(From OE-Core rev: ddbbefdd124604d10bd47dd0266b55a764fcc0ab)
Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest/bbtests.py')
| -rw-r--r-- | meta/lib/oeqa/selftest/bbtests.py | 278 |
1 files changed, 0 insertions, 278 deletions
diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py deleted file mode 100644 index 46e09f509f..0000000000 --- a/meta/lib/oeqa/selftest/bbtests.py +++ /dev/null | |||
| @@ -1,278 +0,0 @@ | |||
| 1 | import os | ||
| 2 | import re | ||
| 3 | |||
| 4 | import oeqa.utils.ftools as ftools | ||
| 5 | from oeqa.selftest.base import oeSelfTest | ||
| 6 | from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars | ||
| 7 | from oeqa.utils.decorators import testcase | ||
| 8 | |||
| 9 | class BitbakeTests(oeSelfTest): | ||
| 10 | |||
| 11 | def getline(self, res, line): | ||
| 12 | for l in res.output.split('\n'): | ||
| 13 | if line in l: | ||
| 14 | return l | ||
| 15 | |||
| 16 | @testcase(789) | ||
| 17 | def test_run_bitbake_from_dir_1(self): | ||
| 18 | os.chdir(os.path.join(self.builddir, 'conf')) | ||
| 19 | self.assertEqual(bitbake('-e').status, 0, msg = "bitbake couldn't run from \"conf\" dir") | ||
| 20 | |||
| 21 | @testcase(790) | ||
| 22 | def test_run_bitbake_from_dir_2(self): | ||
| 23 | my_env = os.environ.copy() | ||
| 24 | my_env['BBPATH'] = my_env['BUILDDIR'] | ||
| 25 | os.chdir(os.path.dirname(os.environ['BUILDDIR'])) | ||
| 26 | self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from builddir") | ||
| 27 | |||
| 28 | @testcase(806) | ||
| 29 | def test_event_handler(self): | ||
| 30 | self.write_config("INHERIT += \"test_events\"") | ||
| 31 | result = bitbake('m4-native') | ||
| 32 | find_build_started = re.search("NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Executing RunQueue Tasks", result.output) | ||
| 33 | find_build_completed = re.search("Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output) | ||
| 34 | self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output) | ||
| 35 | self.assertTrue(find_build_completed, msg = "Match failed in:\n%s" % result.output) | ||
| 36 | self.assertFalse('Test for bb.event.InvalidEvent' in result.output, msg = "\"Test for bb.event.InvalidEvent\" message found during bitbake process. bitbake output: %s" % result.output) | ||
| 37 | |||
| 38 | @testcase(103) | ||
| 39 | def test_local_sstate(self): | ||
| 40 | bitbake('m4-native') | ||
| 41 | bitbake('m4-native -cclean') | ||
| 42 | result = bitbake('m4-native') | ||
| 43 | find_setscene = re.search("m4-native.*do_.*_setscene", result.output) | ||
| 44 | self.assertTrue(find_setscene, msg = "No \"m4-native.*do_.*_setscene\" message found during bitbake m4-native. bitbake output: %s" % result.output ) | ||
| 45 | |||
| 46 | @testcase(105) | ||
| 47 | def test_bitbake_invalid_recipe(self): | ||
| 48 | result = bitbake('-b asdf', ignore_status=True) | ||
| 49 | self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output, msg = "Though asdf recipe doesn't exist, bitbake didn't output any err. message. bitbake output: %s" % result.output) | ||
| 50 | |||
| 51 | @testcase(107) | ||
| 52 | def test_bitbake_invalid_target(self): | ||
| 53 | result = bitbake('asdf', ignore_status=True) | ||
| 54 | self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output, msg = "Though no 'asdf' target exists, bitbake didn't output any err. message. bitbake output: %s" % result.output) | ||
| 55 | |||
| 56 | @testcase(106) | ||
| 57 | def test_warnings_errors(self): | ||
| 58 | result = bitbake('-b asdf', ignore_status=True) | ||
| 59 | find_warnings = re.search("Summary: There w.{2,3}? [1-9][0-9]* WARNING messages* shown", result.output) | ||
| 60 | find_errors = re.search("Summary: There w.{2,3}? [1-9][0-9]* ERROR messages* shown", result.output) | ||
| 61 | self.assertTrue(find_warnings, msg="Did not find the mumber of warnings at the end of the build:\n" + result.output) | ||
| 62 | self.assertTrue(find_errors, msg="Did not find the mumber of errors at the end of the build:\n" + result.output) | ||
| 63 | |||
| 64 | @testcase(108) | ||
| 65 | def test_invalid_patch(self): | ||
| 66 | # This patch already exists in SRC_URI so adding it again will cause the | ||
| 67 | # patch to fail. | ||
| 68 | self.write_recipeinc('man', 'SRC_URI += "file://man-1.5h1-make.patch"') | ||
| 69 | self.write_config("INHERIT_remove = \"report-error\"") | ||
| 70 | result = bitbake('man -c patch', ignore_status=True) | ||
| 71 | self.delete_recipeinc('man') | ||
| 72 | bitbake('-cclean man') | ||
| 73 | line = self.getline(result, "Function failed: patch_do_patch") | ||
| 74 | self.assertTrue(line and line.startswith("ERROR:"), msg = "Repeated patch application didn't fail. bitbake output: %s" % result.output) | ||
| 75 | |||
| 76 | @testcase(1354) | ||
| 77 | def test_force_task_1(self): | ||
| 78 | # test 1 from bug 5875 | ||
| 79 | test_recipe = 'zlib' | ||
| 80 | test_data = "Microsoft Made No Profit From Anyone's Zunes Yo" | ||
| 81 | bb_vars = get_bb_vars(['D', 'PKGDEST', 'mandir'], test_recipe) | ||
| 82 | image_dir = bb_vars['D'] | ||
| 83 | pkgsplit_dir = bb_vars['PKGDEST'] | ||
| 84 | man_dir = bb_vars['mandir'] | ||
| 85 | |||
| 86 | bitbake('-c clean %s' % test_recipe) | ||
| 87 | bitbake('-c package -f %s' % test_recipe) | ||
| 88 | self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) | ||
| 89 | |||
| 90 | man_file = os.path.join(image_dir + man_dir, 'man3/zlib.3') | ||
| 91 | ftools.append_file(man_file, test_data) | ||
| 92 | bitbake('-c package -f %s' % test_recipe) | ||
| 93 | |||
| 94 | man_split_file = os.path.join(pkgsplit_dir, 'zlib-doc' + man_dir, 'man3/zlib.3') | ||
| 95 | man_split_content = ftools.read_file(man_split_file) | ||
| 96 | self.assertIn(test_data, man_split_content, 'The man file has not changed in packages-split.') | ||
| 97 | |||
| 98 | ret = bitbake(test_recipe) | ||
| 99 | self.assertIn('task do_package_write_rpm:', ret.output, 'Task do_package_write_rpm did not re-executed.') | ||
| 100 | |||
| 101 | @testcase(163) | ||
| 102 | def test_force_task_2(self): | ||
| 103 | # test 2 from bug 5875 | ||
| 104 | test_recipe = 'zlib' | ||
| 105 | |||
| 106 | bitbake(test_recipe) | ||
| 107 | self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) | ||
| 108 | |||
| 109 | result = bitbake('-C compile %s' % test_recipe) | ||
| 110 | look_for_tasks = ['do_compile:', 'do_install:', 'do_populate_sysroot:', 'do_package:'] | ||
| 111 | for task in look_for_tasks: | ||
| 112 | self.assertIn(task, result.output, msg="Couldn't find %s task.") | ||
| 113 | |||
| 114 | @testcase(167) | ||
| 115 | def test_bitbake_g(self): | ||
| 116 | result = bitbake('-g core-image-minimal') | ||
| 117 | for f in ['pn-buildlist', 'recipe-depends.dot', 'task-depends.dot']: | ||
| 118 | self.addCleanup(os.remove, f) | ||
| 119 | self.assertTrue('Task dependencies saved to \'task-depends.dot\'' in result.output, msg = "No task dependency \"task-depends.dot\" file was generated for the given task target. bitbake output: %s" % result.output) | ||
| 120 | self.assertTrue('busybox' in ftools.read_file(os.path.join(self.builddir, 'task-depends.dot')), msg = "No \"busybox\" dependency found in task-depends.dot file.") | ||
| 121 | |||
| 122 | @testcase(899) | ||
| 123 | def test_image_manifest(self): | ||
| 124 | bitbake('core-image-minimal') | ||
| 125 | bb_vars = get_bb_vars(["DEPLOY_DIR_IMAGE", "IMAGE_LINK_NAME"], "core-image-minimal") | ||
| 126 | deploydir = bb_vars["DEPLOY_DIR_IMAGE"] | ||
| 127 | imagename = bb_vars["IMAGE_LINK_NAME"] | ||
| 128 | manifest = os.path.join(deploydir, imagename + ".manifest") | ||
| 129 | self.assertTrue(os.path.islink(manifest), msg="No manifest file created for image. It should have been created in %s" % manifest) | ||
| 130 | |||
| 131 | @testcase(168) | ||
| 132 | def test_invalid_recipe_src_uri(self): | ||
| 133 | data = 'SRC_URI = "file://invalid"' | ||
| 134 | self.write_recipeinc('man', data) | ||
| 135 | self.write_config("""DL_DIR = \"${TOPDIR}/download-selftest\" | ||
| 136 | SSTATE_DIR = \"${TOPDIR}/download-selftest\" | ||
| 137 | INHERIT_remove = \"report-error\" | ||
| 138 | """) | ||
| 139 | self.track_for_cleanup(os.path.join(self.builddir, "download-selftest")) | ||
| 140 | |||
| 141 | bitbake('-ccleanall man') | ||
| 142 | result = bitbake('-c fetch man', ignore_status=True) | ||
| 143 | bitbake('-ccleanall man') | ||
| 144 | self.delete_recipeinc('man') | ||
| 145 | self.assertEqual(result.status, 1, msg="Command succeded when it should have failed. bitbake output: %s" % result.output) | ||
| 146 | self.assertTrue('Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were:' in result.output, msg = "\"invalid\" file \ | ||
| 147 | doesn't exist, yet no error message encountered. bitbake output: %s" % result.output) | ||
| 148 | line = self.getline(result, 'Fetcher failure for URL: \'file://invalid\'. Unable to fetch URL from any source.') | ||
| 149 | self.assertTrue(line and line.startswith("ERROR:"), msg = "\"invalid\" file \ | ||
| 150 | doesn't exist, yet fetcher didn't report any error. bitbake output: %s" % result.output) | ||
| 151 | |||
| 152 | @testcase(171) | ||
| 153 | def test_rename_downloaded_file(self): | ||
| 154 | # TODO unique dldir instead of using cleanall | ||
| 155 | # TODO: need to set sstatedir? | ||
| 156 | self.write_config("""DL_DIR = \"${TOPDIR}/download-selftest\" | ||
| 157 | SSTATE_DIR = \"${TOPDIR}/download-selftest\" | ||
| 158 | """) | ||
| 159 | self.track_for_cleanup(os.path.join(self.builddir, "download-selftest")) | ||
| 160 | |||
| 161 | data = 'SRC_URI = "${GNU_MIRROR}/aspell/aspell-${PV}.tar.gz;downloadfilename=test-aspell.tar.gz"' | ||
| 162 | self.write_recipeinc('aspell', data) | ||
| 163 | result = bitbake('-f -c fetch aspell', ignore_status=True) | ||
| 164 | self.delete_recipeinc('aspell') | ||
| 165 | self.assertEqual(result.status, 0, msg = "Couldn't fetch aspell. %s" % result.output) | ||
| 166 | dl_dir = get_bb_var("DL_DIR") | ||
| 167 | self.assertTrue(os.path.isfile(os.path.join(dl_dir, 'test-aspell.tar.gz')), msg = "File rename failed. No corresponding test-aspell.tar.gz file found under %s" % dl_dir) | ||
| 168 | self.assertTrue(os.path.isfile(os.path.join(dl_dir, 'test-aspell.tar.gz.done')), "File rename failed. No corresponding test-aspell.tar.gz.done file found under %s" % dl_dir) | ||
| 169 | |||
| 170 | @testcase(1028) | ||
| 171 | def test_environment(self): | ||
| 172 | self.write_config("TEST_ENV=\"localconf\"") | ||
| 173 | result = runCmd('bitbake -e | grep TEST_ENV=') | ||
| 174 | self.assertTrue('localconf' in result.output, msg = "bitbake didn't report any value for TEST_ENV variable. To test, run 'bitbake -e | grep TEST_ENV='") | ||
| 175 | |||
| 176 | @testcase(1029) | ||
| 177 | def test_dry_run(self): | ||
| 178 | result = runCmd('bitbake -n m4-native') | ||
| 179 | self.assertEqual(0, result.status, "bitbake dry run didn't run as expected. %s" % result.output) | ||
| 180 | |||
| 181 | @testcase(1030) | ||
| 182 | def test_just_parse(self): | ||
| 183 | result = runCmd('bitbake -p') | ||
| 184 | self.assertEqual(0, result.status, "errors encountered when parsing recipes. %s" % result.output) | ||
| 185 | |||
| 186 | @testcase(1031) | ||
| 187 | def test_version(self): | ||
| 188 | result = runCmd('bitbake -s | grep wget') | ||
| 189 | find = re.search("wget *:([0-9a-zA-Z\.\-]+)", result.output) | ||
| 190 | self.assertTrue(find, "No version returned for searched recipe. bitbake output: %s" % result.output) | ||
| 191 | |||
| 192 | @testcase(1032) | ||
| 193 | def test_prefile(self): | ||
| 194 | preconf = os.path.join(self.builddir, 'conf/prefile.conf') | ||
| 195 | self.track_for_cleanup(preconf) | ||
| 196 | ftools.write_file(preconf ,"TEST_PREFILE=\"prefile\"") | ||
| 197 | result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=') | ||
| 198 | self.assertTrue('prefile' in result.output, "Preconfigure file \"prefile.conf\"was not taken into consideration. ") | ||
| 199 | self.write_config("TEST_PREFILE=\"localconf\"") | ||
| 200 | result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=') | ||
| 201 | self.assertTrue('localconf' in result.output, "Preconfigure file \"prefile.conf\"was not taken into consideration.") | ||
| 202 | |||
| 203 | @testcase(1033) | ||
| 204 | def test_postfile(self): | ||
| 205 | postconf = os.path.join(self.builddir, 'conf/postfile.conf') | ||
| 206 | self.track_for_cleanup(postconf) | ||
| 207 | ftools.write_file(postconf , "TEST_POSTFILE=\"postfile\"") | ||
| 208 | self.write_config("TEST_POSTFILE=\"localconf\"") | ||
| 209 | result = runCmd('bitbake -R conf/postfile.conf -e | grep TEST_POSTFILE=') | ||
| 210 | self.assertTrue('postfile' in result.output, "Postconfigure file \"postfile.conf\"was not taken into consideration.") | ||
| 211 | |||
| 212 | @testcase(1034) | ||
| 213 | def test_checkuri(self): | ||
| 214 | result = runCmd('bitbake -c checkuri m4') | ||
| 215 | self.assertEqual(0, result.status, msg = "\"checkuri\" task was not executed. bitbake output: %s" % result.output) | ||
| 216 | |||
| 217 | @testcase(1035) | ||
| 218 | def test_continue(self): | ||
| 219 | self.write_config("""DL_DIR = \"${TOPDIR}/download-selftest\" | ||
| 220 | SSTATE_DIR = \"${TOPDIR}/download-selftest\" | ||
| 221 | INHERIT_remove = \"report-error\" | ||
| 222 | """) | ||
| 223 | self.track_for_cleanup(os.path.join(self.builddir, "download-selftest")) | ||
| 224 | self.write_recipeinc('man',"\ndo_fail_task () {\nexit 1 \n}\n\naddtask do_fail_task before do_fetch\n" ) | ||
| 225 | runCmd('bitbake -c cleanall man xcursor-transparent-theme') | ||
| 226 | result = runCmd('bitbake -c unpack -k man xcursor-transparent-theme', ignore_status=True) | ||
| 227 | errorpos = result.output.find('ERROR: Function failed: do_fail_task') | ||
| 228 | manver = re.search("NOTE: recipe xcursor-transparent-theme-(.*?): task do_unpack: Started", result.output) | ||
| 229 | continuepos = result.output.find('NOTE: recipe xcursor-transparent-theme-%s: task do_unpack: Started' % manver.group(1)) | ||
| 230 | self.assertLess(errorpos,continuepos, msg = "bitbake didn't pass do_fail_task. bitbake output: %s" % result.output) | ||
| 231 | |||
| 232 | @testcase(1119) | ||
| 233 | def test_non_gplv3(self): | ||
| 234 | self.write_config('INCOMPATIBLE_LICENSE = "GPLv3"') | ||
| 235 | result = bitbake('selftest-ed', ignore_status=True) | ||
| 236 | self.assertEqual(result.status, 0, "Bitbake failed, exit code %s, output %s" % (result.status, result.output)) | ||
| 237 | lic_dir = get_bb_var('LICENSE_DIRECTORY') | ||
| 238 | self.assertFalse(os.path.isfile(os.path.join(lic_dir, 'selftest-ed/generic_GPLv3'))) | ||
| 239 | self.assertTrue(os.path.isfile(os.path.join(lic_dir, 'selftest-ed/generic_GPLv2'))) | ||
| 240 | |||
| 241 | @testcase(1422) | ||
| 242 | def test_setscene_only(self): | ||
| 243 | """ Bitbake option to restore from sstate only within a build (i.e. execute no real tasks, only setscene)""" | ||
| 244 | test_recipe = 'ed' | ||
| 245 | |||
| 246 | bitbake(test_recipe) | ||
| 247 | bitbake('-c clean %s' % test_recipe) | ||
| 248 | ret = bitbake('--setscene-only %s' % test_recipe) | ||
| 249 | |||
| 250 | tasks = re.findall(r'task\s+(do_\S+):', ret.output) | ||
| 251 | |||
| 252 | for task in tasks: | ||
| 253 | self.assertIn('_setscene', task, 'A task different from _setscene ran: %s.\n' | ||
| 254 | 'Executed tasks were: %s' % (task, str(tasks))) | ||
| 255 | |||
| 256 | @testcase(1425) | ||
| 257 | def test_bbappend_order(self): | ||
| 258 | """ Bitbake should bbappend to recipe in a predictable order """ | ||
| 259 | test_recipe = 'ed' | ||
| 260 | bb_vars = get_bb_vars(['SUMMARY', 'PV'], test_recipe) | ||
| 261 | test_recipe_summary_before = bb_vars['SUMMARY'] | ||
| 262 | test_recipe_pv = bb_vars['PV'] | ||
| 263 | recipe_append_file = test_recipe + '_' + test_recipe_pv + '.bbappend' | ||
| 264 | expected_recipe_summary = test_recipe_summary_before | ||
| 265 | |||
| 266 | for i in range(5): | ||
| 267 | recipe_append_dir = test_recipe + '_test_' + str(i) | ||
| 268 | recipe_append_path = os.path.join(self.testlayer_path, 'recipes-test', recipe_append_dir, recipe_append_file) | ||
| 269 | os.mkdir(os.path.join(self.testlayer_path, 'recipes-test', recipe_append_dir)) | ||
| 270 | feature = 'SUMMARY += "%s"\n' % i | ||
| 271 | ftools.write_file(recipe_append_path, feature) | ||
| 272 | expected_recipe_summary += ' %s' % i | ||
| 273 | |||
| 274 | self.add_command_to_tearDown('rm -rf %s' % os.path.join(self.testlayer_path, 'recipes-test', | ||
| 275 | test_recipe + '_test_*')) | ||
| 276 | |||
| 277 | test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) | ||
| 278 | self.assertEqual(expected_recipe_summary, test_recipe_summary_after) | ||
