From ddbbefdd124604d10bd47dd0266b55a764fcc0ab Mon Sep 17 00:00:00 2001 From: Leonardo Sandoval Date: Fri, 12 May 2017 14:40:21 -0700 Subject: oeqa/selftest/cases: Migrate test cases into the new oe-qa framework MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Signed-off-by: Leonardo Sandoval Signed-off-by: Aníbal Limón --- meta/lib/oeqa/selftest/__init__.py | 2 - meta/lib/oeqa/selftest/_sstatetests_noauto.py | 95 -- meta/lib/oeqa/selftest/archiver.py | 43 - meta/lib/oeqa/selftest/bblayers.py | 99 -- meta/lib/oeqa/selftest/bbtests.py | 278 ---- meta/lib/oeqa/selftest/buildhistory.py | 47 - meta/lib/oeqa/selftest/buildoptions.py | 184 --- .../lib/oeqa/selftest/cases/_sstatetests_noauto.py | 92 ++ meta/lib/oeqa/selftest/cases/archiver.py | 41 + meta/lib/oeqa/selftest/cases/bblayers.py | 97 ++ meta/lib/oeqa/selftest/cases/bbtests.py | 279 ++++ meta/lib/oeqa/selftest/cases/buildhistory.py | 46 + meta/lib/oeqa/selftest/cases/buildoptions.py | 184 +++ meta/lib/oeqa/selftest/cases/containerimage.py | 83 + meta/lib/oeqa/selftest/cases/devtool.py | 1696 ++++++++++++++++++++ meta/lib/oeqa/selftest/cases/eSDK.py | 111 ++ meta/lib/oeqa/selftest/cases/image_typedep.py | 51 + meta/lib/oeqa/selftest/cases/imagefeatures.py | 125 ++ meta/lib/oeqa/selftest/cases/layerappend.py | 95 ++ meta/lib/oeqa/selftest/cases/liboe.py | 98 ++ meta/lib/oeqa/selftest/cases/lic_checksum.py | 35 + meta/lib/oeqa/selftest/cases/manifest.py | 166 ++ meta/lib/oeqa/selftest/cases/oelib/__init__.py | 0 meta/lib/oeqa/selftest/cases/oelib/buildhistory.py | 88 + meta/lib/oeqa/selftest/cases/oelib/elf.py | 21 + meta/lib/oeqa/selftest/cases/oelib/license.py | 68 + meta/lib/oeqa/selftest/cases/oelib/path.py | 89 + meta/lib/oeqa/selftest/cases/oelib/types.py | 50 + meta/lib/oeqa/selftest/cases/oelib/utils.py | 51 + meta/lib/oeqa/selftest/cases/oescripts.py | 15 + meta/lib/oeqa/selftest/cases/package.py | 80 + meta/lib/oeqa/selftest/cases/pkgdata.py | 224 +++ meta/lib/oeqa/selftest/cases/prservice.py | 131 ++ meta/lib/oeqa/selftest/cases/recipetool.py | 694 ++++++++ meta/lib/oeqa/selftest/cases/runqemu.py | 141 ++ meta/lib/oeqa/selftest/cases/runtime_test.py | 239 +++ meta/lib/oeqa/selftest/cases/signing.py | 184 +++ meta/lib/oeqa/selftest/cases/sstate.py | 63 + meta/lib/oeqa/selftest/cases/sstatetests.py | 479 ++++++ meta/lib/oeqa/selftest/cases/tinfoil.py | 189 +++ meta/lib/oeqa/selftest/cases/wic.py | 793 +++++++++ meta/lib/oeqa/selftest/containerimage.py | 83 - meta/lib/oeqa/selftest/devtool.py | 1696 -------------------- meta/lib/oeqa/selftest/eSDK.py | 115 -- meta/lib/oeqa/selftest/image_typedep.py | 51 - meta/lib/oeqa/selftest/imagefeatures.py | 127 -- meta/lib/oeqa/selftest/layerappend.py | 100 -- meta/lib/oeqa/selftest/liboe.py | 99 -- meta/lib/oeqa/selftest/lic-checksum.py | 35 - meta/lib/oeqa/selftest/manifest.py | 166 -- meta/lib/oeqa/selftest/oelib/__init__.py | 0 meta/lib/oeqa/selftest/oelib/buildhistory.py | 88 - meta/lib/oeqa/selftest/oelib/elf.py | 21 - meta/lib/oeqa/selftest/oelib/license.py | 68 - meta/lib/oeqa/selftest/oelib/path.py | 89 - meta/lib/oeqa/selftest/oelib/types.py | 50 - meta/lib/oeqa/selftest/oelib/utils.py | 51 - meta/lib/oeqa/selftest/oescripts.py | 22 - meta/lib/oeqa/selftest/package.py | 80 - meta/lib/oeqa/selftest/pkgdata.py | 227 --- meta/lib/oeqa/selftest/prservice.py | 132 -- meta/lib/oeqa/selftest/recipetool.py | 695 -------- meta/lib/oeqa/selftest/runqemu.py | 140 -- meta/lib/oeqa/selftest/runtime-test.py | 238 --- meta/lib/oeqa/selftest/signing.py | 183 --- meta/lib/oeqa/selftest/sstate.py | 62 - meta/lib/oeqa/selftest/sstatetests.py | 483 ------ meta/lib/oeqa/selftest/tinfoil.py | 190 --- meta/lib/oeqa/selftest/wic.py | 791 --------- 69 files changed, 6798 insertions(+), 6830 deletions(-) delete mode 100644 meta/lib/oeqa/selftest/__init__.py delete mode 100644 meta/lib/oeqa/selftest/_sstatetests_noauto.py delete mode 100644 meta/lib/oeqa/selftest/archiver.py delete mode 100644 meta/lib/oeqa/selftest/bblayers.py delete mode 100644 meta/lib/oeqa/selftest/bbtests.py delete mode 100644 meta/lib/oeqa/selftest/buildhistory.py delete mode 100644 meta/lib/oeqa/selftest/buildoptions.py create mode 100644 meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py create mode 100644 meta/lib/oeqa/selftest/cases/archiver.py create mode 100644 meta/lib/oeqa/selftest/cases/bblayers.py create mode 100644 meta/lib/oeqa/selftest/cases/bbtests.py create mode 100644 meta/lib/oeqa/selftest/cases/buildhistory.py create mode 100644 meta/lib/oeqa/selftest/cases/buildoptions.py create mode 100644 meta/lib/oeqa/selftest/cases/containerimage.py create mode 100644 meta/lib/oeqa/selftest/cases/devtool.py create mode 100644 meta/lib/oeqa/selftest/cases/eSDK.py create mode 100644 meta/lib/oeqa/selftest/cases/image_typedep.py create mode 100644 meta/lib/oeqa/selftest/cases/imagefeatures.py create mode 100644 meta/lib/oeqa/selftest/cases/layerappend.py create mode 100644 meta/lib/oeqa/selftest/cases/liboe.py create mode 100644 meta/lib/oeqa/selftest/cases/lic_checksum.py create mode 100644 meta/lib/oeqa/selftest/cases/manifest.py create mode 100644 meta/lib/oeqa/selftest/cases/oelib/__init__.py create mode 100644 meta/lib/oeqa/selftest/cases/oelib/buildhistory.py create mode 100644 meta/lib/oeqa/selftest/cases/oelib/elf.py create mode 100644 meta/lib/oeqa/selftest/cases/oelib/license.py create mode 100644 meta/lib/oeqa/selftest/cases/oelib/path.py create mode 100644 meta/lib/oeqa/selftest/cases/oelib/types.py create mode 100644 meta/lib/oeqa/selftest/cases/oelib/utils.py create mode 100644 meta/lib/oeqa/selftest/cases/oescripts.py create mode 100644 meta/lib/oeqa/selftest/cases/package.py create mode 100644 meta/lib/oeqa/selftest/cases/pkgdata.py create mode 100644 meta/lib/oeqa/selftest/cases/prservice.py create mode 100644 meta/lib/oeqa/selftest/cases/recipetool.py create mode 100644 meta/lib/oeqa/selftest/cases/runqemu.py create mode 100644 meta/lib/oeqa/selftest/cases/runtime_test.py create mode 100644 meta/lib/oeqa/selftest/cases/signing.py create mode 100644 meta/lib/oeqa/selftest/cases/sstate.py create mode 100644 meta/lib/oeqa/selftest/cases/sstatetests.py create mode 100644 meta/lib/oeqa/selftest/cases/tinfoil.py create mode 100644 meta/lib/oeqa/selftest/cases/wic.py delete mode 100644 meta/lib/oeqa/selftest/containerimage.py delete mode 100644 meta/lib/oeqa/selftest/devtool.py delete mode 100644 meta/lib/oeqa/selftest/eSDK.py delete mode 100644 meta/lib/oeqa/selftest/image_typedep.py delete mode 100644 meta/lib/oeqa/selftest/imagefeatures.py delete mode 100644 meta/lib/oeqa/selftest/layerappend.py delete mode 100644 meta/lib/oeqa/selftest/liboe.py delete mode 100644 meta/lib/oeqa/selftest/lic-checksum.py delete mode 100644 meta/lib/oeqa/selftest/manifest.py delete mode 100644 meta/lib/oeqa/selftest/oelib/__init__.py delete mode 100644 meta/lib/oeqa/selftest/oelib/buildhistory.py delete mode 100644 meta/lib/oeqa/selftest/oelib/elf.py delete mode 100644 meta/lib/oeqa/selftest/oelib/license.py delete mode 100644 meta/lib/oeqa/selftest/oelib/path.py delete mode 100644 meta/lib/oeqa/selftest/oelib/types.py delete mode 100644 meta/lib/oeqa/selftest/oelib/utils.py delete mode 100644 meta/lib/oeqa/selftest/oescripts.py delete mode 100644 meta/lib/oeqa/selftest/package.py delete mode 100644 meta/lib/oeqa/selftest/pkgdata.py delete mode 100644 meta/lib/oeqa/selftest/prservice.py delete mode 100644 meta/lib/oeqa/selftest/recipetool.py delete mode 100644 meta/lib/oeqa/selftest/runqemu.py delete mode 100644 meta/lib/oeqa/selftest/runtime-test.py delete mode 100644 meta/lib/oeqa/selftest/signing.py delete mode 100644 meta/lib/oeqa/selftest/sstate.py delete mode 100644 meta/lib/oeqa/selftest/sstatetests.py delete mode 100644 meta/lib/oeqa/selftest/tinfoil.py delete mode 100644 meta/lib/oeqa/selftest/wic.py diff --git a/meta/lib/oeqa/selftest/__init__.py b/meta/lib/oeqa/selftest/__init__.py deleted file mode 100644 index 3ad9513f40..0000000000 --- a/meta/lib/oeqa/selftest/__init__.py +++ /dev/null @@ -1,2 +0,0 @@ -from pkgutil import extend_path -__path__ = extend_path(__path__, __name__) diff --git a/meta/lib/oeqa/selftest/_sstatetests_noauto.py b/meta/lib/oeqa/selftest/_sstatetests_noauto.py deleted file mode 100644 index fc9ae7efb9..0000000000 --- a/meta/lib/oeqa/selftest/_sstatetests_noauto.py +++ /dev/null @@ -1,95 +0,0 @@ -import datetime -import unittest -import os -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, get_test_layer -from oeqa.selftest.sstate import SStateBase - - -class RebuildFromSState(SStateBase): - - @classmethod - def setUpClass(self): - self.builddir = os.path.join(os.environ.get('BUILDDIR')) - - def get_dep_targets(self, primary_targets): - found_targets = [] - bitbake("-g " + ' '.join(map(str, primary_targets))) - with open(os.path.join(self.builddir, 'pn-buildlist'), 'r') as pnfile: - found_targets = pnfile.read().splitlines() - return found_targets - - def configure_builddir(self, builddir): - os.mkdir(builddir) - self.track_for_cleanup(builddir) - os.mkdir(os.path.join(builddir, 'conf')) - shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(builddir, 'conf/local.conf')) - config = {} - config['default_sstate_dir'] = "SSTATE_DIR ?= \"${TOPDIR}/sstate-cache\"" - config['null_sstate_mirrors'] = "SSTATE_MIRRORS = \"\"" - config['default_tmp_dir'] = "TMPDIR = \"${TOPDIR}/tmp\"" - for key in config: - ftools.append_file(os.path.join(builddir, 'conf/selftest.inc'), config[key]) - shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/bblayers.conf'), os.path.join(builddir, 'conf/bblayers.conf')) - try: - shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/auto.conf'), os.path.join(builddir, 'conf/auto.conf')) - except: - pass - - def hardlink_tree(self, src, dst): - os.mkdir(dst) - self.track_for_cleanup(dst) - for root, dirs, files in os.walk(src): - if root == src: - continue - os.mkdir(os.path.join(dst, root.split(src)[1][1:])) - for sstate_file in files: - os.link(os.path.join(root, sstate_file), os.path.join(dst, root.split(src)[1][1:], sstate_file)) - - def run_test_sstate_rebuild(self, primary_targets, relocate=False, rebuild_dependencies=False): - buildA = os.path.join(self.builddir, 'buildA') - if relocate: - buildB = os.path.join(self.builddir, 'buildB') - else: - buildB = buildA - - if rebuild_dependencies: - rebuild_targets = self.get_dep_targets(primary_targets) - else: - rebuild_targets = primary_targets - - self.configure_builddir(buildA) - runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildA)) + 'bitbake ' + ' '.join(map(str, primary_targets)), shell=True, executable='/bin/bash') - self.hardlink_tree(os.path.join(buildA, 'sstate-cache'), os.path.join(self.builddir, 'sstate-cache-buildA')) - shutil.rmtree(buildA) - - failed_rebuild = [] - failed_cleansstate = [] - for target in rebuild_targets: - self.configure_builddir(buildB) - self.hardlink_tree(os.path.join(self.builddir, 'sstate-cache-buildA'), os.path.join(buildB, 'sstate-cache')) - - result_cleansstate = runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildB)) + 'bitbake -ccleansstate ' + target, ignore_status=True, shell=True, executable='/bin/bash') - if not result_cleansstate.status == 0: - failed_cleansstate.append(target) - shutil.rmtree(buildB) - continue - - result_build = runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildB)) + 'bitbake ' + target, ignore_status=True, shell=True, executable='/bin/bash') - if not result_build.status == 0: - failed_rebuild.append(target) - - shutil.rmtree(buildB) - - self.assertFalse(failed_rebuild, msg="The following recipes have failed to rebuild: %s" % ' '.join(map(str, failed_rebuild))) - self.assertFalse(failed_cleansstate, msg="The following recipes have failed cleansstate(all others have passed both cleansstate and rebuild from sstate tests): %s" % ' '.join(map(str, failed_cleansstate))) - - def test_sstate_relocation(self): - self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=True, rebuild_dependencies=True) - - def test_sstate_rebuild(self): - self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=False, rebuild_dependencies=True) diff --git a/meta/lib/oeqa/selftest/archiver.py b/meta/lib/oeqa/selftest/archiver.py deleted file mode 100644 index d7f215cbf6..0000000000 --- a/meta/lib/oeqa/selftest/archiver.py +++ /dev/null @@ -1,43 +0,0 @@ -from oeqa.selftest.base import oeSelfTest -from oeqa.utils.commands import bitbake, get_bb_vars -from oeqa.utils.decorators import testcase -import glob -import os -import shutil - - -class Archiver(oeSelfTest): - - @testcase(1345) - def test_archiver_allows_to_filter_on_recipe_name(self): - """ - Summary: The archiver should offer the possibility to filter on the recipe. (#6929) - Expected: 1. Included recipe (busybox) should be included - 2. Excluded recipe (zlib) should be excluded - Product: oe-core - Author: Daniel Istrate - AutomatedBy: Daniel Istrate - """ - - include_recipe = 'busybox' - exclude_recipe = 'zlib' - - features = 'INHERIT += "archiver"\n' - features += 'ARCHIVER_MODE[src] = "original"\n' - features += 'COPYLEFT_PN_INCLUDE = "%s"\n' % include_recipe - features += 'COPYLEFT_PN_EXCLUDE = "%s"\n' % exclude_recipe - self.write_config(features) - - bitbake('-c clean %s %s' % (include_recipe, exclude_recipe)) - bitbake("%s %s" % (include_recipe, exclude_recipe)) - - bb_vars = get_bb_vars(['DEPLOY_DIR_SRC', 'TARGET_SYS']) - src_path = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['TARGET_SYS']) - - # Check that include_recipe was included - included_present = len(glob.glob(src_path + '/%s-*' % include_recipe)) - self.assertTrue(included_present, 'Recipe %s was not included.' % include_recipe) - - # Check that exclude_recipe was excluded - excluded_present = len(glob.glob(src_path + '/%s-*' % exclude_recipe)) - self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % exclude_recipe) diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py deleted file mode 100644 index cd658c5d4e..0000000000 --- a/meta/lib/oeqa/selftest/bblayers.py +++ /dev/null @@ -1,99 +0,0 @@ -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, get_bb_var -from oeqa.utils.decorators import testcase - -class BitbakeLayers(oeSelfTest): - - @testcase(756) - def test_bitbakelayers_showcrossdepends(self): - result = runCmd('bitbake-layers show-cross-depends') - self.assertTrue('aspell' in result.output, msg = "No dependencies were shown. bitbake-layers show-cross-depends output: %s" % result.output) - - @testcase(83) - def test_bitbakelayers_showlayers(self): - result = runCmd('bitbake-layers show-layers') - self.assertTrue('meta-selftest' in result.output, msg = "No layers were shown. bitbake-layers show-layers output: %s" % result.output) - - @testcase(93) - def test_bitbakelayers_showappends(self): - recipe = "xcursor-transparent-theme" - bb_file = self.get_recipe_basename(recipe) - result = runCmd('bitbake-layers show-appends') - self.assertTrue(bb_file in result.output, msg="%s file was not recognised. bitbake-layers show-appends output: %s" % (bb_file, result.output)) - - @testcase(90) - def test_bitbakelayers_showoverlayed(self): - result = runCmd('bitbake-layers show-overlayed') - self.assertTrue('aspell' in result.output, msg="aspell overlayed recipe was not recognised bitbake-layers show-overlayed %s" % result.output) - - @testcase(95) - def test_bitbakelayers_flatten(self): - recipe = "xcursor-transparent-theme" - recipe_path = "recipes-graphics/xcursor-transparent-theme" - recipe_file = self.get_recipe_basename(recipe) - testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') - self.assertFalse(os.path.isdir(testoutdir), msg = "test_bitbakelayers_flatten should not exist at this point in time") - self.track_for_cleanup(testoutdir) - result = runCmd('bitbake-layers flatten %s' % testoutdir) - bb_file = os.path.join(testoutdir, recipe_path, recipe_file) - self.assertTrue(os.path.isfile(bb_file), msg = "Cannot find xcursor-transparent-theme_0.1.1.bb in the test_bitbakelayers_flatten local dir.") - contents = ftools.read_file(bb_file) - find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents) - self.assertTrue(find_in_contents, msg = "Flattening layers did not work. bitbake-layers flatten output: %s" % result.output) - - @testcase(1195) - def test_bitbakelayers_add_remove(self): - test_layer = os.path.join(get_bb_var('COREBASE'), 'meta-skeleton') - result = runCmd('bitbake-layers show-layers') - self.assertNotIn('meta-skeleton', result.output, "This test cannot run with meta-skeleton in bblayers.conf. bitbake-layers show-layers output: %s" % result.output) - result = runCmd('bitbake-layers add-layer %s' % test_layer) - result = runCmd('bitbake-layers show-layers') - self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf. bitbake-layers show-layers output: %s" % result.output) - result = runCmd('bitbake-layers remove-layer %s' % test_layer) - result = runCmd('bitbake-layers show-layers') - self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step. bitbake-layers show-layers output: %s" % result.output) - result = runCmd('bitbake-layers add-layer %s' % test_layer) - result = runCmd('bitbake-layers show-layers') - self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf. bitbake-layers show-layers output: %s" % result.output) - result = runCmd('bitbake-layers remove-layer */meta-skeleton') - result = runCmd('bitbake-layers show-layers') - self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step. bitbake-layers show-layers output: %s" % result.output) - - @testcase(1384) - def test_bitbakelayers_showrecipes(self): - result = runCmd('bitbake-layers show-recipes') - self.assertIn('aspell:', result.output) - self.assertIn('mtd-utils:', result.output) - self.assertIn('core-image-minimal:', result.output) - result = runCmd('bitbake-layers show-recipes mtd-utils') - self.assertIn('mtd-utils:', result.output) - self.assertNotIn('aspell:', result.output) - result = runCmd('bitbake-layers show-recipes -i image') - self.assertIn('core-image-minimal', result.output) - self.assertNotIn('mtd-utils:', result.output) - result = runCmd('bitbake-layers show-recipes -i cmake,pkgconfig') - self.assertIn('libproxy:', result.output) - self.assertNotIn('mtd-utils:', result.output) # doesn't inherit either - self.assertNotIn('wget:', result.output) # doesn't inherit cmake - self.assertNotIn('waffle:', result.output) # doesn't inherit pkgconfig - result = runCmd('bitbake-layers show-recipes -i nonexistentclass', ignore_status=True) - self.assertNotEqual(result.status, 0, 'bitbake-layers show-recipes -i nonexistentclass should have failed') - self.assertIn('ERROR:', result.output) - - def get_recipe_basename(self, recipe): - recipe_file = "" - result = runCmd("bitbake-layers show-recipes -f %s" % recipe) - for line in result.output.splitlines(): - if recipe in line: - recipe_file = line - break - - self.assertTrue(os.path.isfile(recipe_file), msg = "Can't find recipe file for %s" % recipe) - return os.path.basename(recipe_file) 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 @@ -import os -import re - -import oeqa.utils.ftools as ftools -from oeqa.selftest.base import oeSelfTest -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars -from oeqa.utils.decorators import testcase - -class BitbakeTests(oeSelfTest): - - def getline(self, res, line): - for l in res.output.split('\n'): - if line in l: - return l - - @testcase(789) - def test_run_bitbake_from_dir_1(self): - os.chdir(os.path.join(self.builddir, 'conf')) - self.assertEqual(bitbake('-e').status, 0, msg = "bitbake couldn't run from \"conf\" dir") - - @testcase(790) - 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'])) - self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from builddir") - - @testcase(806) - 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: Executing RunQueue Tasks", 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, msg = "\"Test for bb.event.InvalidEvent\" message found during bitbake process. bitbake output: %s" % result.output) - - @testcase(103) - def test_local_sstate(self): - 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, msg = "No \"m4-native.*do_.*_setscene\" message found during bitbake m4-native. bitbake output: %s" % result.output ) - - @testcase(105) - 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, msg = "Though asdf recipe doesn't exist, bitbake didn't output any err. message. bitbake output: %s" % result.output) - - @testcase(107) - def test_bitbake_invalid_target(self): - result = bitbake('asdf', ignore_status=True) - 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) - - @testcase(106) - def test_warnings_errors(self): - result = bitbake('-b asdf', ignore_status=True) - find_warnings = re.search("Summary: There w.{2,3}? [1-9][0-9]* WARNING messages* shown", result.output) - find_errors = re.search("Summary: There w.{2,3}? [1-9][0-9]* ERROR messages* shown", result.output) - self.assertTrue(find_warnings, msg="Did not find the mumber of warnings at the end of the build:\n" + result.output) - self.assertTrue(find_errors, msg="Did not find the mumber of errors at the end of the build:\n" + result.output) - - @testcase(108) - def test_invalid_patch(self): - # This patch already exists in SRC_URI so adding it again will cause the - # patch to fail. - self.write_recipeinc('man', 'SRC_URI += "file://man-1.5h1-make.patch"') - self.write_config("INHERIT_remove = \"report-error\"") - result = bitbake('man -c patch', ignore_status=True) - self.delete_recipeinc('man') - bitbake('-cclean man') - line = self.getline(result, "Function failed: patch_do_patch") - self.assertTrue(line and line.startswith("ERROR:"), msg = "Repeated patch application didn't fail. bitbake output: %s" % result.output) - - @testcase(1354) - def test_force_task_1(self): - # test 1 from bug 5875 - test_recipe = 'zlib' - test_data = "Microsoft Made No Profit From Anyone's Zunes Yo" - bb_vars = get_bb_vars(['D', 'PKGDEST', 'mandir'], test_recipe) - image_dir = bb_vars['D'] - pkgsplit_dir = bb_vars['PKGDEST'] - man_dir = bb_vars['mandir'] - - bitbake('-c clean %s' % test_recipe) - bitbake('-c package -f %s' % test_recipe) - self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) - - man_file = os.path.join(image_dir + man_dir, 'man3/zlib.3') - ftools.append_file(man_file, test_data) - bitbake('-c package -f %s' % test_recipe) - - man_split_file = os.path.join(pkgsplit_dir, 'zlib-doc' + man_dir, 'man3/zlib.3') - man_split_content = ftools.read_file(man_split_file) - self.assertIn(test_data, man_split_content, 'The man file has not changed in packages-split.') - - ret = bitbake(test_recipe) - self.assertIn('task do_package_write_rpm:', ret.output, 'Task do_package_write_rpm did not re-executed.') - - @testcase(163) - def test_force_task_2(self): - # test 2 from bug 5875 - test_recipe = 'zlib' - - bitbake(test_recipe) - self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) - - result = bitbake('-C compile %s' % test_recipe) - look_for_tasks = ['do_compile:', 'do_install:', 'do_populate_sysroot:', 'do_package:'] - for task in look_for_tasks: - self.assertIn(task, result.output, msg="Couldn't find %s task.") - - @testcase(167) - def test_bitbake_g(self): - result = bitbake('-g core-image-minimal') - for f in ['pn-buildlist', 'recipe-depends.dot', 'task-depends.dot']: - self.addCleanup(os.remove, f) - 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) - 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.") - - @testcase(899) - def test_image_manifest(self): - bitbake('core-image-minimal') - bb_vars = get_bb_vars(["DEPLOY_DIR_IMAGE", "IMAGE_LINK_NAME"], "core-image-minimal") - deploydir = bb_vars["DEPLOY_DIR_IMAGE"] - imagename = bb_vars["IMAGE_LINK_NAME"] - manifest = os.path.join(deploydir, imagename + ".manifest") - self.assertTrue(os.path.islink(manifest), msg="No manifest file created for image. It should have been created in %s" % manifest) - - @testcase(168) - def test_invalid_recipe_src_uri(self): - data = 'SRC_URI = "file://invalid"' - self.write_recipeinc('man', data) - self.write_config("""DL_DIR = \"${TOPDIR}/download-selftest\" -SSTATE_DIR = \"${TOPDIR}/download-selftest\" -INHERIT_remove = \"report-error\" -""") - self.track_for_cleanup(os.path.join(self.builddir, "download-selftest")) - - 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. bitbake output: %s" % result.output) - self.assertTrue('Fetcher failure: Unable to find file file://invalid anywhere. The paths that were searched were:' in result.output, msg = "\"invalid\" file \ -doesn't exist, yet no error message encountered. bitbake output: %s" % result.output) - line = self.getline(result, 'Fetcher failure for URL: \'file://invalid\'. Unable to fetch URL from any source.') - self.assertTrue(line and line.startswith("ERROR:"), msg = "\"invalid\" file \ -doesn't exist, yet fetcher didn't report any error. bitbake output: %s" % result.output) - - @testcase(171) - def test_rename_downloaded_file(self): - # TODO unique dldir instead of using cleanall - # TODO: need to set sstatedir? - self.write_config("""DL_DIR = \"${TOPDIR}/download-selftest\" -SSTATE_DIR = \"${TOPDIR}/download-selftest\" -""") - self.track_for_cleanup(os.path.join(self.builddir, "download-selftest")) - - data = 'SRC_URI = "${GNU_MIRROR}/aspell/aspell-${PV}.tar.gz;downloadfilename=test-aspell.tar.gz"' - self.write_recipeinc('aspell', data) - result = bitbake('-f -c fetch aspell', ignore_status=True) - self.delete_recipeinc('aspell') - self.assertEqual(result.status, 0, msg = "Couldn't fetch aspell. %s" % result.output) - dl_dir = get_bb_var("DL_DIR") - 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) - 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) - - @testcase(1028) - def test_environment(self): - self.write_config("TEST_ENV=\"localconf\"") - result = runCmd('bitbake -e | grep TEST_ENV=') - 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='") - - @testcase(1029) - def test_dry_run(self): - result = runCmd('bitbake -n m4-native') - self.assertEqual(0, result.status, "bitbake dry run didn't run as expected. %s" % result.output) - - @testcase(1030) - def test_just_parse(self): - result = runCmd('bitbake -p') - self.assertEqual(0, result.status, "errors encountered when parsing recipes. %s" % result.output) - - @testcase(1031) - def test_version(self): - result = runCmd('bitbake -s | grep wget') - find = re.search("wget *:([0-9a-zA-Z\.\-]+)", result.output) - self.assertTrue(find, "No version returned for searched recipe. bitbake output: %s" % result.output) - - @testcase(1032) - def test_prefile(self): - preconf = os.path.join(self.builddir, 'conf/prefile.conf') - self.track_for_cleanup(preconf) - ftools.write_file(preconf ,"TEST_PREFILE=\"prefile\"") - result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=') - self.assertTrue('prefile' in result.output, "Preconfigure file \"prefile.conf\"was not taken into consideration. ") - self.write_config("TEST_PREFILE=\"localconf\"") - result = runCmd('bitbake -r conf/prefile.conf -e | grep TEST_PREFILE=') - self.assertTrue('localconf' in result.output, "Preconfigure file \"prefile.conf\"was not taken into consideration.") - - @testcase(1033) - def test_postfile(self): - postconf = os.path.join(self.builddir, 'conf/postfile.conf') - self.track_for_cleanup(postconf) - ftools.write_file(postconf , "TEST_POSTFILE=\"postfile\"") - self.write_config("TEST_POSTFILE=\"localconf\"") - result = runCmd('bitbake -R conf/postfile.conf -e | grep TEST_POSTFILE=') - self.assertTrue('postfile' in result.output, "Postconfigure file \"postfile.conf\"was not taken into consideration.") - - @testcase(1034) - def test_checkuri(self): - result = runCmd('bitbake -c checkuri m4') - self.assertEqual(0, result.status, msg = "\"checkuri\" task was not executed. bitbake output: %s" % result.output) - - @testcase(1035) - def test_continue(self): - self.write_config("""DL_DIR = \"${TOPDIR}/download-selftest\" -SSTATE_DIR = \"${TOPDIR}/download-selftest\" -INHERIT_remove = \"report-error\" -""") - self.track_for_cleanup(os.path.join(self.builddir, "download-selftest")) - self.write_recipeinc('man',"\ndo_fail_task () {\nexit 1 \n}\n\naddtask do_fail_task before do_fetch\n" ) - runCmd('bitbake -c cleanall man xcursor-transparent-theme') - result = runCmd('bitbake -c unpack -k man xcursor-transparent-theme', ignore_status=True) - errorpos = result.output.find('ERROR: Function failed: do_fail_task') - manver = re.search("NOTE: recipe xcursor-transparent-theme-(.*?): task do_unpack: Started", result.output) - continuepos = result.output.find('NOTE: recipe xcursor-transparent-theme-%s: task do_unpack: Started' % manver.group(1)) - self.assertLess(errorpos,continuepos, msg = "bitbake didn't pass do_fail_task. bitbake output: %s" % result.output) - - @testcase(1119) - def test_non_gplv3(self): - self.write_config('INCOMPATIBLE_LICENSE = "GPLv3"') - result = bitbake('selftest-ed', ignore_status=True) - self.assertEqual(result.status, 0, "Bitbake failed, exit code %s, output %s" % (result.status, result.output)) - lic_dir = get_bb_var('LICENSE_DIRECTORY') - self.assertFalse(os.path.isfile(os.path.join(lic_dir, 'selftest-ed/generic_GPLv3'))) - self.assertTrue(os.path.isfile(os.path.join(lic_dir, 'selftest-ed/generic_GPLv2'))) - - @testcase(1422) - def test_setscene_only(self): - """ Bitbake option to restore from sstate only within a build (i.e. execute no real tasks, only setscene)""" - test_recipe = 'ed' - - bitbake(test_recipe) - bitbake('-c clean %s' % test_recipe) - ret = bitbake('--setscene-only %s' % test_recipe) - - tasks = re.findall(r'task\s+(do_\S+):', ret.output) - - for task in tasks: - self.assertIn('_setscene', task, 'A task different from _setscene ran: %s.\n' - 'Executed tasks were: %s' % (task, str(tasks))) - - @testcase(1425) - def test_bbappend_order(self): - """ Bitbake should bbappend to recipe in a predictable order """ - test_recipe = 'ed' - bb_vars = get_bb_vars(['SUMMARY', 'PV'], test_recipe) - test_recipe_summary_before = bb_vars['SUMMARY'] - test_recipe_pv = bb_vars['PV'] - recipe_append_file = test_recipe + '_' + test_recipe_pv + '.bbappend' - expected_recipe_summary = test_recipe_summary_before - - for i in range(5): - recipe_append_dir = test_recipe + '_test_' + str(i) - recipe_append_path = os.path.join(self.testlayer_path, 'recipes-test', recipe_append_dir, recipe_append_file) - os.mkdir(os.path.join(self.testlayer_path, 'recipes-test', recipe_append_dir)) - feature = 'SUMMARY += "%s"\n' % i - ftools.write_file(recipe_append_path, feature) - expected_recipe_summary += ' %s' % i - - self.add_command_to_tearDown('rm -rf %s' % os.path.join(self.testlayer_path, 'recipes-test', - test_recipe + '_test_*')) - - test_recipe_summary_after = get_bb_var('SUMMARY', test_recipe) - self.assertEqual(expected_recipe_summary, test_recipe_summary_after) diff --git a/meta/lib/oeqa/selftest/buildhistory.py b/meta/lib/oeqa/selftest/buildhistory.py deleted file mode 100644 index 008c39c956..0000000000 --- a/meta/lib/oeqa/selftest/buildhistory.py +++ /dev/null @@ -1,47 +0,0 @@ -import os -import re -import datetime - -from oeqa.selftest.base import oeSelfTest -from oeqa.utils.commands import bitbake, get_bb_vars -from oeqa.utils.decorators import testcase - - -class BuildhistoryBase(oeSelfTest): - - def config_buildhistory(self, tmp_bh_location=False): - bb_vars = get_bb_vars(['USER_CLASSES', 'INHERIT']) - if (not 'buildhistory' in bb_vars['USER_CLASSES']) and (not 'buildhistory' in bb_vars['INHERIT']): - add_buildhistory_config = 'INHERIT += "buildhistory"\nBUILDHISTORY_COMMIT = "1"' - self.append_config(add_buildhistory_config) - - if tmp_bh_location: - # Using a temporary buildhistory location for testing - tmp_bh_dir = os.path.join(self.builddir, "tmp_buildhistory_%s" % datetime.datetime.now().strftime('%Y%m%d%H%M%S')) - buildhistory_dir_config = "BUILDHISTORY_DIR = \"%s\"" % tmp_bh_dir - self.append_config(buildhistory_dir_config) - self.track_for_cleanup(tmp_bh_dir) - - def run_buildhistory_operation(self, target, global_config='', target_config='', change_bh_location=False, expect_error=False, error_regex=''): - if change_bh_location: - tmp_bh_location = True - else: - tmp_bh_location = False - self.config_buildhistory(tmp_bh_location) - - self.append_config(global_config) - self.append_recipeinc(target, target_config) - bitbake("-cclean %s" % target) - result = bitbake(target, ignore_status=True) - self.remove_config(global_config) - self.remove_recipeinc(target, target_config) - - if expect_error: - self.assertEqual(result.status, 1, msg="Error expected for global config '%s' and target config '%s'" % (global_config, target_config)) - search_for_error = re.search(error_regex, result.output) - self.assertTrue(search_for_error, msg="Could not find desired error in output: %s (%s)" % (error_regex, result.output)) - else: - self.assertEqual(result.status, 0, msg="Command 'bitbake %s' has failed unexpectedly: %s" % (target, result.output)) - - # No tests should be added to the base class. - # Please create a new class that inherit this one, or use one of those already available for adding tests. diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py deleted file mode 100644 index ce37ea457c..0000000000 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ /dev/null @@ -1,184 +0,0 @@ -import os -import re -import glob as g -import shutil -import tempfile -from oeqa.selftest.base import oeSelfTest -from oeqa.selftest.buildhistory import BuildhistoryBase -from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars -import oeqa.utils.ftools as ftools -from oeqa.utils.decorators import testcase - -class ImageOptionsTests(oeSelfTest): - - @testcase(761) - def test_incremental_image_generation(self): - image_pkgtype = get_bb_var("IMAGE_PKGTYPE") - if image_pkgtype != 'rpm': - self.skipTest('Not using RPM as main package format') - bitbake("-c clean core-image-minimal") - self.write_config('INC_RPM_IMAGE_GEN = "1"') - self.append_config('IMAGE_FEATURES += "ssh-server-openssh"') - bitbake("core-image-minimal") - log_data_file = os.path.join(get_bb_var("WORKDIR", "core-image-minimal"), "temp/log.do_rootfs") - log_data_created = ftools.read_file(log_data_file) - incremental_created = re.search(r"Installing\s*:\s*packagegroup-core-ssh-openssh", log_data_created) - self.remove_config('IMAGE_FEATURES += "ssh-server-openssh"') - self.assertTrue(incremental_created, msg = "Match failed in:\n%s" % log_data_created) - bitbake("core-image-minimal") - log_data_removed = ftools.read_file(log_data_file) - incremental_removed = re.search(r"Erasing\s*:\s*packagegroup-core-ssh-openssh", log_data_removed) - self.assertTrue(incremental_removed, msg = "Match failed in:\n%s" % log_data_removed) - - @testcase(286) - def test_ccache_tool(self): - bitbake("ccache-native") - bb_vars = get_bb_vars(['SYSROOT_DESTDIR', 'bindir'], 'ccache-native') - p = bb_vars['SYSROOT_DESTDIR'] + bb_vars['bindir'] + "/" + "ccache" - self.assertTrue(os.path.isfile(p), msg = "No ccache found (%s)" % p) - self.write_config('INHERIT += "ccache"') - self.add_command_to_tearDown('bitbake -c clean m4') - bitbake("m4 -f -c compile") - log_compile = os.path.join(get_bb_var("WORKDIR","m4"), "temp/log.do_compile") - res = runCmd("grep ccache %s" % log_compile, ignore_status=True) - self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile. For further details: %s" % log_compile) - - @testcase(1435) - def test_read_only_image(self): - distro_features = get_bb_var('DISTRO_FEATURES') - if not ('x11' in distro_features and 'opengl' in distro_features): - self.skipTest('core-image-sato requires x11 and opengl in distro features') - self.write_config('IMAGE_FEATURES += "read-only-rootfs"') - bitbake("core-image-sato") - # do_image will fail if there are any pending postinsts - -class DiskMonTest(oeSelfTest): - - @testcase(277) - def test_stoptask_behavior(self): - self.write_config('BB_DISKMON_DIRS = "STOPTASKS,${TMPDIR},100000G,100K"') - res = bitbake("m4", ignore_status = True) - self.assertTrue('ERROR: No new tasks can be executed since the disk space monitor action is "STOPTASKS"!' in res.output, msg = "Tasks should have stopped. Disk monitor is set to STOPTASK: %s" % res.output) - self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output)) - self.write_config('BB_DISKMON_DIRS = "ABORT,${TMPDIR},100000G,100K"') - res = bitbake("m4", ignore_status = True) - self.assertTrue('ERROR: Immediately abort since the disk space monitor action is "ABORT"!' in res.output, "Tasks should have been aborted immediatelly. Disk monitor is set to ABORT: %s" % res.output) - self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output)) - self.write_config('BB_DISKMON_DIRS = "WARN,${TMPDIR},100000G,100K"') - res = bitbake("m4") - self.assertTrue('WARNING: The free space' in res.output, msg = "A warning should have been displayed for disk monitor is set to WARN: %s" %res.output) - -class SanityOptionsTest(oeSelfTest): - def getline(self, res, line): - for l in res.output.split('\n'): - if line in l: - return l - - @testcase(927) - def test_options_warnqa_errorqa_switch(self): - - self.write_config("INHERIT_remove = \"report-error\"") - if "packages-list" not in get_bb_var("ERROR_QA"): - self.append_config("ERROR_QA_append = \" packages-list\"") - - self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') - self.add_command_to_tearDown('bitbake -c clean xcursor-transparent-theme') - res = bitbake("xcursor-transparent-theme -f -c package", ignore_status=True) - self.delete_recipeinc('xcursor-transparent-theme') - line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.") - self.assertTrue(line and line.startswith("ERROR:"), msg=res.output) - self.assertEqual(res.status, 1, msg = "bitbake reported exit code %s. It should have been 1. Bitbake output: %s" % (str(res.status), res.output)) - self.write_recipeinc('xcursor-transparent-theme', 'PACKAGES += \"${PN}-dbg\"') - self.append_config('ERROR_QA_remove = "packages-list"') - self.append_config('WARN_QA_append = " packages-list"') - res = bitbake("xcursor-transparent-theme -f -c package") - self.delete_recipeinc('xcursor-transparent-theme') - line = self.getline(res, "QA Issue: xcursor-transparent-theme-dbg is listed in PACKAGES multiple times, this leads to packaging errors.") - self.assertTrue(line and line.startswith("WARNING:"), msg=res.output) - - @testcase(278) - def test_sanity_unsafe_script_references(self): - self.write_config('WARN_QA_append = " unsafe-references-in-scripts"') - - self.add_command_to_tearDown('bitbake -c clean gzip') - res = bitbake("gzip -f -c package_qa") - line = self.getline(res, "QA Issue: gzip") - self.assertFalse(line, "WARNING: QA Issue: gzip message is present in bitbake's output and shouldn't be: %s" % res.output) - - self.append_config(""" -do_install_append_pn-gzip () { - echo "\n${bindir}/test" >> ${D}${bindir}/zcat -} -""") - res = bitbake("gzip -f -c package_qa") - line = self.getline(res, "QA Issue: gzip") - self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: gzip message is not present in bitbake's output: %s" % res.output) - - @testcase(1421) - def test_layer_without_git_dir(self): - """ - Summary: Test that layer git revisions are displayed and do not fail without git repository - Expected: The build to be successful and without "fatal" errors - Product: oe-core - Author: Daniel Istrate - AutomatedBy: Daniel Istrate - """ - - dirpath = tempfile.mkdtemp() - - dummy_layer_name = 'meta-dummy' - dummy_layer_path = os.path.join(dirpath, dummy_layer_name) - dummy_layer_conf_dir = os.path.join(dummy_layer_path, 'conf') - os.makedirs(dummy_layer_conf_dir) - dummy_layer_conf_path = os.path.join(dummy_layer_conf_dir, 'layer.conf') - - dummy_layer_content = 'BBPATH .= ":${LAYERDIR}"\n' \ - 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' \ - 'BBFILE_COLLECTIONS += "%s"\n' \ - 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' \ - 'BBFILE_PRIORITY_%s = "6"\n' % (dummy_layer_name, dummy_layer_name, dummy_layer_name) - - ftools.write_file(dummy_layer_conf_path, dummy_layer_content) - - bblayers_conf = 'BBLAYERS += "%s"\n' % dummy_layer_path - self.write_bblayers_config(bblayers_conf) - - test_recipe = 'ed' - - ret = bitbake('-n %s' % test_recipe) - - err = 'fatal: Not a git repository' - - shutil.rmtree(dirpath) - - self.assertNotIn(err, ret.output) - - -class BuildhistoryTests(BuildhistoryBase): - - @testcase(293) - def test_buildhistory_basic(self): - self.run_buildhistory_operation('xcursor-transparent-theme') - self.assertTrue(os.path.isdir(get_bb_var('BUILDHISTORY_DIR')), "buildhistory dir was not created.") - - @testcase(294) - def test_buildhistory_buildtime_pr_backwards(self): - target = 'xcursor-transparent-theme' - error = "ERROR:.*QA Issue: Package version for package %s went backwards which would break package feeds from (.*-r1.* to .*-r0.*)" % target - self.run_buildhistory_operation(target, target_config="PR = \"r1\"", change_bh_location=True) - self.run_buildhistory_operation(target, target_config="PR = \"r0\"", change_bh_location=False, expect_error=True, error_regex=error) - -class ArchiverTest(oeSelfTest): - @testcase(926) - def test_arch_work_dir_and_export_source(self): - """ - Test for archiving the work directory and exporting the source files. - """ - self.write_config("INHERIT += \"archiver\"\nARCHIVER_MODE[src] = \"original\"\nARCHIVER_MODE[srpm] = \"1\"") - res = bitbake("xcursor-transparent-theme", ignore_status=True) - self.assertEqual(res.status, 0, "\nCouldn't build xcursortransparenttheme.\nbitbake output %s" % res.output) - deploy_dir_src = get_bb_var('DEPLOY_DIR_SRC') - pkgs_path = g.glob(str(deploy_dir_src) + "/allarch*/xcurs*") - src_file_glob = str(pkgs_path[0]) + "/xcursor*.src.rpm" - tar_file_glob = str(pkgs_path[0]) + "/xcursor*.tar.gz" - self.assertTrue((g.glob(src_file_glob) and g.glob(tar_file_glob)), "Couldn't find .src.rpm and .tar.gz files under %s/allarch*/xcursor*" % deploy_dir_src) diff --git a/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py new file mode 100644 index 0000000000..0e5896234c --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/_sstatetests_noauto.py @@ -0,0 +1,92 @@ +import os +import shutil + +import oeqa.utils.ftools as ftools +from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer +from oeqa.selftest.cases.sstate import SStateBase + + +class RebuildFromSState(SStateBase): + + @classmethod + def setUpClass(self): + super(RebuildFromSState, self).setUpClass() + self.builddir = os.path.join(os.environ.get('BUILDDIR')) + + def get_dep_targets(self, primary_targets): + found_targets = [] + bitbake("-g " + ' '.join(map(str, primary_targets))) + with open(os.path.join(self.builddir, 'pn-buildlist'), 'r') as pnfile: + found_targets = pnfile.read().splitlines() + return found_targets + + def configure_builddir(self, builddir): + os.mkdir(builddir) + self.track_for_cleanup(builddir) + os.mkdir(os.path.join(builddir, 'conf')) + shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/local.conf'), os.path.join(builddir, 'conf/local.conf')) + config = {} + config['default_sstate_dir'] = "SSTATE_DIR ?= \"${TOPDIR}/sstate-cache\"" + config['null_sstate_mirrors'] = "SSTATE_MIRRORS = \"\"" + config['default_tmp_dir'] = "TMPDIR = \"${TOPDIR}/tmp\"" + for key in config: + ftools.append_file(os.path.join(builddir, 'conf/selftest.inc'), config[key]) + shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/bblayers.conf'), os.path.join(builddir, 'conf/bblayers.conf')) + try: + shutil.copyfile(os.path.join(os.environ.get('BUILDDIR'), 'conf/auto.conf'), os.path.join(builddir, 'conf/auto.conf')) + except: + pass + + def hardlink_tree(self, src, dst): + os.mkdir(dst) + self.track_for_cleanup(dst) + for root, dirs, files in os.walk(src): + if root == src: + continue + os.mkdir(os.path.join(dst, root.split(src)[1][1:])) + for sstate_file in files: + os.link(os.path.join(root, sstate_file), os.path.join(dst, root.split(src)[1][1:], sstate_file)) + + def run_test_sstate_rebuild(self, primary_targets, relocate=False, rebuild_dependencies=False): + buildA = os.path.join(self.builddir, 'buildA') + if relocate: + buildB = os.path.join(self.builddir, 'buildB') + else: + buildB = buildA + + if rebuild_dependencies: + rebuild_targets = self.get_dep_targets(primary_targets) + else: + rebuild_targets = primary_targets + + self.configure_builddir(buildA) + runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildA)) + 'bitbake ' + ' '.join(map(str, primary_targets)), shell=True, executable='/bin/bash') + self.hardlink_tree(os.path.join(buildA, 'sstate-cache'), os.path.join(self.builddir, 'sstate-cache-buildA')) + shutil.rmtree(buildA) + + failed_rebuild = [] + failed_cleansstate = [] + for target in rebuild_targets: + self.configure_builddir(buildB) + self.hardlink_tree(os.path.join(self.builddir, 'sstate-cache-buildA'), os.path.join(buildB, 'sstate-cache')) + + result_cleansstate = runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildB)) + 'bitbake -ccleansstate ' + target, ignore_status=True, shell=True, executable='/bin/bash') + if not result_cleansstate.status == 0: + failed_cleansstate.append(target) + shutil.rmtree(buildB) + continue + + result_build = runCmd((". %s/oe-init-build-env %s && " % (get_bb_var('COREBASE'), buildB)) + 'bitbake ' + target, ignore_status=True, shell=True, executable='/bin/bash') + if not result_build.status == 0: + failed_rebuild.append(target) + + shutil.rmtree(buildB) + + self.assertFalse(failed_rebuild, msg="The following recipes have failed to rebuild: %s" % ' '.join(map(str, failed_rebuild))) + self.assertFalse(failed_cleansstate, msg="The following recipes have failed cleansstate(all others have passed both cleansstate and rebuild from sstate tests): %s" % ' '.join(map(str, failed_cleansstate))) + + def test_sstate_relocation(self): + self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=True, rebuild_dependencies=True) + + def test_sstate_rebuild(self): + self.run_test_sstate_rebuild(['core-image-sato-sdk'], relocate=False, rebuild_dependencies=True) diff --git a/meta/lib/oeqa/selftest/cases/archiver.py b/meta/lib/oeqa/selftest/cases/archiver.py new file mode 100644 index 0000000000..70c7282f22 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/archiver.py @@ -0,0 +1,41 @@ +import os +import glob +from oeqa.utils.commands import bitbake, get_bb_vars +from oeqa.selftest.case import OESelftestTestCase +from oeqa.core.decorator.oeid import OETestID + +class Archiver(OESelftestTestCase): + + @OETestID(1345) + def test_archiver_allows_to_filter_on_recipe_name(self): + """ + Summary: The archiver should offer the possibility to filter on the recipe. (#6929) + Expected: 1. Included recipe (busybox) should be included + 2. Excluded recipe (zlib) should be excluded + Product: oe-core + Author: Daniel Istrate + AutomatedBy: Daniel Istrate + """ + + include_recipe = 'busybox' + exclude_recipe = 'zlib' + + features = 'INHERIT += "archiver"\n' + features += 'ARCHIVER_MODE[src] = "original"\n' + features += 'COPYLEFT_PN_INCLUDE = "%s"\n' % include_recipe + features += 'COPYLEFT_PN_EXCLUDE = "%s"\n' % exclude_recipe + self.write_config(features) + + bitbake('-c clean %s %s' % (include_recipe, exclude_recipe)) + bitbake("%s %s" % (include_recipe, exclude_recipe)) + + bb_vars = get_bb_vars(['DEPLOY_DIR_SRC', 'TARGET_SYS']) + src_path = os.path.join(bb_vars['DEPLOY_DIR_SRC'], bb_vars['TARGET_SYS']) + + # Check that include_recipe was included + included_present = len(glob.glob(src_path + '/%s-*' % include_recipe)) + self.assertTrue(included_present, 'Recipe %s was not included.' % include_recipe) + + # Check that exclude_recipe was excluded + excluded_present = len(glob.glob(src_path + '/%s-*' % exclude_recipe)) + self.assertFalse(excluded_present, 'Recipe %s was not excluded.' % exclude_recipe) diff --git a/meta/lib/oeqa/selftest/cases/bblayers.py b/meta/lib/oeqa/selftest/cases/bblayers.py new file mode 100644 index 0000000000..90a2249b08 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/bblayers.py @@ -0,0 +1,97 @@ +import os +import re + +import oeqa.utils.ftools as ftools +from oeqa.utils.commands import runCmd, get_bb_var + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.core.decorator.oeid import OETestID + +class BitbakeLayers(OESelftestTestCase): + + @OETestID(756) + def test_bitbakelayers_showcrossdepends(self): + result = runCmd('bitbake-layers show-cross-depends') + self.assertTrue('aspell' in result.output, msg = "No dependencies were shown. bitbake-layers show-cross-depends output: %s" % result.output) + + @OETestID(83) + def test_bitbakelayers_showlayers(self): + result = runCmd('bitbake-layers show-layers') + self.assertTrue('meta-selftest' in result.output, msg = "No layers were shown. bitbake-layers show-layers output: %s" % result.output) + + @OETestID(93) + def test_bitbakelayers_showappends(self): + recipe = "xcursor-transparent-theme" + bb_file = self.get_recipe_basename(recipe) + result = runCmd('bitbake-layers show-appends') + self.assertTrue(bb_file in result.output, msg="%s file was not recognised. bitbake-layers show-appends output: %s" % (bb_file, result.output)) + + @OETestID(90) + def test_bitbakelayers_showoverlayed(self): + result = runCmd('bitbake-layers show-overlayed') + self.assertTrue('aspell' in result.output, msg="aspell overlayed recipe was not recognised bitbake-layers show-overlayed %s" % result.output) + + @OETestID(95) + def test_bitbakelayers_flatten(self): + recipe = "xcursor-transparent-theme" + recipe_path = "recipes-graphics/xcursor-transparent-theme" + recipe_file = self.get_recipe_basename(recipe) + testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') + self.assertFalse(os.path.isdir(testoutdir), msg = "test_bitbakelayers_flatten should not exist at this point in time") + self.track_for_cleanup(testoutdir) + result = runCmd('bitbake-layers flatten %s' % testoutdir) + bb_file = os.path.join(testoutdir, recipe_path, recipe_file) + self.assertTrue(os.path.isfile(bb_file), msg = "Cannot find xcursor-transparent-theme_0.1.1.bb in the test_bitbakelayers_flatten local dir.") + contents = ftools.read_file(bb_file) + find_in_contents = re.search("##### bbappended from meta-selftest #####\n(.*\n)*include test_recipe.inc", contents) + self.assertTrue(find_in_contents, msg = "Flattening layers did not work. bitbake-layers flatten output: %s" % result.output) + + @OETestID(1195) + def test_bitbakelayers_add_remove(self): + test_layer = os.path.join(get_bb_var('COREBASE'), 'meta-skeleton') + result = runCmd('bitbake-layers show-layers') + self.assertNotIn('meta-skeleton', result.output, "This test cannot run with meta-skeleton in bblayers.conf. bitbake-layers show-layers output: %s" % result.output) + result = runCmd('bitbake-layers add-layer %s' % test_layer) + result = runCmd('bitbake-layers show-layers') + self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf. bitbake-layers show-layers output: %s" % result.output) + result = runCmd('bitbake-layers remove-layer %s' % test_layer) + result = runCmd('bitbake-layers show-layers') + self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step. bitbake-layers show-layers output: %s" % result.output) + result = runCmd('bitbake-layers add-layer %s' % test_layer) + result = runCmd('bitbake-layers show-layers') + self.assertIn('meta-skeleton', result.output, msg = "Something wrong happened. meta-skeleton layer was not added to conf/bblayers.conf. bitbake-layers show-layers output: %s" % result.output) + result = runCmd('bitbake-layers remove-layer */meta-skeleton') + result = runCmd('bitbake-layers show-layers') + self.assertNotIn('meta-skeleton', result.output, msg = "meta-skeleton should have been removed at this step. bitbake-layers show-layers output: %s" % result.output) + + @OETestID(1384) + def test_bitbakelayers_showrecipes(self): + result = runCmd('bitbake-layers show-recipes') + self.assertIn('aspell:', result.output) + self.assertIn('mtd-utils:', result.output) + self.assertIn('core-image-minimal:', result.output) + result = runCmd('bitbake-layers show-recipes mtd-utils') + self.assertIn('mtd-utils:', result.output) + self.assertNotIn('aspell:', result.output) + result = runCmd('bitbake-layers show-recipes -i image') + self.assertIn('core-image-minimal', result.output) + self.assertNotIn('mtd-utils:', result.output) + result = runCmd('bitbake-layers show-recipes -i cmake,pkgconfig') + self.assertIn('libproxy:', result.output) + self.assertNotIn('mtd-utils:', result.output) # doesn't inherit either + self.assertNotIn('wget:', result.output) # doesn't inherit cmake + self.assertNotIn('waffle:', result.output) # doesn't inherit pkgconfig + result = runCmd('bitbake-layers show-recipes -i nonexistentclass', ignore_status=True) + self.assertNotEqual(result.status, 0, 'bitbake-layers show-recipes -i nonexistentclass should have failed') + self.assertIn('ERROR:', result.output) + + def get_recipe_basename(self, recipe): + recipe_file = "" + result = runCmd("bitbake-layers show-recipes -f %s" % recipe) + for line in result.output.splitlines(): + if recipe in line: + recipe_file = line + break + + self.assertTrue(os.path.isfile(recipe_file), msg = "Can't find recipe file for %s" % recipe) + return os.path.basename(recipe_file) diff --git a/meta/lib/oeqa/selftest/cases/bbtests.py b/meta/lib/oeqa/selftest/cases/bbtests.py new file mode 100644 index 0000000000..4c82049032 --- /dev/null +++ b/meta/lib/oeqa/selftest/cases/bbtests.py @@ -0,0 +1,279 @@ +import os +import re + +import oeqa.utils.ftools as ftools +from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_bb_vars + +from oeqa.selftest.case import OESelftestTestCase +from oeqa.core.decorator.oeid import OETestID + +class BitbakeTests(OESelftestTestCase): + + def getline(self, res, line): + for l in res.output.split('\n'): + if line in l: + return l + + @OETestID(789) + def test_run_bitbake_from_dir_1(self): + os.chdir(os.path.join(self.builddir, 'conf')) + self.assertEqual(bitbake('-e').status, 0, msg = "bitbake couldn't run from \"conf\" dir") + + @OETestID(790) + 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'])) + self.assertEqual(bitbake('-e', env=my_env).status, 0, msg = "bitbake couldn't run from builddir") + + @OETestID(806) + 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: Executing RunQueue Tasks", 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 resu