summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/selftest
diff options
context:
space:
mode:
authorCorneliu Stoicescu <corneliux.stoicescu@intel.com>2013-11-27 19:08:53 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-03 17:45:51 +0000
commit1611b474b69228597b46590db5fe8532b71147df (patch)
tree381e41d25d158abade514d77062f88519e8cce65 /meta/lib/oeqa/selftest
parentf8ee10865dcde6693f5e7ba47a2a00a4955bdffb (diff)
downloadpoky-1611b474b69228597b46590db5fe8532b71147df.tar.gz
lib/oeqa/selftest: add test modules for expected bitbake output and bitbake-layers
Tests for bitbake-layers and expected output for some bitbake options. (From OE-Core rev: 8408a7700cd9cab4559ddae0bbe57f0d7fae5c37) Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu@intel.com> Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/selftest')
-rw-r--r--meta/lib/oeqa/selftest/bblayers.py37
-rw-r--r--meta/lib/oeqa/selftest/bbtests.py97
2 files changed, 134 insertions, 0 deletions
diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py
new file mode 100644
index 0000000000..52aa4f8112
--- /dev/null
+++ b/meta/lib/oeqa/selftest/bblayers.py
@@ -0,0 +1,37 @@
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
10
11class BitbakeLayers(oeSelfTest):
12
13 def test_bitbakelayers_showcrossdepends(self):
14 result = runCmd('bitbake-layers show-cross-depends')
15 self.assertTrue('aspell' in result.output)
16
17 def test_bitbakelayers_showlayers(self):
18 result = runCmd('bitbake-layers show_layers')
19 self.assertTrue('meta-selftest' in result.output)
20
21 def test_bitbakelayers_showappends(self):
22 result = runCmd('bitbake-layers show_appends')
23 self.assertTrue('xcursor-transparent-theme_0.1.1.bbappend' in result.output, msg='xcursor-transparent-theme_0.1.1.bbappend file was not recognised')
24
25 def test_bitbakelayers_showoverlayed(self):
26 result = runCmd('bitbake-layers show_overlayed')
27 self.assertTrue('aspell' in result.output, msg='xcursor-transparent-theme_0.1.1.bbappend file was not recognised')
28
29 def test_bitbakelayers_flatten(self):
30 self.assertFalse(os.path.isdir(os.path.join(self.builddir, 'test')))
31 result = runCmd('bitbake-layers flatten test')
32 bb_file = os.path.join(self.builddir, 'test/recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb')
33 self.assertTrue(os.path.isfile(bb_file))
34 contents = ftools.read_file(bb_file)
35 find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents)
36 shutil.rmtree(os.path.join(self.builddir, 'test'))
37 self.assertTrue(find_in_contents)
diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py
new file mode 100644
index 0000000000..01e0099644
--- /dev/null
+++ b/meta/lib/oeqa/selftest/bbtests.py
@@ -0,0 +1,97 @@
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 was [1-9][0-9]* WARNING message shown.", result.output)
51 find_errors = re.search("Summary: There was [1-9][0-9]* ERROR message shown.", result.output)
52 self.assertTrue(find_warnings)
53 self.assertTrue(find_errors)
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-basic')
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_invalid_recipe_src_uri(self):
78 data = 'SRC_URI = "file://invalid"'
79 self.write_recipeinc('man', data)
80 bitbake('-ccleanall man')
81 result = bitbake('-c fetch man', ignore_status=True)
82 bitbake('-ccleanall man')
83 self.delete_recipeinc('man')
84 self.assertEqual(result.status, 1, msg='Command succeded when it should have failed')
85 self.assertTrue('ERROR: Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were:' in result.output)
86 self.assertTrue('ERROR: Function failed: Fetcher failure for URL: \'file://invalid\'. Unable to fetch URL from any source.' in result.output)
87
88 def test_rename_downloaded_file(self):
89 data = 'SRC_URI_append = ";downloadfilename=test-aspell.tar.gz"'
90 self.write_recipeinc('aspell', data)
91 bitbake('-ccleanall aspell')
92 result = bitbake('-c fetch aspell', ignore_status=True)
93 self.delete_recipeinc('aspell')
94 self.assertEqual(result.status, 0)
95 self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz')))
96 self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz.done')))
97 bitbake('-ccleanall aspell')