[OE-core] [RFC PATCH 3/4] scripts/lib/selftest: add a new module for bitbake output tests

Stefan Stanacar stefanx.stanacar at intel.com
Tue Nov 19 15:43:36 UTC 2013


From: Corneliu Stoicescu <corneliux.stoicescu at intel.com>

Tests for bitbake-layers and expected output for some bitbake options.

Signed-off-by: Corneliu Stoicescu <corneliux.stoicescu at intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar at intel.com>
---
 scripts/lib/selftest/tests/__init__.py |  1 +
 scripts/lib/selftest/tests/bboutput.py | 86 ++++++++++++++++++++++++++++++++++
 2 files changed, 87 insertions(+)
 create mode 100644 scripts/lib/selftest/tests/bboutput.py

diff --git a/scripts/lib/selftest/tests/__init__.py b/scripts/lib/selftest/tests/__init__.py
index e69de29..3acc480 100644
--- a/scripts/lib/selftest/tests/__init__.py
+++ b/scripts/lib/selftest/tests/__init__.py
@@ -0,0 +1 @@
+from selftest.tests.bboutput import *
diff --git a/scripts/lib/selftest/tests/bboutput.py b/scripts/lib/selftest/tests/bboutput.py
new file mode 100644
index 0000000..386572f
--- /dev/null
+++ b/scripts/lib/selftest/tests/bboutput.py
@@ -0,0 +1,86 @@
+import unittest
+import os
+import logging
+import re
+import shutil
+from selftest.base import oeSelfTest
+from selftest.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer
+import selftest.utils.ftools as ftools
+
+class BitbakeTests(oeSelfTest):
+
+    def test_run_bitbake_from_1(self):
+        os.chdir(os.path.join(self.builddir, 'conf'))
+        bitbake('-e')
+
+    def test_run_bitbake_from_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):
+        inc_file = os.path.join(get_test_layer(), 'recipes-test/man/test_recipe.inc')
+        ftools.write_file(inc_file, 'SRC_URI += "file://man-1.5h1-make.patch"')
+        result = bitbake('man -c patch', ignore_status=True)
+        os.remove(inc_file)
+        bitbake('-cclean man')
+        self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output)
+
+
+class BitbakeLayers(oeSelfTest):
+
+    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):
+        if os.path.isdir(os.path.join(self.builddir, 'test')):
+            shutil.rmtree(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 #####\nTEST_VAR = \"\"", contents)
+        shutil.rmtree(os.path.join(self.builddir, 'test'))
+        self.assertTrue(find_in_contents)
-- 
1.8.3.1




More information about the Openembedded-core mailing list