summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest/bbtests.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oeqa/selftest/bbtests.py')
-rw-r--r--meta/lib/oeqa/selftest/bbtests.py104
1 files changed, 104 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..6815ecfe0b
--- /dev/null
+++ b/meta/lib/oeqa/selftest/bbtests.py
@@ -0,0 +1,104 @@
1import unittest
2import os
3import logging
4import re
5import shutil
6
7import oeqa.utils.ftools as ftools
8from oeqa.selftest.base import oeSelfTest
9from oeqa.utils.commands import runCmd, bitbake, get_bb_var
10
11class BitbakeTests(oeSelfTest):
12
13 def test_run_bitbake_from_dir_1(self):
14 os.chdir(os.path.join(self.builddir, 'conf'))
15 bitbake('-e')
16
17 def test_run_bitbake_from_dir_2(self):
18 my_env = os.environ.copy()
19 my_env['BBPATH'] = my_env['BUILDDIR']
20 os.chdir(os.path.dirname(os.environ['BUILDDIR']))
21 bitbake('-e', env=my_env)
22
23 def test_event_handler(self):
24 self.write_config("INHERIT += \"test_events\"")
25 result = bitbake('m4-native')
26 find_build_started = re.search("NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Preparing runqueue", result.output)
27 find_build_completed = re.search("Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output)
28 self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output)
29 self.assertTrue(find_build_completed, msg = "Match failed in:\n%s" % result.output)
30 self.assertFalse('Test for bb.event.InvalidEvent' in result.output)
31
32 def test_local_sstate(self):
33 bitbake('m4-native -ccleansstate')
34 bitbake('m4-native')
35 bitbake('m4-native -cclean')
36 result = bitbake('m4-native')
37 find_setscene = re.search("m4-native.*do_.*_setscene", result.output)
38 self.assertTrue(find_setscene)
39
40 def test_bitbake_invalid_recipe(self):
41 result = bitbake('-b asdf', ignore_status=True)
42 self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output)
43
44 def test_bitbake_invalid_target(self):
45 result = bitbake('asdf', ignore_status=True)
46 self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output)
47
48 def test_warnings_errors(self):
49 result = bitbake('-b asdf', ignore_status=True)
50 find_warnings = re.search("Summary: There w.{2,3}? [1-9][0-9]* WARNING messages* shown", result.output)
51 find_errors = re.search("Summary: There w.{2,3}? [1-9][0-9]* ERROR messages* shown", result.output)
52 self.assertTrue(find_warnings, msg="Did not find the mumber of warnings at the end of the build:\n" + result.output)
53 self.assertTrue(find_errors, msg="Did not find the mumber of errors at the end of the build:\n" + result.output)
54
55 def test_invalid_patch(self):
56 self.write_recipeinc('man', 'SRC_URI += "file://man-1.5h1-make.patch"')
57 result = bitbake('man -c patch', ignore_status=True)
58 self.delete_recipeinc('man')
59 bitbake('-cclean man')
60 self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output)
61
62 def test_force_task(self):
63 bitbake('m4-native')
64 result = bitbake('-C compile m4-native')
65 look_for_tasks = ['do_compile', 'do_install', 'do_populate_sysroot']
66 for task in look_for_tasks:
67 find_task = re.search("m4-native.*%s" % task, result.output)
68 self.assertTrue(find_task)
69
70 def test_bitbake_g(self):
71 result = bitbake('-g core-image-full-cmdline')
72 self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output)
73 self.assertTrue('openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist')))
74 for f in ['pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot']:
75 os.remove(f)
76
77 def test_image_manifest(self):
78 bitbake('core-image-minimal')
79 deploydir = get_bb_var("DEPLOY_DIR_IMAGE", target="core-image-minimal")
80 imagename = get_bb_var("IMAGE_LINK_NAME", target="core-image-minimal")
81 manifest = os.path.join(deploydir, imagename + ".manifest")
82 self.assertTrue(os.path.islink(manifest), msg="No manifest file created for image")
83
84 def test_invalid_recipe_src_uri(self):
85 data = 'SRC_URI = "file://invalid"'
86 self.write_recipeinc('man', data)
87 bitbake('-ccleanall man')
88 result = bitbake('-c fetch man', ignore_status=True)
89 bitbake('-ccleanall man')
90 self.delete_recipeinc('man')
91 self.assertEqual(result.status, 1, msg='Command succeded when it should have failed')
92 self.assertTrue('ERROR: Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were:' in result.output)
93 self.assertTrue('ERROR: Function failed: Fetcher failure for URL: \'file://invalid\'. Unable to fetch URL from any source.' in result.output)
94
95 def test_rename_downloaded_file(self):
96 data = 'SRC_URI_append = ";downloadfilename=test-aspell.tar.gz"'
97 self.write_recipeinc('aspell', data)
98 bitbake('-ccleanall aspell')
99 result = bitbake('-c fetch aspell', ignore_status=True)
100 self.delete_recipeinc('aspell')
101 self.assertEqual(result.status, 0)
102 self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz')))
103 self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz.done')))
104 bitbake('-ccleanall aspell')