aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib
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 12:50:23 +0000
commit8408a7700cd9cab4559ddae0bbe57f0d7fae5c37 (patch)
tree688fc04e76cc179ca031845ce059490a7f9b5b26 /meta/lib
parent75d2a1a37a18a22b0da7ab5b30cf005c78bc313f (diff)
downloadopenembedded-core-contrib-8408a7700cd9cab4559ddae0bbe57f0d7fae5c37.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. 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')
-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 @@
+import unittest
+import os
+import logging
+import re
+import shutil
+
+import oeqa.utils.ftools as ftools
+from oeqa.selftest.base import oeSelfTest
+from oeqa.utils.commands import runCmd
+
+class BitbakeLayers(oeSelfTest):
+
+ def test_bitbakelayers_showcrossdepends(self):
+ result = runCmd('bitbake-layers show-cross-depends')
+ self.assertTrue('aspell' in result.output)
+
+ def test_bitbakelayers_showlayers(self):
+ result = runCmd('bitbake-layers show_layers')
+ self.assertTrue('meta-selftest' in result.output)
+
+ def test_bitbakelayers_showappends(self):
+ result = runCmd('bitbake-layers show_appends')
+ self.assertTrue('xcursor-transparent-theme_0.1.1.bbappend' in result.output, msg='xcursor-transparent-theme_0.1.1.bbappend file was not recognised')
+
+ def test_bitbakelayers_showoverlayed(self):
+ result = runCmd('bitbake-layers show_overlayed')
+ self.assertTrue('aspell' in result.output, msg='xcursor-transparent-theme_0.1.1.bbappend file was not recognised')
+
+ def test_bitbakelayers_flatten(self):
+ self.assertFalse(os.path.isdir(os.path.join(self.builddir, 'test')))
+ result = runCmd('bitbake-layers flatten test')
+ bb_file = os.path.join(self.builddir, 'test/recipes-graphics/xcursor-transparent-theme/xcursor-transparent-theme_0.1.1.bb')
+ self.assertTrue(os.path.isfile(bb_file))
+ contents = ftools.read_file(bb_file)
+ find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents)
+ shutil.rmtree(os.path.join(self.builddir, 'test'))
+ 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 @@
+import unittest
+import os
+import logging
+import re
+import shutil
+
+import oeqa.utils.ftools as ftools
+from oeqa.selftest.base import oeSelfTest
+from oeqa.utils.commands import runCmd, bitbake, get_bb_var
+
+class BitbakeTests(oeSelfTest):
+
+ def test_run_bitbake_from_dir_1(self):
+ os.chdir(os.path.join(self.builddir, 'conf'))
+ bitbake('-e')
+
+ def test_run_bitbake_from_dir_2(self):
+ my_env = os.environ.copy()
+ my_env['BBPATH'] = my_env['BUILDDIR']
+ os.chdir(os.path.dirname(os.environ['BUILDDIR']))
+ bitbake('-e', env=my_env)
+
+ def test_event_handler(self):
+ self.write_config("INHERIT += \"test_events\"")
+ result = bitbake('m4-native')
+ find_build_started = re.search("NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Preparing runqueue", result.output)
+ find_build_completed = re.search("Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output)
+ self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output)
+ self.assertTrue(find_build_completed, msg = "Match failed in:\n%s" % result.output)
+ self.assertFalse('Test for bb.event.InvalidEvent' in result.output)
+
+ def test_local_sstate(self):
+ bitbake('m4-native -ccleansstate')
+ bitbake('m4-native')
+ bitbake('m4-native -cclean')
+ result = bitbake('m4-native')
+ find_setscene = re.search("m4-native.*do_.*_setscene", result.output)
+ self.assertTrue(find_setscene)
+
+ def test_bitbake_invalid_recipe(self):
+ result = bitbake('-b asdf', ignore_status=True)
+ self.assertTrue("ERROR: Unable to find any recipe file matching 'asdf'" in result.output)
+
+ def test_bitbake_invalid_target(self):
+ result = bitbake('asdf', ignore_status=True)
+ self.assertTrue("ERROR: Nothing PROVIDES 'asdf'" in result.output)
+
+ def test_warnings_errors(self):
+ result = bitbake('-b asdf', ignore_status=True)
+ find_warnings = re.search("Summary: There was [1-9][0-9]* WARNING message shown.", result.output)
+ find_errors = re.search("Summary: There was [1-9][0-9]* ERROR message shown.", result.output)
+ self.assertTrue(find_warnings)
+ self.assertTrue(find_errors)
+
+ def test_invalid_patch(self):
+ self.write_recipeinc('man', 'SRC_URI += "file://man-1.5h1-make.patch"')
+ result = bitbake('man -c patch', ignore_status=True)
+ self.delete_recipeinc('man')
+ bitbake('-cclean man')
+ self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output)
+
+ def test_force_task(self):
+ bitbake('m4-native')
+ result = bitbake('-C compile m4-native')
+ look_for_tasks = ['do_compile', 'do_install', 'do_populate_sysroot']
+ for task in look_for_tasks:
+ find_task = re.search("m4-native.*%s" % task, result.output)
+ self.assertTrue(find_task)
+
+ def test_bitbake_g(self):
+ result = bitbake('-g core-image-basic')
+ self.assertTrue('NOTE: PN build list saved to \'pn-buildlist\'' in result.output)
+ self.assertTrue('openssh' in ftools.read_file(os.path.join(self.builddir, 'pn-buildlist')))
+ for f in ['pn-buildlist', 'pn-depends.dot', 'package-depends.dot', 'task-depends.dot']:
+ os.remove(f)
+
+ def test_invalid_recipe_src_uri(self):
+ data = 'SRC_URI = "file://invalid"'
+ self.write_recipeinc('man', data)
+ bitbake('-ccleanall man')
+ result = bitbake('-c fetch man', ignore_status=True)
+ bitbake('-ccleanall man')
+ self.delete_recipeinc('man')
+ self.assertEqual(result.status, 1, msg='Command succeded when it should have failed')
+ self.assertTrue('ERROR: Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were:' in result.output)
+ self.assertTrue('ERROR: Function failed: Fetcher failure for URL: \'file://invalid\'. Unable to fetch URL from any source.' in result.output)
+
+ def test_rename_downloaded_file(self):
+ data = 'SRC_URI_append = ";downloadfilename=test-aspell.tar.gz"'
+ self.write_recipeinc('aspell', data)
+ bitbake('-ccleanall aspell')
+ result = bitbake('-c fetch aspell', ignore_status=True)
+ self.delete_recipeinc('aspell')
+ self.assertEqual(result.status, 0)
+ self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz')))
+ self.assertTrue(os.path.isfile(os.path.join(get_bb_var("DL_DIR"), 'test-aspell.tar.gz.done')))
+ bitbake('-ccleanall aspell')