[OE-core] [PATCH 1/2] oeqa/selftest: Added 3 new selftest testcases.
Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/imagefeatures.py | 206 1 file changed, 206 insertions(+) create mode 100644 meta/lib/oeqa/selftest/imagefeatures.py diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py new file mode 100644 index 000..f697956 --- /dev/null +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -0,0 +1,206 @@ +from oeqa.selftest.base import oeSelfTest +from oeqa.utils.commands import runCmd, bitbake +from oeqa.utils.decorators import testcase +import pexpect +from os.path import expanduser +from os import system + +class ImageFeatures(oeSelfTest): + +@testcase(1107) +def test_non_root_user_can_connect_via_ssh_without_password(self): +""" +Summary: Check if non root user can connect via ssh without password +Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed. + 2. Connection to the image via ssh using tester user without providing a password should be allowed. +Product: oe-core +Author: Ionut Chisanovici + AutomatedBy: Daniel Istrate +""" + +test_user = 'tester' +root_user = 'root' +prompt = r'qemux86:\S+[$#]\s+' +tap_inf_ip = '192.168.7.2' + +features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh empty-root-password"\n' +features += 'INHERIT += "extrausers"\n' +features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user) + +# Append 'features' to local.conf +self.append_config(features) + +# Build a core-image-minimal +ret = bitbake('core-image-minimal') +self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal') + +rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip) +# Delete the ssh keys for 192.168.7.2 (qemu) +ret = runCmd(rm_ssh_keys_cmd) +self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.') + +# Boot qemu image +proc_qemu = pexpect.spawn('runqemu qemux86 nographic') +try: +proc_qemu.expect('qemux86 login:', timeout=100) +except: +system('pkill qemu') +proc_qemu.close() +self.fail('Failed to start qemu.') + +# Attempt to ssh with each user into qemu with empty password +for user in [root_user, test_user]: +proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user)) +index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF]) +if index == 0: +proc_ssh.sendline('yes') +try: +proc_ssh.expect(prompt) +except: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu.'.format(user)) +elif index == 1: +# user successfully logged in with empty password +pass +elif index == 2: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user)) +else: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu (eof).'.format(user)) + +# Cleanup +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +ret = runCmd(rm_ssh_keys_cmd) +self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host (at cleanup).') + +@testcase(1115) +def test_all_users_can_connect_via_ssh_without_password(self): +""" +Summary: Check if all users can connect via ssh without password +Expected:1. Connection to the image via ssh using root or tester user without providing a password should be allowed. +Product: oe-core +Author: Ionut Chisanovici +AutomatedBy: Daniel Istrate +""" +test_user = 'tester' +root_user = 'root' +prompt = r'qemux86:\S+[$#]\s+' +tap_inf_ip = '192.168.7.2' + +features = 'EXTRA_IMAG
[OE-core] [PATCH 2/2] oeqa/utils: Minor documentation update to ftools methods.
Signed-off-by: Daniel Istrate --- meta/lib/oeqa/utils/ftools.py | 4 1 file changed, 4 insertions(+) diff --git a/meta/lib/oeqa/utils/ftools.py b/meta/lib/oeqa/utils/ftools.py index 64ebe3d..e396591 100644 --- a/meta/lib/oeqa/utils/ftools.py +++ b/meta/lib/oeqa/utils/ftools.py @@ -1,22 +1,26 @@ import os import re +# Replaces file (path) content with 'data' def write_file(path, data): wdata = data.rstrip() + "\n" with open(path, "w") as f: f.write(wdata) +# Append 'data' to a specified file (path) def append_file(path, data): wdata = data.rstrip() + "\n" with open(path, "a") as f: f.write(wdata) +# Returns the content of the specified file (path) def read_file(path): data = None with open(path) as f: data = f.read() return data +# Removes 'data' from a specified file (path) def remove_from_file(path, data): lines = read_file(path).splitlines() rmdata = data.strip().splitlines() -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 2/3] Added methods for manipulating bblayer.conf file in the same manner as local.conf file: - write_bblayers_config - append_bblayers_config - remove_bblayers_config
--- meta/lib/oeqa/selftest/base.py | 22 ++ scripts/oe-selftest| 16 +++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 80b9b4b..b2faa66 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py @@ -27,6 +27,8 @@ class oeSelfTest(unittest.TestCase): self.builddir = os.environ.get("BUILDDIR") self.localconf_path = os.path.join(self.builddir, "conf/local.conf") self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") +self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") +self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") self.testlayer_path = oeSelfTest.testlayer_path self._extra_tear_down_commands = [] self._track_for_cleanup = [] @@ -45,6 +47,11 @@ class oeSelfTest(unittest.TestCase): for f in files: if f == 'test_recipe.inc': os.remove(os.path.join(root, f)) +try: +os.remove(self.testinc_bblayers_path) +except OSError as e: +if e.errno != errno.ENOENT: +raise # tests might need their own setup # but if they overwrite this one they have to call # super each time, so let's give them an alternative @@ -129,3 +136,18 @@ class oeSelfTest(unittest.TestCase): except OSError as e: if e.errno != errno.ENOENT: raise + +# write to /conf/bblayers.inc +def write_bblayers_config(self, data): +self.log.debug("Writing to: %s\n%s\n" % (self.testinc_bblayers_path, data)) +ftools.write_file(self.testinc_bblayers_path, data) + +# append to /conf/bblayers.inc +def append_bblayers_config(self, data): +self.log.debug("Appending to: %s\n%s\n" % (self.testinc_bblayers_path, data)) +ftools.append_file(self.testinc_bblayers_path, data) + +# remove data from /conf/bblayers.inc +def remove_bblayers_config(self, data): +self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data)) +ftools.remove_from_file(self.testinc_bblayers_path, data) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index a04e9fc..049a94e 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -100,6 +100,11 @@ def add_include(): ftools.append_file(os.path.join(builddir, "conf/local.conf"), \ "\n#include added by oe-selftest.py\ninclude selftest.inc") +if "#include added by oe-selftest.py" \ +not in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): +log.info("Adding: \"include bblayers.inc\" in bblayers.conf") +ftools.append_file(os.path.join(builddir, "conf/bblayers.conf"), \ +"\n#include added by oe-selftest.py\ninclude bblayers.inc") def remove_include(): builddir = os.environ.get("BUILDDIR") @@ -111,6 +116,11 @@ def remove_include(): ftools.remove_from_file(os.path.join(builddir, "conf/local.conf"), \ "#include added by oe-selftest.py\ninclude selftest.inc") +if "#include added by oe-selftest.py" \ +in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): +log.info("Removing the include from bblayers.conf") +ftools.remove_from_file(os.path.join(builddir, "conf/bblayers.conf"), \ +"#include added by oe-selftest.py\ninclude bblayers.inc") def remove_inc_files(): try: @@ -122,6 +132,11 @@ def remove_inc_files(): except (AttributeError, OSError,) as e:# AttributeError may happen if BUILDDIR is not set pass +try: +os.remove(os.path.join(os.environ.get("BUILDDIR"), "conf/bblayers.inc")) +except: +pass + def get_tests(exclusive_modules=[], include_hidden=False): testslist = [] for x in exclusive_modules: @@ -167,7 +182,6 @@ def main(): print e pass - if args.run_tests or args.run_all_tests: if not preflight_check(): return 1 -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 1/3] Added 'testcase' decorator to oe-selftest test cases missing this feature.
--- meta/lib/oeqa/selftest/bblayers.py | 1 + meta/lib/oeqa/selftest/devtool.py | 16 meta/lib/oeqa/selftest/layerappend.py | 1 + meta/lib/oeqa/selftest/lic-checksum.py | 2 ++ meta/lib/oeqa/selftest/pkgdata.py | 8 meta/lib/oeqa/selftest/recipetool.py | 25 ++--- meta/lib/oeqa/selftest/wic.py | 7 +++ 7 files changed, 57 insertions(+), 3 deletions(-) diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py index 3a18029..bf3dd1b 100644 --- a/meta/lib/oeqa/selftest/bblayers.py +++ b/meta/lib/oeqa/selftest/bblayers.py @@ -43,6 +43,7 @@ class BitbakeLayers(oeSelfTest): find_in_contents = re.search("# bbappended from meta-selftest #\n(.*\n)*include test_recipe.inc", contents) self.assertTrue(find_in_contents) +@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') diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index c4a0399..5dc0947 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -84,6 +84,7 @@ class DevtoolBase(oeSelfTest): class DevtoolTests(DevtoolBase): +@testcase(1158) def test_create_workspace(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -106,6 +107,7 @@ class DevtoolTests(DevtoolBase): self.assertNotIn(tempdir, result.output) self.assertIn(workspacedir, result.output) +@testcase(1159) def test_devtool_add(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -140,6 +142,7 @@ class DevtoolTests(DevtoolBase): bindir = bindir[1:] self.assertTrue(os.path.isfile(os.path.join(installdir, bindir, 'pv')), 'pv binary not found in D') +@testcase(1162) def test_devtool_add_library(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -180,6 +183,7 @@ class DevtoolTests(DevtoolBase): self.assertFalse(matches, 'Stamp files exist for recipe libftdi that should have been cleaned') self.assertFalse(os.path.isfile(os.path.join(staging_libdir, 'libftdi1.so.2.1.0')), 'libftdi binary still found in STAGING_LIBDIR after cleaning') +@testcase(1160) def test_devtool_add_fetch(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -226,6 +230,7 @@ class DevtoolTests(DevtoolBase): checkvars['SRC_URI'] = url.replace(testver, '${PV}') self._test_recipe_contents(recipefile, checkvars, []) +@testcase(1161) def test_devtool_add_fetch_git(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -277,6 +282,7 @@ class DevtoolTests(DevtoolBase): checkvars['SRCREV'] = checkrev self._test_recipe_contents(recipefile, checkvars, []) +@testcase(1164) def test_devtool_modify(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -328,6 +334,7 @@ class DevtoolTests(DevtoolBase): matches = glob.glob(stampprefix + '*') self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned') +@testcase(1166) def test_devtool_modify_invalid(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -360,6 +367,7 @@ class DevtoolTests(DevtoolBase): self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed' % testrecipe) self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe) +@testcase(1165) def test_devtool_modify_git(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -393,6 +401,7 @@ class DevtoolTests(DevtoolBase): # Try building bitbake(testrecipe) +@testcase(1167) def test_devtool_modify_localfiles(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -425,6 +434,7 @@ class DevtoolTests(DevtoolBase): # Try building bitbake(testrecipe) +@testcase(1169) def test_devtool_update_recipe(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -471,6 +481,7 @@ class DevtoolTests(DevtoolBase): else: raise AssertionError('Unexpected modified file in status: %s' % line) +@testcase(1172) def test_devtool_update_recipe_git(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -545,6 +556,7 @@ class DevtoolTests(Devtool
[OE-core] [PATCH 3/3] Automated 5 oe-selftest testcase: - 1107: Check if non root user can connect via ssh without password - 1115: Check if all users can connect via ssh without password - 1114: Chec
--- meta/lib/oeqa/selftest/imagefeatures.py | 282 1 file changed, 282 insertions(+) create mode 100644 meta/lib/oeqa/selftest/imagefeatures.py diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py new file mode 100644 index 000..e49f498 --- /dev/null +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -0,0 +1,282 @@ +from oeqa.selftest.base import oeSelfTest +from oeqa.utils.commands import runCmd, bitbake, get_bb_var +from oeqa.utils.decorators import testcase +import pexpect +from os.path import expanduser, isfile +from os import system +import glob + + +class ImageFeatures(oeSelfTest): + +@testcase(1107) +def test_non_root_user_can_connect_via_ssh_without_password(self): +""" +Summary: Check if non root user can connect via ssh without password +Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed. + 2. Connection to the image via ssh using tester user without providing a password should be allowed. +Product: oe-core +Author: Ionut Chisanovici + AutomatedBy: Daniel Istrate +""" + +test_user = 'tester' +root_user = 'root' +prompt = r'qemux86:\S+[$#]\s+' +tap_inf_ip = '192.168.7.2' + +features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh empty-root-password"\n' +features += 'INHERIT += "extrausers"\n' +features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user) + +# Append 'features' to local.conf +self.append_config(features) + +# Build a core-image-minimal +ret = bitbake('core-image-minimal') +self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal') + +rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip) +# Delete the ssh keys for 192.168.7.2 (qemu) +ret = runCmd(rm_ssh_keys_cmd) +self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.') + +# Boot qemu image +proc_qemu = pexpect.spawn('runqemu qemux86 nographic') +try: +proc_qemu.expect('qemux86 login:', timeout=100) +except: +system('pkill qemu') +proc_qemu.close() +self.fail('Failed to start qemu.') + +# Attempt to ssh with each user into qemu with empty password +for user in [root_user, test_user]: +proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user)) +index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF]) +if index == 0: +proc_ssh.sendline('yes') +try: +proc_ssh.expect(prompt) +except: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu.'.format(user)) +elif index == 1: +# user successfully logged in with empty password +pass +elif index == 2: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user)) +else: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu (eof).'.format(user)) + +# Cleanup +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +ret = runCmd(rm_ssh_keys_cmd) +self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host (at cleanup).') + +@testcase(1115) +def test_all_users_can_connect_via_ssh_without_password(self): +""" +Summary: Check if all users can connect via ssh without password +Expected:1. Connection to the image via ssh using root or tester user without providing a password should be allowed. +Product: oe-core +Author: Ionut Chisanovici +AutomatedBy: Daniel Istrate +""" +test_user = 'tester' +root_user = 'root' +prompt = r'qemux86:\S+[$#]\s+' +tap_inf_ip = '192.168.7.2' + +features = 'EXTRA_IMAG
[OE-core] [PATCH] oeqa/selftest: Add methods to manipulate bblayers.conf in base.py
Added methods for manipulating bblayers.conf file in the same manner as local.conf file: - write_bblayers_config - append_bblayers_config - remove_bblayers_config Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/base.py | 22 ++ 1 file changed, 22 insertions(+) diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 80b9b4b..b2faa66 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py @@ -27,6 +27,8 @@ class oeSelfTest(unittest.TestCase): self.builddir = os.environ.get("BUILDDIR") self.localconf_path = os.path.join(self.builddir, "conf/local.conf") self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") +self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") +self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") self.testlayer_path = oeSelfTest.testlayer_path self._extra_tear_down_commands = [] self._track_for_cleanup = [] @@ -45,6 +47,11 @@ class oeSelfTest(unittest.TestCase): for f in files: if f == 'test_recipe.inc': os.remove(os.path.join(root, f)) +try: +os.remove(self.testinc_bblayers_path) +except OSError as e: +if e.errno != errno.ENOENT: +raise # tests might need their own setup # but if they overwrite this one they have to call # super each time, so let's give them an alternative @@ -129,3 +136,18 @@ class oeSelfTest(unittest.TestCase): except OSError as e: if e.errno != errno.ENOENT: raise + +# write to /conf/bblayers.inc +def write_bblayers_config(self, data): +self.log.debug("Writing to: %s\n%s\n" % (self.testinc_bblayers_path, data)) +ftools.write_file(self.testinc_bblayers_path, data) + +# append to /conf/bblayers.inc +def append_bblayers_config(self, data): +self.log.debug("Appending to: %s\n%s\n" % (self.testinc_bblayers_path, data)) +ftools.append_file(self.testinc_bblayers_path, data) + +# remove data from /conf/bblayers.inc +def remove_bblayers_config(self, data): +self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data)) +ftools.remove_from_file(self.testinc_bblayers_path, data) -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest: Added new testsuite for image features.
Automated 5 oe-selftest testcase: - 1107: Check if non root user can connect via ssh without password - 1115: Check if all users can connect via ssh without password - 1114: Check rpm version 4 support on image - 1101: Check if efi/gummiboot images can be buit - 1103: Check that wic command can create efi/gummiboot installation images Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/imagefeatures.py | 282 1 file changed, 282 insertions(+) create mode 100644 meta/lib/oeqa/selftest/imagefeatures.py diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py new file mode 100644 index 000..e49f498 --- /dev/null +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -0,0 +1,282 @@ +from oeqa.selftest.base import oeSelfTest +from oeqa.utils.commands import runCmd, bitbake, get_bb_var +from oeqa.utils.decorators import testcase +import pexpect +from os.path import expanduser, isfile +from os import system +import glob + + +class ImageFeatures(oeSelfTest): + +@testcase(1107) +def test_non_root_user_can_connect_via_ssh_without_password(self): +""" +Summary: Check if non root user can connect via ssh without password +Expected: 1. Connection to the image via ssh using root user without providing a password should be allowed. + 2. Connection to the image via ssh using tester user without providing a password should be allowed. +Product: oe-core +Author: Ionut Chisanovici + AutomatedBy: Daniel Istrate +""" + +test_user = 'tester' +root_user = 'root' +prompt = r'qemux86:\S+[$#]\s+' +tap_inf_ip = '192.168.7.2' + +features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh empty-root-password"\n' +features += 'INHERIT += "extrausers"\n' +features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user) + +# Append 'features' to local.conf +self.append_config(features) + +# Build a core-image-minimal +ret = bitbake('core-image-minimal') +self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal') + +rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip) +# Delete the ssh keys for 192.168.7.2 (qemu) +ret = runCmd(rm_ssh_keys_cmd) +self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.') + +# Boot qemu image +proc_qemu = pexpect.spawn('runqemu qemux86 nographic') +try: +proc_qemu.expect('qemux86 login:', timeout=100) +except: +system('pkill qemu') +proc_qemu.close() +self.fail('Failed to start qemu.') + +# Attempt to ssh with each user into qemu with empty password +for user in [root_user, test_user]: +proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user)) +index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF]) +if index == 0: +proc_ssh.sendline('yes') +try: +proc_ssh.expect(prompt) +except: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu.'.format(user)) +elif index == 1: +# user successfully logged in with empty password +pass +elif index == 2: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user)) +else: +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +self.fail('Failed to ssh with {} user into qemu (eof).'.format(user)) + +# Cleanup +system('pkill qemu') +proc_qemu.close() +proc_ssh.terminate() +ret = runCmd(rm_ssh_keys_cmd) +self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host (at cleanup).') + +@testcase(1115) +def test_all_users_can_connect_via_ssh_without_password(self): +""" +Summary: Check if all users can connect via ssh without password +Expected:1. Connection to the image via ssh using root or tester user without
[OE-core] [PATCH] oeqa/selftest: Added @testcase decorators to oeselftest testcases.
Added decorator to some testcases missing this feature. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/bblayers.py | 1 + meta/lib/oeqa/selftest/devtool.py | 15 +++ meta/lib/oeqa/selftest/layerappend.py | 1 + meta/lib/oeqa/selftest/lic-checksum.py | 2 ++ meta/lib/oeqa/selftest/pkgdata.py | 8 meta/lib/oeqa/selftest/recipetool.py | 25 ++--- 6 files changed, 49 insertions(+), 3 deletions(-) diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py index 3a18029..bf3dd1b 100644 --- a/meta/lib/oeqa/selftest/bblayers.py +++ b/meta/lib/oeqa/selftest/bblayers.py @@ -43,6 +43,7 @@ class BitbakeLayers(oeSelfTest): find_in_contents = re.search("# bbappended from meta-selftest #\n(.*\n)*include test_recipe.inc", contents) self.assertTrue(find_in_contents) +@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') diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index c4a0399..ab412b6 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -84,6 +84,7 @@ class DevtoolBase(oeSelfTest): class DevtoolTests(DevtoolBase): +@testcase(1158) def test_create_workspace(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -106,6 +107,7 @@ class DevtoolTests(DevtoolBase): self.assertNotIn(tempdir, result.output) self.assertIn(workspacedir, result.output) +@testcase(1159) def test_devtool_add(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -140,6 +142,7 @@ class DevtoolTests(DevtoolBase): bindir = bindir[1:] self.assertTrue(os.path.isfile(os.path.join(installdir, bindir, 'pv')), 'pv binary not found in D') +@testcase(1162) def test_devtool_add_library(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -180,6 +183,7 @@ class DevtoolTests(DevtoolBase): self.assertFalse(matches, 'Stamp files exist for recipe libftdi that should have been cleaned') self.assertFalse(os.path.isfile(os.path.join(staging_libdir, 'libftdi1.so.2.1.0')), 'libftdi binary still found in STAGING_LIBDIR after cleaning') +@testcase(1160) def test_devtool_add_fetch(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -226,6 +230,7 @@ class DevtoolTests(DevtoolBase): checkvars['SRC_URI'] = url.replace(testver, '${PV}') self._test_recipe_contents(recipefile, checkvars, []) +@testcase(1161) def test_devtool_add_fetch_git(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -277,6 +282,7 @@ class DevtoolTests(DevtoolBase): checkvars['SRCREV'] = checkrev self._test_recipe_contents(recipefile, checkvars, []) +@testcase(1164) def test_devtool_modify(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -328,6 +334,7 @@ class DevtoolTests(DevtoolBase): matches = glob.glob(stampprefix + '*') self.assertFalse(matches, 'Stamp files exist for recipe mdadm that should have been cleaned') +@testcase(1166) def test_devtool_modify_invalid(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -360,6 +367,7 @@ class DevtoolTests(DevtoolBase): self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed' % testrecipe) self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe) +@testcase(1165) def test_devtool_modify_git(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -393,6 +401,7 @@ class DevtoolTests(DevtoolBase): # Try building bitbake(testrecipe) +@testcase(1167) def test_devtool_modify_localfiles(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -425,6 +434,7 @@ class DevtoolTests(DevtoolBase): # Try building bitbake(testrecipe) +@testcase(1169) def test_devtool_update_recipe(self): # Check preconditions workspacedir = os.path.join(self.builddir, 'workspace') @@ -471,6 +481,7 @@ class DevtoolTests(DevtoolBase):
[OE-core] [PATCH] scripts/oe-selftest: Added mechanism for including/removing bblayers.inc
When oe-selftest starts it includes bblayers.inc into bblayers.conf When oe-selftest ends it deletes bblayers.inc and the included line from bblayers.conf Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 16 +++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index fd58a66..fa6245a 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -100,6 +100,11 @@ def add_include(): ftools.append_file(os.path.join(builddir, "conf/local.conf"), \ "\n#include added by oe-selftest.py\ninclude selftest.inc") +if "#include added by oe-selftest.py" \ +not in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): +log.info("Adding: \"include bblayers.inc\" in bblayers.conf") +ftools.append_file(os.path.join(builddir, "conf/bblayers.conf"), \ +"\n#include added by oe-selftest.py\ninclude bblayers.inc") def remove_include(): builddir = os.environ.get("BUILDDIR") @@ -111,6 +116,11 @@ def remove_include(): ftools.remove_from_file(os.path.join(builddir, "conf/local.conf"), \ "#include added by oe-selftest.py\ninclude selftest.inc") +if "#include added by oe-selftest.py" \ +in ftools.read_file(os.path.join(builddir, "conf/bblayers.conf")): +log.info("Removing the include from bblayers.conf") +ftools.remove_from_file(os.path.join(builddir, "conf/bblayers.conf"), \ +"#include added by oe-selftest.py\ninclude bblayers.inc") def remove_inc_files(): try: @@ -122,6 +132,11 @@ def remove_inc_files(): except (AttributeError, OSError,) as e:# AttributeError may happen if BUILDDIR is not set pass +try: +os.remove(os.path.join(os.environ.get("BUILDDIR"), "conf/bblayers.inc")) +except: +pass + def get_tests(exclusive_modules=[], include_hidden=False): testslist = [] for x in exclusive_modules: @@ -167,7 +182,6 @@ def main(): print e pass - if args.run_tests or args.run_all_tests: if not preflight_check(): return 1 -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest: Added 2 testcases and updated setup for other two in imagefeatures.
Automated 2 oe-selftest testcases: - 1116: Check if clutter image can be built - 1117: Check Wayland support in image Updated setup for test_efi_gummiboot_images_can_be_build and test_wic_command_can_create_efi_gummiboot_installation_images to accomodate latest wic changes. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/imagefeatures.py | 41 +++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py index e49f498..e0e424d 100644 --- a/meta/lib/oeqa/selftest/imagefeatures.py +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -207,6 +207,41 @@ class ImageFeatures(oeSelfTest): system('pkill qemu') proc_qemu.close() +@testcase(1116) +def test_clutter_image_can_be_built(self): +""" +Summary: Check if clutter image can be built +Expected:1. core-image-clutter can be built +Product: oe-core +Author: Ionut Chisanovici + AutomatedBy: Daniel Istrate +""" + +# Build a core-image-clutter +ret = bitbake('core-image-clutter') +self.assertEqual(0, ret.status, 'Failed to build core-image-clutter') + +@testcase(1117) +def test_wayland_support_in_image(self): +""" +Summary: Check Wayland support in image +Expected:1. Wayland image can be build + 2. Wayland feature can be installed +Product: oe-core + Author: Ionut Chisanovici +AutomatedBy: Daniel Istrate +""" + +features = 'DISTRO_FEATURES_append = " wayland"\n' +features += 'CORE_IMAGE_EXTRA_INSTALL += "wayland weston"' + +# Append 'features' to local.conf +self.append_config(features) + +# Build a core-image-weston +ret = bitbake('core-image-weston') +self.assertEqual(0, ret.status, 'Failed to build a core-image-weston') + class Gummiboot(oeSelfTest): @@ -240,8 +275,10 @@ class Gummiboot(oeSelfTest): features += 'MACHINE = "nuc"' self.append_config(features) -# Run "bitbake core-image-minimal" to build a nuc efi/gummiboot image -ret = bitbake('core-image-minimal') +# Run "bitbake syslinux syslinux-native parted-native dosfstools-native mtools-native core-image-minimal " +# to build a nuc/efi gummiboot image + +ret = bitbake('syslinux syslinux-native parted-native dosfstools-native mtools-native core-image-minimal') self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal') @testcase(1101) -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/runtime: Added 4 new runtime test cases
bash:(240) check bash in image connman: (223) Only one connmand in background (963) test connmand file rpm: (195) Check rpm install/removal log file size Signed-off-by: Daniel Istrate --- meta/lib/oeqa/runtime/bash.py| 23 +++ meta/lib/oeqa/runtime/connman.py | 40 meta/lib/oeqa/runtime/rpm.py | 37 + 3 files changed, 100 insertions(+) create mode 100644 meta/lib/oeqa/runtime/bash.py diff --git a/meta/lib/oeqa/runtime/bash.py b/meta/lib/oeqa/runtime/bash.py new file mode 100644 index 000..2a261a3 --- /dev/null +++ b/meta/lib/oeqa/runtime/bash.py @@ -0,0 +1,23 @@ +from oeqa.oetest import oeRuntimeTest +from oeqa.utils.decorators import * + + +class BashTest(oeRuntimeTest): + +@testcase(240) +@skipUnlessPassed("test_ssh") +def test_check_bash_in_image(self): +""" +Summary: check bash in image +Expected:bash command should exist in image +Product: BSPs +Author: Alexandru Georgescu + AutomatedBy: Daniel Istrate +""" + +cmd = 'which bash' +expected_ret = '/bin/bash' + +(status, output) = self.target.run(cmd) +self.assertEqual(0, status, 'Failed to send cmd "{}"'.format(cmd)) +self.assertEqual(str(output), expected_ret, 'Found "{}", instead of "{}"'.format(output, expected_ret)) diff --git a/meta/lib/oeqa/runtime/connman.py b/meta/lib/oeqa/runtime/connman.py index cc537f7..70ead4e 100644 --- a/meta/lib/oeqa/runtime/connman.py +++ b/meta/lib/oeqa/runtime/connman.py @@ -28,3 +28,43 @@ class ConnmanTest(oeRuntimeTest): if status != 0: print self.service_status("connman") self.fail("No connmand process running") + +@testcase(223) +def test_only_one_connmand_in_background(self): +""" +Summary: Only one connmand in background +Expected:There will be only one connmand instance in background. +Product: BSPs +Author: Alexandru Georgescu +AutomatedBy: Daniel Istrate +""" + +# Make sure that 'connmand' is running in background +(status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand') +self.assertEqual(0, status, 'Failed to find "connmand" process running in background.') + +# Start a new instance of 'connmand' +(status, output) = self.target.run('connmand') +self.assertEqual(0, status, 'Failed to start a new "connmand" process.') + +# Make sure that only one 'connmand' is running in background +(status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand | wc -l') +self.assertEqual(0, status, 'Failed to find "connmand" process running in background.') +self.assertEqual(1, int(output), 'Found {} connmand processes running, expected 1.'.format(output)) + +@testcase(963) +def test_connmand_file(self): +""" +Summary: test connmand file +Expected:connman-applet should be ELF32 binary +Product: BSPs +Author: Lucian Musat +AutomatedBy: Daniel Istrate +""" + +cmd = "readelf -h /usr/bin/connman-applet | sed -n '3p' | awk '{print $2}'" +expected_ret = 'ELF32' + +(status, output) = self.target.run(cmd) +self.assertEqual(0, status, 'Failed to send cmd "{}"'.format(cmd)) +self.assertEqual(expected_ret, str(output), "Expected {}, found instead {}".format(expected_ret, output)) diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py index 4ca193b..32aae24 100644 --- a/meta/lib/oeqa/runtime/rpm.py +++ b/meta/lib/oeqa/runtime/rpm.py @@ -58,6 +58,43 @@ class RpmInstallRemoveTest(oeRuntimeTest): (status, output) = self.target.run('sudo -u test1 rpm -qa') self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa" % status) +@testcase(195) +@skipUnlessPassed('test_rpm_install') +def test_check_rpm_install_removal_log_file_size(self): +""" +Summary: Check rpm install/removal log file size +Expected:There should be some method to keep rpm log in a small size . +Product: BSPs +Author: Alexandru Georgescu +AutomatedBy: Daniel Istrate +""" +db_files_cmd = 'ls /var/lib/rpm/__db.*' +get_log_size_cmd = "du /var/lib/rpm/log/
[OE-core] [PATCH] oeqa/selftest: [YOCTO #7976] Updated imagefeature testcases.
Updated testcases that use qemu to not interfere with other qemu instances that might run in parallel. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/imagefeatures.py | 153 1 file changed, 58 insertions(+), 95 deletions(-) diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py index e0e424d..030969e 100644 --- a/meta/lib/oeqa/selftest/imagefeatures.py +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -2,13 +2,20 @@ from oeqa.selftest.base import oeSelfTest from oeqa.utils.commands import runCmd, bitbake, get_bb_var from oeqa.utils.decorators import testcase import pexpect -from os.path import expanduser, isfile +from os.path import isfile from os import system import glob +import time class ImageFeatures(oeSelfTest): +test_user = 'tester' +root_user = 'root' +prompt = r'qemux86:\S+[$#]\s+' +ssh_cmd = "ssh {} -l {} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" +get_ip_patt = r'\s+ip=(?P(\d+.){3}\d+)::' + @testcase(1107) def test_non_root_user_can_connect_via_ssh_without_password(self): """ @@ -20,69 +27,49 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -test_user = 'tester' -root_user = 'root' -prompt = r'qemux86:\S+[$#]\s+' -tap_inf_ip = '192.168.7.2' - features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh empty-root-password"\n' features += 'INHERIT += "extrausers"\n' -features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user) +features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) # Append 'features' to local.conf self.append_config(features) # Build a core-image-minimal ret = bitbake('core-image-minimal') -self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal') - -rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip) -# Delete the ssh keys for 192.168.7.2 (qemu) -ret = runCmd(rm_ssh_keys_cmd) -self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.') +self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal. Reason: {}'.format(ret.output)) # Boot qemu image -proc_qemu = pexpect.spawn('runqemu qemux86 nographic') +proc_qemu = pexpect.spawn('runqemu qemux86') try: -proc_qemu.expect('qemux86 login:', timeout=100) +proc_qemu.expect(self.get_ip_patt, timeout=100) except: -system('pkill qemu') -proc_qemu.close() +proc_qemu.sendintr() self.fail('Failed to start qemu.') +qemu_ip = proc_qemu.match.group('qemu_ip') + +# Give it some time for qemu to boot up +time.sleep(60) + # Attempt to ssh with each user into qemu with empty password -for user in [root_user, test_user]: -proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user)) -index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF]) +for user in [self.root_user, self.test_user]: +proc_ssh = pexpect.spawn(self.ssh_cmd.format(qemu_ip, user)) +index = proc_ssh.expect([self.prompt, pexpect.TIMEOUT, pexpect.EOF]) if index == 0: -proc_ssh.sendline('yes') -try: -proc_ssh.expect(prompt) -except: -system('pkill qemu') -proc_qemu.close() -proc_ssh.terminate() -self.fail('Failed to ssh with {} user into qemu.'.format(user)) -elif index == 1: # user successfully logged in with empty password pass -elif index == 2: -system('pkill qemu') -proc_qemu.close() +elif index == 1: +proc_qemu.sendintr() proc_ssh.terminate() self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user)) else: -system('pkill qemu') -proc_qemu.close() +proc_qemu.sendintr() proc_ssh.terminate() self.fail('Failed to ssh
[OE-core] [PATCH] oeqa/runtime: Added one runtime testcase in connman.
(testcase 223) Check that only one connmand runs in background. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/runtime/connman.py | 23 +++ 1 file changed, 23 insertions(+) diff --git a/meta/lib/oeqa/runtime/connman.py b/meta/lib/oeqa/runtime/connman.py index cc537f7..b040400 100644 --- a/meta/lib/oeqa/runtime/connman.py +++ b/meta/lib/oeqa/runtime/connman.py @@ -28,3 +28,26 @@ class ConnmanTest(oeRuntimeTest): if status != 0: print self.service_status("connman") self.fail("No connmand process running") + +@testcase(223) +def test_only_one_connmand_in_background(self): +""" +Summary: Only one connmand in background +Expected:There will be only one connmand instance in background. +Product: BSPs +Author: Alexandru Georgescu +AutomatedBy: Daniel Istrate +""" + +# Make sure that 'connmand' is running in background +(status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand') +self.assertEqual(0, status, 'Failed to find "connmand" process running in background.') + +# Start a new instance of 'connmand' +(status, output) = self.target.run('connmand') +self.assertEqual(0, status, 'Failed to start a new "connmand" process.') + +# Make sure that only one 'connmand' is running in background +(status, output) = self.target.run(oeRuntimeTest.pscmd + ' | grep [c]onnmand | wc -l') +self.assertEqual(0, status, 'Failed to find "connmand" process running in background.') +self.assertEqual(1, int(output), 'Found {} connmand processes running, expected 1.'.format(output)) -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/runtime: Added a new automated rpm test.
testcase 195: Check rpm install/removal log file size Signed-off-by: Daniel Istrate --- meta/lib/oeqa/runtime/rpm.py | 37 + 1 file changed, 37 insertions(+) diff --git a/meta/lib/oeqa/runtime/rpm.py b/meta/lib/oeqa/runtime/rpm.py index 4ca193b..32aae24 100644 --- a/meta/lib/oeqa/runtime/rpm.py +++ b/meta/lib/oeqa/runtime/rpm.py @@ -58,6 +58,43 @@ class RpmInstallRemoveTest(oeRuntimeTest): (status, output) = self.target.run('sudo -u test1 rpm -qa') self.assertEqual(status, 0, msg="status: %s. Cannot run rpm -qa" % status) +@testcase(195) +@skipUnlessPassed('test_rpm_install') +def test_check_rpm_install_removal_log_file_size(self): +""" +Summary: Check rpm install/removal log file size +Expected:There should be some method to keep rpm log in a small size . +Product: BSPs +Author: Alexandru Georgescu +AutomatedBy: Daniel Istrate +""" +db_files_cmd = 'ls /var/lib/rpm/__db.*' +get_log_size_cmd = "du /var/lib/rpm/log/log.* | awk '{print $1}'" + +# Make sure that some database files are under /var/lib/rpm as '__db.xxx' +(status, output) = self.target.run(db_files_cmd) +self.assertEqual(0, status, 'Failed to find database files under /var/lib/rpm/ as __db.xxx') + +# Remove the package just in case +self.target.run('rpm -e rpm-doc') + +# Install/Remove a package 10 times +for i in range(10): +(status, output) = self.target.run('rpm -ivh /tmp/rpm-doc.rpm') +self.assertEqual(0, status, "Failed to install rpm-doc package. Reason: {}".format(output)) + +(status, output) = self.target.run('rpm -e rpm-doc') +self.assertEqual(0, status, "Failed to remove rpm-doc package. Reason: {}".format(output)) + +# Get the size of log file +(status, output) = self.target.run(get_log_size_cmd) +self.assertEqual(0, status, 'Failed to get the final size of the log file.') + +# Compare each log size +for log_file_size in output: +self.assertLessEqual(int(log_file_size), 11264, + 'Log file size is greater that expected (~10MB), found {} bytes'.format(log_file_size)) + @classmethod def tearDownClass(self): oeRuntimeTest.tc.target.run('rm -f /tmp/rpm-doc.rpm') -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/runtime: Added one automated runtime testcase.
testcase 240: Checks that bash is installed in image. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/runtime/bash.py | 23 +++ 1 file changed, 23 insertions(+) create mode 100644 meta/lib/oeqa/runtime/bash.py diff --git a/meta/lib/oeqa/runtime/bash.py b/meta/lib/oeqa/runtime/bash.py new file mode 100644 index 000..2a261a3 --- /dev/null +++ b/meta/lib/oeqa/runtime/bash.py @@ -0,0 +1,23 @@ +from oeqa.oetest import oeRuntimeTest +from oeqa.utils.decorators import * + + +class BashTest(oeRuntimeTest): + +@testcase(240) +@skipUnlessPassed("test_ssh") +def test_check_bash_in_image(self): +""" +Summary: check bash in image +Expected:bash command should exist in image +Product: BSPs +Author: Alexandru Georgescu + AutomatedBy: Daniel Istrate +""" + +cmd = 'which bash' +expected_ret = '/bin/bash' + +(status, output) = self.target.run(cmd) +self.assertEqual(0, status, 'Failed to send cmd "{}"'.format(cmd)) +self.assertEqual(str(output), expected_ret, 'Found "{}", instead of "{}"'.format(output, expected_ret)) -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest: Fix imagefeature testcases not to interfere with testimage on AB
[YOCTO #8017] - selftest does not use pkill qemu [YOCTO #7976] - tests do not touch .ssh/known_hosts - don't hardcode qemu IP [YOCTO #8027] - use qemu nographic Extra: removed unnecessary assert for bitbake and runCmd status Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/imagefeatures.py | 148 +++- 1 file changed, 48 insertions(+), 100 deletions(-) diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py index e0e424d..70ebbe4 100644 --- a/meta/lib/oeqa/selftest/imagefeatures.py +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -2,13 +2,20 @@ from oeqa.selftest.base import oeSelfTest from oeqa.utils.commands import runCmd, bitbake, get_bb_var from oeqa.utils.decorators import testcase import pexpect -from os.path import expanduser, isfile -from os import system +from os.path import isfile +from os import system, killpg import glob +import signal class ImageFeatures(oeSelfTest): +test_user = 'tester' +root_user = 'root' +prompt = r'qemux86:\S+[$#]\s+' +ssh_cmd = "ssh {} -l {} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" +get_ip_patt = r'\s+ip=(?P(\d+.){3}\d+)::' + @testcase(1107) def test_non_root_user_can_connect_via_ssh_without_password(self): """ @@ -20,69 +27,45 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -test_user = 'tester' -root_user = 'root' -prompt = r'qemux86:\S+[$#]\s+' -tap_inf_ip = '192.168.7.2' - features = 'EXTRA_IMAGE_FEATURES += "ssh-server-openssh empty-root-password"\n' features += 'INHERIT += "extrausers"\n' -features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(test_user, test_user) +features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) # Append 'features' to local.conf self.append_config(features) # Build a core-image-minimal -ret = bitbake('core-image-minimal') -self.assertEqual(0, ret.status, 'Failed to build a core-image-minimal') - -rm_ssh_keys_cmd = 'ssh-keygen -f "{}/.ssh/known_hosts" -R {}'.format(expanduser('~'), tap_inf_ip) -# Delete the ssh keys for 192.168.7.2 (qemu) -ret = runCmd(rm_ssh_keys_cmd) -self.assertEqual(0, ret.status, 'Failed to delete ssh keys for qemu host.') +bitbake('core-image-minimal') # Boot qemu image proc_qemu = pexpect.spawn('runqemu qemux86 nographic') try: +proc_qemu.expect(self.get_ip_patt, timeout=100) +qemu_ip = proc_qemu.match.group('qemu_ip') proc_qemu.expect('qemux86 login:', timeout=100) except: -system('pkill qemu') -proc_qemu.close() +killpg(proc_qemu.pid, signal.SIGTERM) self.fail('Failed to start qemu.') # Attempt to ssh with each user into qemu with empty password -for user in [root_user, test_user]: -proc_ssh = pexpect.spawn('ssh {} -l {}'.format(tap_inf_ip, user)) -index = proc_ssh.expect(['Are you sure you want to continue connecting', prompt, pexpect.TIMEOUT, pexpect.EOF]) +for user in [self.root_user, self.test_user]: +proc_ssh = pexpect.spawn(self.ssh_cmd.format(qemu_ip, user)) +index = proc_ssh.expect([self.prompt, pexpect.TIMEOUT, pexpect.EOF]) if index == 0: -proc_ssh.sendline('yes') -try: -proc_ssh.expect(prompt) -except: -system('pkill qemu') -proc_qemu.close() -proc_ssh.terminate() -self.fail('Failed to ssh with {} user into qemu.'.format(user)) -elif index == 1: # user successfully logged in with empty password pass -elif index == 2: -system('pkill qemu') -proc_qemu.close() +elif index == 1: +killpg(proc_qemu.pid, signal.SIGTERM) proc_ssh.terminate() self.fail('Failed to ssh with {} user into qemu (timeout).'.format(user)) else: -system('pkill qemu') -proc_qemu.close() +killpg(proc_qemu.pid, signal.SIGTERM) proc_ssh.terminate()
[OE-core] [PATCH] oeqa/selftest: buildoptions.py Removed unused imports
Removed unused imports: unittest, logging, pexpect Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildoptions.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 483803b..d76aef1 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -1,9 +1,6 @@ -import unittest import os -import logging import re import glob as g -import pexpect as p from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/archiver: Test that archiver filters on recipe name
[YOCTO #6929] this test validates the feature introduced in bug 6929 Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/archiver.py | 50 ++ 1 file changed, 50 insertions(+) create mode 100644 meta/lib/oeqa/selftest/archiver.py diff --git a/meta/lib/oeqa/selftest/archiver.py b/meta/lib/oeqa/selftest/archiver.py new file mode 100644 index 000..f2030c4 --- /dev/null +++ b/meta/lib/oeqa/selftest/archiver.py @@ -0,0 +1,50 @@ +from oeqa.selftest.base import oeSelfTest +from oeqa.utils.commands import bitbake, get_bb_var +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 + +# Update local.conf +self.write_config(features) + +tmp_dir = get_bb_var('TMPDIR') +deploy_dir_src = get_bb_var('DEPLOY_DIR_SRC') +target_sys = get_bb_var('TARGET_SYS') +src_path = os.path.join(deploy_dir_src, target_sys) + +# Delete tmp directory +shutil.rmtree(tmp_dir) + +# Build core-image-minimal +bitbake('core-image-minimal') + +# Check that include_recipe was included +is_included = len(glob.glob(src_path + '/%s*' % include_recipe)) +self.assertEqual(1, is_included, 'Recipe %s was not included.' % include_recipe) + +# Check that exclude_recipe was excluded +is_excluded = len(glob.glob(src_path + '/%s*' % exclude_recipe)) +self.assertEqual(0, is_excluded, 'Recipe %s was not excluded.' % exclude_recipe) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/wic: Added testcase decorator to all testcases + fixed minor typos.
Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/wic.py | 33 + 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 3dc54a4..9425dc0 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -31,6 +31,8 @@ from shutil import rmtree from oeqa.selftest.base import oeSelfTest from oeqa.utils.commands import runCmd, bitbake, get_bb_var +from oeqa.utils.decorators import testcase + class Wic(oeSelfTest): """Wic test class.""" @@ -56,24 +58,29 @@ class Wic(oeSelfTest): rmtree(self.resultdir, ignore_errors=True) +@testcase(1208) def test01_help(self): """Test wic --help""" self.assertEqual(0, runCmd('wic --help').status) +@testcase(1209) def test02_createhelp(self): """Test wic create --help""" self.assertEqual(0, runCmd('wic create --help').status) +@testcase(1210) def test03_listhelp(self): """Test wic list --help""" self.assertEqual(0, runCmd('wic list --help').status) +@testcase(1211) def test04_build_image_name(self): """Test wic create directdisk --image-name core-image-minimal""" self.assertEqual(0, runCmd("wic create directdisk " "--image-name core-image-minimal").status) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) +@testcase(1212) def test05_build_artifacts(self): """Test wic create directdisk providing all artifacts.""" vars = dict((var.lower(), get_bb_var(var, 'core-image-minimal')) \ @@ -87,33 +94,40 @@ class Wic(oeSelfTest): self.assertEqual(0, status) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) +@testcase(1157) def test06_gpt_image(self): """Test creation of core-image-minimal with gpt table and UUID boot""" self.assertEqual(0, runCmd("wic create directdisk-gpt " "--image-name core-image-minimal").status) self.assertEqual(1, len(glob(self.resultdir + "directdisk-*.direct"))) +@testcase(1213) def test07_unsupported_subcommand(self): """Test unsupported subcommand""" self.assertEqual(1, runCmd('wic unsupported', ignore_status=True).status) +@testcase(1214) def test08_no_command(self): """Test wic without command""" self.assertEqual(1, runCmd('wic', ignore_status=True).status) -def test09_help_kickstart(self): +@testcase(1215) +def test09_help_overview(self): """Test wic help overview""" self.assertEqual(0, runCmd('wic help overview').status) +@testcase(1216) def test10_help_plugins(self): """Test wic help plugins""" self.assertEqual(0, runCmd('wic help plugins').status) +@testcase(1217) def test11_help_kickstart(self): """Test wic help kickstart""" self.assertEqual(0, runCmd('wic help kickstart').status) +@testcase(1264) def test12_compress_gzip(self): """Test compressing an image with gzip""" self.assertEqual(0, runCmd("wic create directdisk " @@ -122,7 +136,8 @@ class Wic(oeSelfTest): self.assertEqual(1, len(glob(self.resultdir + \ "directdisk-*.direct.gz"))) -def test13_compress_gzip(self): +@testcase(1265) +def test13_compress_bzip2(self): """Test compressing an image with bzip2""" self.assertEqual(0, runCmd("wic create directdisk " "--image-name core-image-minimal " @@ -130,7 +145,8 @@ class Wic(oeSelfTest): self.assertEqual(1, len(glob(self.resultdir + \ "directdisk-*.direct.bz2"))) -def test14_compress_gzip(self): +@testcase(1266) +def test14_compress_xz(self): """Test compressing an image with xz""" self.assertEqual(0, runCmd("wic create directdisk " "--image-name core-image-minimal " @@ -138,12 +154,14 @@ class Wic(oeSelfTest): self.assertEqual(1, len(glob(self.resultdi
[OE-core] [PATCH] oeqa/selftest/bbtests: Updated bitbake TCs
- Added new TC test_force_task_1 (1354); check that do_package_write_rpm() re-executes upon changes in package image. - Updated TC test_force_task_2 (163); changed test recipe to zlib and added do_package() to the task execution list. - Removed unnecessary imports. Fix for bug [YOCTO #5875]. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/bbtests.py | 45 ++- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py index 3d6860f..46f1bfe 100644 --- a/meta/lib/oeqa/selftest/bbtests.py +++ b/meta/lib/oeqa/selftest/bbtests.py @@ -1,8 +1,5 @@ -import unittest import os -import logging import re -import shutil import oeqa.utils.ftools as ftools from oeqa.selftest.base import oeSelfTest @@ -68,15 +65,43 @@ class BitbakeTests(oeSelfTest): bitbake('-cclean man') self.assertTrue("ERROR: Function failed: patch_do_patch" in result.output, msg = "Though no man-1.5h1-make.patch file exists, bitbake didn't output any err. message. 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" +image_dir = get_bb_var('D', test_recipe) +pkgsplit_dir = get_bb_var('PKGDEST', test_recipe) +man_dir = get_bb_var('mandir', test_recipe) + +bitbake('-c cleansstate %s' % test_recipe) +bitbake(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(self): -bitbake('m4-native') -self.add_command_to_tearDown('bitbake -c clean m4-native') -result = bitbake('-C compile m4-native') -look_for_tasks = ['do_compile', 'do_install', 'do_populate_sysroot'] +def test_force_task_2(self): +# test 2 from bug 5875 +test_recipe = 'zlib' + +bitbake('-c cleansstate %s' % test_recipe) +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: -find_task = re.search("m4-native.*%s" % task, result.output) -self.assertTrue(find_task, msg = "Couldn't find %s task. bitbake output %s" % (task, result.output)) +self.assertIn(task, result.output, msg="Couldn't find %s task.") @testcase(167) def test_bitbake_g(self): -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/wic: corrected testcase decorator for test18_iso_image
Changed testcase decorator for TC test18_iso_image from 1264 to 1346. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/wic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 7625505..f4c22f7 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -190,7 +190,7 @@ class Wic(oeSelfTest): self.assertEqual(1, len(glob(self.resultdir + \ "%(wks)s-*.direct" % vars))) -@testcase(1264) +@testcase(1346) def test18_iso_image(self): """Test creation of hybrid iso image with legacy and EFI boot""" self.assertEqual(0, runCmd("wic create mkhybridiso " -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/signing: New test for Signing packages in the package feeds.
[YOCTO # 8134] This test verifies features introduced in bug 8134. It requires as resources the files from meta-selftest/files/signing: For 'gpg --gen-key' the used input was: key: RSA key-size: 2048 key-valid: 0 realname: testuser email: testu...@email.com comment: nocomment passphrase: test123 Depends on: http://lists.openembedded.org/pipermail/openembedded-core/2015-October/111550.html Signed-off-by: Daniel Istrate --- meta-selftest/files/signing/key.pub | 30 meta-selftest/files/signing/key.secret | 59 meta-selftest/files/signing/pubring.gpg | Bin 0 -> 1204 bytes meta-selftest/files/signing/secret.txt | 1 + meta-selftest/files/signing/secring.gpg | Bin 0 -> 2582 bytes meta-selftest/files/signing/trustdb.gpg | Bin 0 -> 40 bytes meta/lib/oeqa/selftest/signing.py | 51 +++ 7 files changed, 141 insertions(+) create mode 100644 meta-selftest/files/signing/key.pub create mode 100644 meta-selftest/files/signing/key.secret create mode 100644 meta-selftest/files/signing/pubring.gpg create mode 100644 meta-selftest/files/signing/secret.txt create mode 100644 meta-selftest/files/signing/secring.gpg create mode 100644 meta-selftest/files/signing/trustdb.gpg create mode 100644 meta/lib/oeqa/selftest/signing.py diff --git a/meta-selftest/files/signing/key.pub b/meta-selftest/files/signing/key.pub new file mode 100644 index 000..e197bb3 --- /dev/null +++ b/meta-selftest/files/signing/key.pub @@ -0,0 +1,30 @@ +-BEGIN PGP PUBLIC KEY BLOCK- +Version: GnuPG v1 + +mQENBFYeMycBCADISkEj+u+3SkGbmC4b09StA3Fk4J8bKZrTTpQqUhOH4QFIQpso +q96Q907h/ABAgB+IV0SGIeN866E7BqToqoXZ74X6EoyXWdndaMaFZSj+oNqqg6Gi +hVsuGNpvRyyXSCYW8w9H2lFx09UufFrUxoSeP2iVdJJaUAmb8e00PCwkYrS2BZEa +tO2VgllbaqczldmlUGnkIZt8YUSQSI/xZBDYUvbcZYBaOnDH1SDQl26f+bgyeIyS +TW5TZb96o4tMfiifgPoqAapAxQLahG0WtjF/n1yNV5wUNQYsEQf6/h6W2rHGsCP5 +6FVFnr/ZPVam9iHUxL4lvJSI8dEH37s9GmarABEBAAG0LXRlc3R1c2VyIChub2Nv +bW1lbnQpIDx0ZXN0dXNlckB0ZXN0ZW1haWwuY29tPokBOAQTAQIAIgUCVh4zJwIb +AwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQezExa11krVLM2wf/fW1C8DPx +tZEyl6iPXFjNotslo+t2TL6jPefC22KmbokJCtCnxcopBjQRuhUSNDTkXkUdVagy +TaaYILV8XGajTmcVGQTaKeh+j6TM6CBGApQB5KhHvZCyvNBrGcNyuiex0Sm/rIhS +fZre6ptZM/026W2kLwwJESXzHJEqCoFmU6aSOUCVyiDgMfcNw6c4NmEoqZtLdnxU +B7Nac98o933AIvaaQMGtKIOcyOM7P/dyv8eMc38z2ew5bEB8E9aSdg5koXb3zIt5 +IKea631k4INAsFFyLMQNSmmKV7RK0miF5b4hGyekrYZRtiic5+dq5aWnVka4hBfi +x31euxwQE87gQLkBDQRWHjMnAQgAt7C9QCFPWzLGQuQ/YaQub+8s2lYNQnmfwDHm +5PuON+Wj/f5GyQhHKsbdUAPZ7GsjFIQnva7xNYYF/IvpC+0saB5NLMkBzjfIsg92 +6MkadAKlOR2o9gKlF59mulsJmJqNFTXiRcVXvpUnU8WB9ECmm321XfYHhk+4EMay +H3OUZ0k6dEmvrWBTKNTR7M0z6j/jW+8J3vP3L9k1H+OV0EZwAKXfbh1lN4H467jY +3gA7FU1WDmA06HphoSaFUEGTuXGtrRP0eksCUj3BtVygXnyQb379dISDOWcs/9Ke +v3KMrZWgDnA4pH1eQpjycBhwKOCHYyhSSVOwCS3DGkaaklmQZwARAQABiQEfBBgB +AgAJBQJWHjMnAhsMAAoJEHsxMWtdZK1SoPsIAKadG/tvS5COCyF8FuriL89Ysfov +kMRKeb9hsMDbKX2lm3UtoS5ErmpkEUO/SbazQYm6/vYc8noQquqhkIdCljIvpWDv +17tXEFfTGA493dlTTEWFt5bvzbQN6OhBu3904lAE4JGtlOOa9OKDeguwXbneLOyl +dnlj2f7rw05cB9t/RDu7T11dTI39BMTUUm1lpWxYJk41o59b9g+fpJZkiIAJwnN3 +MwM1u9/AWfTqjNRgMAO5dIYceceTwGogujG+xz93flt+NjQhILG0T9jd0DFBgIAX +Zq4PzX5aFDKjGoFaOOZ6r+kppBLH/HN6okMGIcfqaPPdnJI1MXFQvFzUNpo= +=2cSJ +-END PGP PUBLIC KEY BLOCK- diff --git a/meta-selftest/files/signing/key.secret b/meta-selftest/files/signing/key.secret new file mode 100644 index 000..70ef829 --- /dev/null +++ b/meta-selftest/files/signing/key.secret @@ -0,0 +1,59 @@ +-BEGIN PGP PRIVATE KEY BLOCK- +Version: GnuPG v1 + +lQO+BFYeLjIBCADxa6HxI7YMC4fedDBB2IvQHXF7fc8JnXtDPCJFbRT4JgBvVzqy +9QRRGfL9+OOr6oKM3cXBUNFWz4UXpC5K3OIcBTy4n0X2YqUrF4jLNZvEZB0+Qpxi +PGQERacD5pPALZDlMPOulfVaq3up7qiMR2gXuQjggPIKmIlQGo5yr2KBNAbcXykh +1DI12qrwsaaXiruFyKCJItzFGlu6B0PqCE0NQOkY/wO+kUSiBP5aQH/WM5We17Wb +Lxl7MLwicheSLQix+YOftFYacs8zBIlkdoVnrwDkJLSwjqHw/i+03LTznr+i3Vp9 +mWRQFI+rcEI8XcLFxOemTYZcCQC+ppZA0F3VABEBAAH+AwMCggofrCu0WR9gR6VS +8/XQ3+yKFwp03/4dds0sYaS5GqIvWnKYOjKlClFDkdtvwKEV/0fvcfeTLMSCSVt3 +RqM+HnDQeCG4Ml+EkTlumUEUJcx03wFqDLpZDu2Ka/NpieYZTLvkUdl/SvUWoTDx +4XAeZGe82BMSUIfa0VDP+7xhsOl/YFqq25Ra/ykiiPWJdKZz75f90gjmX60MmIt/ +egJHx/ec7VaehvVPJ4HgY1dVokfW+WErsZmDP+Ei/zwcdzMIaeXsHJ8FSOqfeejG +u+hCADUUfta/IwdR7wVxvibJ1qqJSa+pf8slxeRjpfp+V6l5G+edfrtmOVkM7HaN +uonCdErAT6n+/l4ce/BuG76GtA232KWNGDJseyhfx011CttkPVEq8adGLA7iiTLC +IHBP58t8CNCRlzOn3IRpRuKkam+yg+vxe7ujaupMUtkBZmECBQa7oSoAGTcetqf3 +nq7N9D3CD7KJffoX+M/0Ye6Ptpc/1Szoea+Yl4u4upVdpie0DhD/o9k8pNT0MGdK +GdMwcgp2XSUpkatCEYD8tg0l8suxdXl4fbtLCi4RvKdU0ZhH6CFQ0IR3D6xtURBR +c0+bYPN3Vb+ynmXxwaUsYVvj7gkkfJbx0y592WpAAZqkfllDsmEaxyNd9SdBagld +KKpgDoV1Cmd7g0rrZJi83Nm5i2F5M1HCt/A91Gh0sx4N0BjnFolC7hCYXKoLBLPv +/saAH+evLZ2JwWlMiR3F/+fU6K916Pj/6LJlbAuCo9EjoD1HjRsC/Qxv/CNArN9N +lrBmSM6TIo3E+Ivsaq5LE7wtfj1V0Tvkl0ur7RS2PR38nbnbTfa1EiXqDBSdYXJP +y0iXB36RcoJVrR2G0UXjpjNWe29jEib07Oy3AN6rToDH771ImPSwtuqgwGo14jdj +MLQtdGVzdHVzZXIgKG5vY29tbWVudCkgPHRlc3R1c2VyQHRlc3
[OE-core] [PATCH 2/2] oeqa/selftest: Added/Updated docstring for each TC with TestopiaID
Also the TCs from meta-yocto-bsp/lib/oeqa/selftest/gummiboot were updated. Signed-off-by: Daniel Istrate --- meta-yocto-bsp/lib/oeqa/selftest/gummiboot.py | 2 + meta/lib/oeqa/selftest/archiver.py| 1 + meta/lib/oeqa/selftest/bblayers.py| 18 meta/lib/oeqa/selftest/bbtests.py | 66 +++ meta/lib/oeqa/selftest/buildoptions.py| 26 ++ meta/lib/oeqa/selftest/devtool.py | 67 ++- meta/lib/oeqa/selftest/imagefeatures.py | 5 ++ meta/lib/oeqa/selftest/layerappend.py | 3 + meta/lib/oeqa/selftest/lic-checksum.py| 3 + meta/lib/oeqa/selftest/oescripts.py | 6 ++ meta/lib/oeqa/selftest/pkgdata.py | 24 ++ meta/lib/oeqa/selftest/prservice.py | 24 ++ meta/lib/oeqa/selftest/recipetool.py | 96 + meta/lib/oeqa/selftest/sstatetests.py | 46 +++ meta/lib/oeqa/selftest/wic.py | 115 -- 15 files changed, 477 insertions(+), 25 deletions(-) diff --git a/meta-yocto-bsp/lib/oeqa/selftest/gummiboot.py b/meta-yocto-bsp/lib/oeqa/selftest/gummiboot.py index 00aa36f..c3d48b5 100644 --- a/meta-yocto-bsp/lib/oeqa/selftest/gummiboot.py +++ b/meta-yocto-bsp/lib/oeqa/selftest/gummiboot.py @@ -37,6 +37,7 @@ class Gummiboot(oeSelfTest): Product: oe-core Author: Ionut Chisanovici AutomatedBy: Daniel Istrate +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1101 """ # We'd use DEPLOY_DIR_IMAGE here, except that we need its value for @@ -63,6 +64,7 @@ class Gummiboot(oeSelfTest): Product: oe-core Author: Ionut Chisanovici AutomatedBy: Daniel Istrate +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1103 """ self._common_setup() diff --git a/meta/lib/oeqa/selftest/archiver.py b/meta/lib/oeqa/selftest/archiver.py index f2030c4..10f9ec7 100644 --- a/meta/lib/oeqa/selftest/archiver.py +++ b/meta/lib/oeqa/selftest/archiver.py @@ -17,6 +17,7 @@ class Archiver(oeSelfTest): Product: oe-core Author: Daniel Istrate AutomatedBy: Daniel Istrate +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=1345 """ include_recipe = 'busybox' diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py index 20c17e4..af6e434 100644 --- a/meta/lib/oeqa/selftest/bblayers.py +++ b/meta/lib/oeqa/selftest/bblayers.py @@ -13,26 +13,41 @@ class BitbakeLayers(oeSelfTest): @testcase(756) def test_bitbakelayers_showcrossdepends(self): +""" +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=756 +""" 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): +""" +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=83 +""" 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): +""" +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=93 +""" 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. bitbake-layers show-appends output: %s" % result.output) @testcase(90) def test_bitbakelayers_showoverlayed(self): +""" +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=90 +""" 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): +""" +TestopiaID: https://bugzilla.yoctoproject.org/tr_show_case.cgi?case_id=95 +""" testoutdir = os.path.join(self.builddir, 'test_bitbakelayers_flatten') self.assertFalse(os.path.isdir(testoutdir), msg = "test_bitbakelayers_
[OE-core] [PATCH 1/2] oeqa/selftest: Added testcase decorators.
Added testcase decorators for testopia integration. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/devtool.py | 8 ++-- meta/lib/oeqa/selftest/recipetool.py | 11 +++ meta/lib/oeqa/selftest/sstatetests.py | 14 -- meta/lib/oeqa/selftest/wic.py | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index baa56d6..18e2a9d 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -378,6 +378,7 @@ class DevtoolTests(DevtoolBase): self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed. devtool output: %s' % (testrecipe, result.output)) self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe) +@testcase(1365) def test_devtool_modify_native(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') @@ -723,7 +724,7 @@ class DevtoolTests(DevtoolBase): self.assertEqual(expectedlines, f.readlines()) # Deleting isn't expected to work under these circumstances -@testcase(1173) +@testcase(1370) def test_devtool_update_recipe_local_files(self): """Check that local source files are copied over instead of patched""" testrecipe = 'makedevs' @@ -753,7 +754,7 @@ class DevtoolTests(DevtoolBase): ('??', '.*/makedevs/0001-Add-new-file.patch$')] self._check_repo_status(os.path.dirname(recipefile), expected_status) -@testcase(1174) +@testcase(1371) def test_devtool_update_recipe_local_files_2(self): """Check local source files support when oe-local-files is in Git""" testrecipe = 'lzo' @@ -832,6 +833,7 @@ class DevtoolTests(DevtoolBase): matches2 = glob.glob(stampprefix2 + '*') self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2) +@testcase(1272) def test_devtool_deploy_target(self): # NOTE: Whilst this test would seemingly be better placed as a runtime test, # unfortunately the runtime tests run under bitbake and you can't run @@ -916,6 +918,7 @@ class DevtoolTests(DevtoolBase): result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand), ignore_status=True) self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have') +@testcase(1366) def test_devtool_build_image(self): """Test devtool build-image plugin""" # Check preconditions @@ -949,6 +952,7 @@ class DevtoolTests(DevtoolBase): if reqpkgs: self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs)) +@testcase(1367) def test_devtool_upgrade(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py index c34ad68..b1f1d2a 100644 --- a/meta/lib/oeqa/selftest/recipetool.py +++ b/meta/lib/oeqa/selftest/recipetool.py @@ -492,9 +492,12 @@ class RecipetoolAppendsrcBase(RecipetoolBase): class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): + +@testcase(1273) def test_recipetool_appendsrcfile_basic(self): self._test_appendsrcfile('base-files', 'a-file') +@testcase(1274) def test_recipetool_appendsrcfile_basic_wildcard(self): testrecipe = 'base-files' self._test_appendsrcfile(testrecipe, 'a-file', options='-w') @@ -502,12 +505,15 @@ class RecipetoolAppendsrcTests(RecipetoolAppendsrcBase): bbappendfile = self._check_bbappend(testrecipe, recipefile, self.templayerdir) self.assertEqual(os.path.basename(bbappendfile), '%s_%%.bbappend' % testrecipe) +@testcase(1281) def test_recipetool_appendsrcfile_subdir_basic(self): self._test_appendsrcfile('base-files', 'a-file', 'tmp') +@testcase(1282) def test_recipetool_appendsrcfile_subdir_basic_dirdest(self): self._test_appendsrcfile('base-files', destdir='tmp') +@testcase(1280) def test_recipetool_appendsrcfile_srcdir_basic(self): testrecipe = 'bash' srcdir = get_bb_var('S', testrecipe) @@ -515,12 +521,14 @@ class RecipetoolAppend
[OE-core] [PATCH] oeqa/selftest: Added testcase decorators.
Added testcase decorators for testopia integration. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/devtool.py | 11 +-- meta/lib/oeqa/selftest/manifest.py| 2 ++ meta/lib/oeqa/selftest/recipetool.py | 11 +++ meta/lib/oeqa/selftest/sstatetests.py | 14 -- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index fb46559..f48e6a2 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -378,6 +378,7 @@ class DevtoolTests(DevtoolBase): self.assertNotEqual(result.status, 0, 'devtool modify on %s should have failed. devtool output: %s' % (testrecipe, result.output)) self.assertIn('ERROR: ', result.output, 'devtool modify on %s should have given an ERROR' % testrecipe) +@testcase(1365) def test_devtool_modify_native(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') @@ -466,6 +467,7 @@ class DevtoolTests(DevtoolBase): # Try building bitbake(testrecipe) +@testcase(1378) def test_devtool_modify_virtual(self): # Try modifying a virtual recipe virtrecipe = 'virtual/libx11' @@ -745,7 +747,7 @@ class DevtoolTests(DevtoolBase): self.assertEqual(expectedlines, f.readlines()) # Deleting isn't expected to work under these circumstances -@testcase(1173) +@testcase(1370) def test_devtool_update_recipe_local_files(self): """Check that local source files are copied over instead of patched""" testrecipe = 'makedevs' @@ -775,7 +777,7 @@ class DevtoolTests(DevtoolBase): ('??', '.*/makedevs/0001-Add-new-file.patch$')] self._check_repo_status(os.path.dirname(recipefile), expected_status) -@testcase(1174) +@testcase(1371) def test_devtool_update_recipe_local_files_2(self): """Check local source files support when oe-local-files is in Git""" testrecipe = 'lzo' @@ -827,6 +829,7 @@ class DevtoolTests(DevtoolBase): self.assertTrue(os.path.exists(os.path.join(tempdir, 'Makefile.am')), 'Extracted source could not be found') self._check_src_repo(tempdir) +@testcase(1379) def test_devtool_extract_virtual(self): tempdir = tempfile.mkdtemp(prefix='devtoolqa') # Try devtool extract @@ -864,6 +867,7 @@ class DevtoolTests(DevtoolBase): matches2 = glob.glob(stampprefix2 + '*') self.assertFalse(matches2, 'Stamp files exist for recipe %s that should have been cleaned' % testrecipe2) +@testcase(1272) def test_devtool_deploy_target(self): # NOTE: Whilst this test would seemingly be better placed as a runtime test, # unfortunately the runtime tests run under bitbake and you can't run @@ -948,6 +952,7 @@ class DevtoolTests(DevtoolBase): result = runCmd('ssh %s root@%s %s' % (sshargs, qemu.ip, testcommand), ignore_status=True) self.assertNotEqual(result, 0, 'undeploy-target did not remove command as it should have') +@testcase(1366) def test_devtool_build_image(self): """Test devtool build-image plugin""" # Check preconditions @@ -981,6 +986,7 @@ class DevtoolTests(DevtoolBase): if reqpkgs: self.fail('The following packages were not present in the image as expected: %s' % ', '.join(reqpkgs)) +@testcase(1367) def test_devtool_upgrade(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') @@ -1016,6 +1022,7 @@ class DevtoolTests(DevtoolBase): self.track_for_cleanup(self.workspacedir) self.add_command_to_tearDown('bitbake-layers remove-layer */workspace') +@testcase(1352) def test_devtool_layer_plugins(self): """Test that devtool can use plugins from other layers. diff --git a/meta/lib/oeqa/selftest/manifest.py b/meta/lib/oeqa/selftest/manifest.py index c813c1d..44d0404 100644 --- a/meta/lib/oeqa/selftest/manifest.py +++ b/meta/lib/oeqa/selftest/manifest.py @@ -59,6 +59,7 @@ class VerifyManifest(oeSelfTest): unittest.SkipTest("{}: Cannot setup testing scenario"\ .format(self.classname)) +@testcase(1380) def test_SDK_manifest_entries(self): '''Verifying the SDK manifest entries exist, this may take a build'&
[OE-core] [PATCHv2 2/2] oeqa/selftest/signing: Added new test for signing sstate.
[YOCTO #8182] Optional signing sstate archives and signature verification [YOCTO #8559] Signing sstate archives with custom dir for gpg keys Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/signing.py | 49 +++ 1 file changed, 49 insertions(+) diff --git a/meta/lib/oeqa/selftest/signing.py b/meta/lib/oeqa/selftest/signing.py index fd8a52c..571b0b2 100644 --- a/meta/lib/oeqa/selftest/signing.py +++ b/meta/lib/oeqa/selftest/signing.py @@ -2,6 +2,7 @@ from oeqa.selftest.base import oeSelfTest from oeqa.utils.commands import runCmd, bitbake, get_bb_var import os import glob +import re from oeqa.utils.decorators import testcase @@ -74,3 +75,51 @@ class Signing(oeSelfTest): ret = runCmd('%s/rpm --checksig %s' % (staging_bindir_native, pkg_deploy)) # tmp/deploy/rpm/i586/ed-1.9-r0.i586.rpm: rsa sha1 md5 OK self.assertIn('rsa sha1 md5 OK', ret.output, 'Package signed incorrectly.') + +@testcase(1382) +def test_signing_sstate_archive(self): +""" +Summary: Test that sstate archives can be signed +Expected:Package should be signed with the correct key + Product: oe-core +Author: Daniel Istrate +AutomatedBy: Daniel Istrate +""" + +test_recipe = 'ed' + +builddir = os.environ.get('BUILDDIR') +sstatedir = os.path.join(builddir, 'test-sstate') + +self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) +self.add_command_to_tearDown('bitbake -c cleansstate %s' % test_recipe) +self.add_command_to_tearDown('rm -rf %s' % sstatedir) + +# Determine the pub key signature +ret = runCmd('gpg --homedir %s --list-keys' % self.gpg_dir) +pub_key = re.search(r'^pub\s+\S+/(\S+)\s+', ret.output, re.M) +self.assertIsNotNone(pub_key, 'Failed to determine the public key signature.') +pub_key = pub_key.group(1) + +feature = 'SSTATE_SIG_KEY ?= "%s"\n' % pub_key +feature += 'SSTATE_SIG_PASSPHRASE ?= "test123"\n' +feature += 'SSTATE_VERIFY_SIG ?= "1"\n' +feature += 'GPG_PATH = "%s"\n' % self.gpg_dir +feature += 'SSTATE_DIR = "%s"\n' % sstatedir + +self.write_config(feature) + +bitbake('-c cleansstate %s' % test_recipe) +bitbake('-c clean %s' % test_recipe) +bitbake(test_recipe) + +recipe_sig = glob.glob(sstatedir + '/*/*:ed:*_package.tgz.sig') +recipe_tgz = glob.glob(sstatedir + '/*/*:ed:*_package.tgz') + +self.assertEqual(len(recipe_sig), 1, 'Failed to find .sig file.') +self.assertEqual(len(recipe_tgz), 1, 'Failed to find .tgz file.') + +ret = runCmd('gpg --homedir %s --verify %s %s' % (self.gpg_dir, recipe_sig[0], recipe_tgz[0])) +# gpg: Signature made Thu 22 Oct 2015 01:45:09 PM EEST using RSA key ID 61EEFB30 +# gpg: Good signature from "testuser (nocomment) " +self.assertIn('gpg: Good signature from', ret.output, 'Package signed incorrectly.') -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv2 1/2] oeqa/selftest/signing: New test for Signing packages in the package feeds.
[YOCTO # 8134] This test verifies features introduced in bug 8134. It requires as resources the files from meta-selftest/files/signing: For 'gpg --gen-key' the used input was: key: RSA key-size: 2048 key-valid: 0 realname: testuser email: testu...@email.com comment: nocomment passphrase: test123 Signed-off-by: Daniel Istrate --- meta-selftest/files/signing/key.pub| 30 ++ meta-selftest/files/signing/key.secret | 59 ++ meta-selftest/files/signing/secret.txt | 1 + meta/lib/oeqa/selftest/signing.py | 76 ++ 4 files changed, 166 insertions(+) create mode 100644 meta-selftest/files/signing/key.pub create mode 100644 meta-selftest/files/signing/key.secret create mode 100644 meta-selftest/files/signing/secret.txt create mode 100644 meta/lib/oeqa/selftest/signing.py diff --git a/meta-selftest/files/signing/key.pub b/meta-selftest/files/signing/key.pub new file mode 100644 index 000..e197bb3 --- /dev/null +++ b/meta-selftest/files/signing/key.pub @@ -0,0 +1,30 @@ +-BEGIN PGP PUBLIC KEY BLOCK- +Version: GnuPG v1 + +mQENBFYeMycBCADISkEj+u+3SkGbmC4b09StA3Fk4J8bKZrTTpQqUhOH4QFIQpso +q96Q907h/ABAgB+IV0SGIeN866E7BqToqoXZ74X6EoyXWdndaMaFZSj+oNqqg6Gi +hVsuGNpvRyyXSCYW8w9H2lFx09UufFrUxoSeP2iVdJJaUAmb8e00PCwkYrS2BZEa +tO2VgllbaqczldmlUGnkIZt8YUSQSI/xZBDYUvbcZYBaOnDH1SDQl26f+bgyeIyS +TW5TZb96o4tMfiifgPoqAapAxQLahG0WtjF/n1yNV5wUNQYsEQf6/h6W2rHGsCP5 +6FVFnr/ZPVam9iHUxL4lvJSI8dEH37s9GmarABEBAAG0LXRlc3R1c2VyIChub2Nv +bW1lbnQpIDx0ZXN0dXNlckB0ZXN0ZW1haWwuY29tPokBOAQTAQIAIgUCVh4zJwIb +AwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQezExa11krVLM2wf/fW1C8DPx +tZEyl6iPXFjNotslo+t2TL6jPefC22KmbokJCtCnxcopBjQRuhUSNDTkXkUdVagy +TaaYILV8XGajTmcVGQTaKeh+j6TM6CBGApQB5KhHvZCyvNBrGcNyuiex0Sm/rIhS +fZre6ptZM/026W2kLwwJESXzHJEqCoFmU6aSOUCVyiDgMfcNw6c4NmEoqZtLdnxU +B7Nac98o933AIvaaQMGtKIOcyOM7P/dyv8eMc38z2ew5bEB8E9aSdg5koXb3zIt5 +IKea631k4INAsFFyLMQNSmmKV7RK0miF5b4hGyekrYZRtiic5+dq5aWnVka4hBfi +x31euxwQE87gQLkBDQRWHjMnAQgAt7C9QCFPWzLGQuQ/YaQub+8s2lYNQnmfwDHm +5PuON+Wj/f5GyQhHKsbdUAPZ7GsjFIQnva7xNYYF/IvpC+0saB5NLMkBzjfIsg92 +6MkadAKlOR2o9gKlF59mulsJmJqNFTXiRcVXvpUnU8WB9ECmm321XfYHhk+4EMay +H3OUZ0k6dEmvrWBTKNTR7M0z6j/jW+8J3vP3L9k1H+OV0EZwAKXfbh1lN4H467jY +3gA7FU1WDmA06HphoSaFUEGTuXGtrRP0eksCUj3BtVygXnyQb379dISDOWcs/9Ke +v3KMrZWgDnA4pH1eQpjycBhwKOCHYyhSSVOwCS3DGkaaklmQZwARAQABiQEfBBgB +AgAJBQJWHjMnAhsMAAoJEHsxMWtdZK1SoPsIAKadG/tvS5COCyF8FuriL89Ysfov +kMRKeb9hsMDbKX2lm3UtoS5ErmpkEUO/SbazQYm6/vYc8noQquqhkIdCljIvpWDv +17tXEFfTGA493dlTTEWFt5bvzbQN6OhBu3904lAE4JGtlOOa9OKDeguwXbneLOyl +dnlj2f7rw05cB9t/RDu7T11dTI39BMTUUm1lpWxYJk41o59b9g+fpJZkiIAJwnN3 +MwM1u9/AWfTqjNRgMAO5dIYceceTwGogujG+xz93flt+NjQhILG0T9jd0DFBgIAX +Zq4PzX5aFDKjGoFaOOZ6r+kppBLH/HN6okMGIcfqaPPdnJI1MXFQvFzUNpo= +=2cSJ +-END PGP PUBLIC KEY BLOCK- diff --git a/meta-selftest/files/signing/key.secret b/meta-selftest/files/signing/key.secret new file mode 100644 index 000..d30d7cd --- /dev/null +++ b/meta-selftest/files/signing/key.secret @@ -0,0 +1,59 @@ +-BEGIN PGP PRIVATE KEY BLOCK- +Version: GnuPG v1 + +lQO+BFYeMycBCADISkEj+u+3SkGbmC4b09StA3Fk4J8bKZrTTpQqUhOH4QFIQpso +q96Q907h/ABAgB+IV0SGIeN866E7BqToqoXZ74X6EoyXWdndaMaFZSj+oNqqg6Gi +hVsuGNpvRyyXSCYW8w9H2lFx09UufFrUxoSeP2iVdJJaUAmb8e00PCwkYrS2BZEa +tO2VgllbaqczldmlUGnkIZt8YUSQSI/xZBDYUvbcZYBaOnDH1SDQl26f+bgyeIyS +TW5TZb96o4tMfiifgPoqAapAxQLahG0WtjF/n1yNV5wUNQYsEQf6/h6W2rHGsCP5 +6FVFnr/ZPVam9iHUxL4lvJSI8dEH37s9GmarABEBAAH+AwMCLgbvBp7KeMdgcmpy +Eheo+Xi7oLtKh5qc2LsxJnvszt4Q+0+v+dO+nlsRBuZAAo6EryyzH/HcncEoTQeG +FvB6Si0IA79a7sdWLz6GmI/gfQUYeR1A7amjbFTu/OGGZIxd9uUrsoNu3Hs5UbeI +0KjrhDYQrEt3GktF0WfAWnOkO3sONbXTKRxATw0YqT96wfPHmTK22qHVKodi2O6O +yNnQ2JotGTiSCYB9geQ0jrYMotJlFrMC0UqIAip2iP/zLwXpCMjEJud5hY4aEDtQ +JkDtQjPb2ICO98AqY6H/I7v1UAzUXJq7tIHTtA2d/9FJ++4wXqWJl3v7pKOOW323 +xpYZgPCtG+Ebx1NAGhze8rncsP+AjtC3dbHWBr6xpVtfw+AJCuSMB9ZR2SXE5NJD +SlTzjsDbbCiCcTvfb+PfIpsMuTadWt+B+sI+LUsK4AaKRItinUz8ozn6ym3gyKA3 +rasW+ZVo9p7LiTX2JjS1K8h+7Sim2WlqTMvk+IzSDdoVRf6SUQ5JXOyxs3p5V5Tb +2EyOuWfN6Fw4Xt3Pso09mSXGg1w6wmqW4nAslsL7U9alTzfNp6wZs5BaXWHRwnyu +LzHATIkHbKbHZYZTJXguZm2jDJiDAIcdX6gpkUYZJpY7c69aMRUe1Xb/3YK4BhbG +qpY0ams3ZwOe0EUz9Y1WLOFz7GqiKC5MBJLwcI483e6frVMMWNnyAH2yYau+n9st +zI/L0nsk8+wpt9ORNq+BT78SL6WznfUdl4OTaJUdzighjBEmlCX5s0hI/09HqpbA +ZdwDrBXmqFlN4BknZ3FCgGecBcG1hrXu80wH+qzA9lFKwJeKyFVGYX2ZPFyMxKJs +1q2emoEqLg0r/ePJvYXpgXIH9ENTphRGTY6z57m8ouMw+TvqI55SOyIqqPTSqgxU +B7QtdGVzdHVzZXIgKG5vY29tbWVudCkgPHRlc3R1c2VyQHRlc3RlbWFpbC5jb20+ +iQE4BBMBAgAiBQJWHjMnAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRB7 +MTFrXWStUszbB/99bULwM/G1kTKXqI9cWM2i2yWj63ZMvqM958LbYqZuiQkK0KfF +yikGNBG6FRI0NOReRR1VqDJNppggtXxcZqNOZxUZBNop6H6PpMzoIEYClAHkqEe9 +kLK80GsZw3K6J7HRKb+siFJ9mt7qm1kz/TbpbaQvDAkRJfMckSoKgWZTppI5QJXK +IOAx9w3Dpzg2YSipm0t2fFQHs1pz3yj3fcAi9ppAwa0og5zI4zs/93K/x4xzfzPZ +7DlsQHwT1pJ2DmShdvfMi3kgp5rrfWTgg0CwUXIsxA1KaYpXtErSaIXlviEbJ6St +hlG2KJzn52rlpadWRriEF+LHfV67HBATzuBAnQO+BFYeMycBCAC3sL1AIU9bMsZC +5D9hpC5v7yzaVg1CeZ/AMebk+4435aP9/kbJCEcqxt1QA9nsayMUhC
[OE-core] [PATCHv3 1/2] oeqa/selftest/signing: New test for Signing packages in the package feeds.
[YOCTO # 8134] This test verifies features introduced in bug 8134. It requires as resources the files from meta-selftest/files/signing: For 'gpg --gen-key' the used input was: key: RSA key-size: 2048 key-valid: 0 realname: testuser email: testu...@email.com comment: nocomment passphrase: test123 Signed-off-by: Daniel Istrate --- meta-selftest/files/signing/key.pub| 30 ++ meta-selftest/files/signing/key.secret | 59 ++ meta-selftest/files/signing/secret.txt | 1 + meta/lib/oeqa/selftest/signing.py | 76 ++ 4 files changed, 166 insertions(+) create mode 100644 meta-selftest/files/signing/key.pub create mode 100644 meta-selftest/files/signing/key.secret create mode 100644 meta-selftest/files/signing/secret.txt create mode 100644 meta/lib/oeqa/selftest/signing.py diff --git a/meta-selftest/files/signing/key.pub b/meta-selftest/files/signing/key.pub new file mode 100644 index 000..e197bb3 --- /dev/null +++ b/meta-selftest/files/signing/key.pub @@ -0,0 +1,30 @@ +-BEGIN PGP PUBLIC KEY BLOCK- +Version: GnuPG v1 + +mQENBFYeMycBCADISkEj+u+3SkGbmC4b09StA3Fk4J8bKZrTTpQqUhOH4QFIQpso +q96Q907h/ABAgB+IV0SGIeN866E7BqToqoXZ74X6EoyXWdndaMaFZSj+oNqqg6Gi +hVsuGNpvRyyXSCYW8w9H2lFx09UufFrUxoSeP2iVdJJaUAmb8e00PCwkYrS2BZEa +tO2VgllbaqczldmlUGnkIZt8YUSQSI/xZBDYUvbcZYBaOnDH1SDQl26f+bgyeIyS +TW5TZb96o4tMfiifgPoqAapAxQLahG0WtjF/n1yNV5wUNQYsEQf6/h6W2rHGsCP5 +6FVFnr/ZPVam9iHUxL4lvJSI8dEH37s9GmarABEBAAG0LXRlc3R1c2VyIChub2Nv +bW1lbnQpIDx0ZXN0dXNlckB0ZXN0ZW1haWwuY29tPokBOAQTAQIAIgUCVh4zJwIb +AwYLCQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQezExa11krVLM2wf/fW1C8DPx +tZEyl6iPXFjNotslo+t2TL6jPefC22KmbokJCtCnxcopBjQRuhUSNDTkXkUdVagy +TaaYILV8XGajTmcVGQTaKeh+j6TM6CBGApQB5KhHvZCyvNBrGcNyuiex0Sm/rIhS +fZre6ptZM/026W2kLwwJESXzHJEqCoFmU6aSOUCVyiDgMfcNw6c4NmEoqZtLdnxU +B7Nac98o933AIvaaQMGtKIOcyOM7P/dyv8eMc38z2ew5bEB8E9aSdg5koXb3zIt5 +IKea631k4INAsFFyLMQNSmmKV7RK0miF5b4hGyekrYZRtiic5+dq5aWnVka4hBfi +x31euxwQE87gQLkBDQRWHjMnAQgAt7C9QCFPWzLGQuQ/YaQub+8s2lYNQnmfwDHm +5PuON+Wj/f5GyQhHKsbdUAPZ7GsjFIQnva7xNYYF/IvpC+0saB5NLMkBzjfIsg92 +6MkadAKlOR2o9gKlF59mulsJmJqNFTXiRcVXvpUnU8WB9ECmm321XfYHhk+4EMay +H3OUZ0k6dEmvrWBTKNTR7M0z6j/jW+8J3vP3L9k1H+OV0EZwAKXfbh1lN4H467jY +3gA7FU1WDmA06HphoSaFUEGTuXGtrRP0eksCUj3BtVygXnyQb379dISDOWcs/9Ke +v3KMrZWgDnA4pH1eQpjycBhwKOCHYyhSSVOwCS3DGkaaklmQZwARAQABiQEfBBgB +AgAJBQJWHjMnAhsMAAoJEHsxMWtdZK1SoPsIAKadG/tvS5COCyF8FuriL89Ysfov +kMRKeb9hsMDbKX2lm3UtoS5ErmpkEUO/SbazQYm6/vYc8noQquqhkIdCljIvpWDv +17tXEFfTGA493dlTTEWFt5bvzbQN6OhBu3904lAE4JGtlOOa9OKDeguwXbneLOyl +dnlj2f7rw05cB9t/RDu7T11dTI39BMTUUm1lpWxYJk41o59b9g+fpJZkiIAJwnN3 +MwM1u9/AWfTqjNRgMAO5dIYceceTwGogujG+xz93flt+NjQhILG0T9jd0DFBgIAX +Zq4PzX5aFDKjGoFaOOZ6r+kppBLH/HN6okMGIcfqaPPdnJI1MXFQvFzUNpo= +=2cSJ +-END PGP PUBLIC KEY BLOCK- diff --git a/meta-selftest/files/signing/key.secret b/meta-selftest/files/signing/key.secret new file mode 100644 index 000..d30d7cd --- /dev/null +++ b/meta-selftest/files/signing/key.secret @@ -0,0 +1,59 @@ +-BEGIN PGP PRIVATE KEY BLOCK- +Version: GnuPG v1 + +lQO+BFYeMycBCADISkEj+u+3SkGbmC4b09StA3Fk4J8bKZrTTpQqUhOH4QFIQpso +q96Q907h/ABAgB+IV0SGIeN866E7BqToqoXZ74X6EoyXWdndaMaFZSj+oNqqg6Gi +hVsuGNpvRyyXSCYW8w9H2lFx09UufFrUxoSeP2iVdJJaUAmb8e00PCwkYrS2BZEa +tO2VgllbaqczldmlUGnkIZt8YUSQSI/xZBDYUvbcZYBaOnDH1SDQl26f+bgyeIyS +TW5TZb96o4tMfiifgPoqAapAxQLahG0WtjF/n1yNV5wUNQYsEQf6/h6W2rHGsCP5 +6FVFnr/ZPVam9iHUxL4lvJSI8dEH37s9GmarABEBAAH+AwMCLgbvBp7KeMdgcmpy +Eheo+Xi7oLtKh5qc2LsxJnvszt4Q+0+v+dO+nlsRBuZAAo6EryyzH/HcncEoTQeG +FvB6Si0IA79a7sdWLz6GmI/gfQUYeR1A7amjbFTu/OGGZIxd9uUrsoNu3Hs5UbeI +0KjrhDYQrEt3GktF0WfAWnOkO3sONbXTKRxATw0YqT96wfPHmTK22qHVKodi2O6O +yNnQ2JotGTiSCYB9geQ0jrYMotJlFrMC0UqIAip2iP/zLwXpCMjEJud5hY4aEDtQ +JkDtQjPb2ICO98AqY6H/I7v1UAzUXJq7tIHTtA2d/9FJ++4wXqWJl3v7pKOOW323 +xpYZgPCtG+Ebx1NAGhze8rncsP+AjtC3dbHWBr6xpVtfw+AJCuSMB9ZR2SXE5NJD +SlTzjsDbbCiCcTvfb+PfIpsMuTadWt+B+sI+LUsK4AaKRItinUz8ozn6ym3gyKA3 +rasW+ZVo9p7LiTX2JjS1K8h+7Sim2WlqTMvk+IzSDdoVRf6SUQ5JXOyxs3p5V5Tb +2EyOuWfN6Fw4Xt3Pso09mSXGg1w6wmqW4nAslsL7U9alTzfNp6wZs5BaXWHRwnyu +LzHATIkHbKbHZYZTJXguZm2jDJiDAIcdX6gpkUYZJpY7c69aMRUe1Xb/3YK4BhbG +qpY0ams3ZwOe0EUz9Y1WLOFz7GqiKC5MBJLwcI483e6frVMMWNnyAH2yYau+n9st +zI/L0nsk8+wpt9ORNq+BT78SL6WznfUdl4OTaJUdzighjBEmlCX5s0hI/09HqpbA +ZdwDrBXmqFlN4BknZ3FCgGecBcG1hrXu80wH+qzA9lFKwJeKyFVGYX2ZPFyMxKJs +1q2emoEqLg0r/ePJvYXpgXIH9ENTphRGTY6z57m8ouMw+TvqI55SOyIqqPTSqgxU +B7QtdGVzdHVzZXIgKG5vY29tbWVudCkgPHRlc3R1c2VyQHRlc3RlbWFpbC5jb20+ +iQE4BBMBAgAiBQJWHjMnAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRB7 +MTFrXWStUszbB/99bULwM/G1kTKXqI9cWM2i2yWj63ZMvqM958LbYqZuiQkK0KfF +yikGNBG6FRI0NOReRR1VqDJNppggtXxcZqNOZxUZBNop6H6PpMzoIEYClAHkqEe9 +kLK80GsZw3K6J7HRKb+siFJ9mt7qm1kz/TbpbaQvDAkRJfMckSoKgWZTppI5QJXK +IOAx9w3Dpzg2YSipm0t2fFQHs1pz3yj3fcAi9ppAwa0og5zI4zs/93K/x4xzfzPZ +7DlsQHwT1pJ2DmShdvfMi3kgp5rrfWTgg0CwUXIsxA1KaYpXtErSaIXlviEbJ6St +hlG2KJzn52rlpadWRriEF+LHfV67HBATzuBAnQO+BFYeMycBCAC3sL1AIU9bMsZC +5D9hpC5v7yzaVg1CeZ/AMebk+4435aP9/kbJCEcqxt1QA9nsayMUhC
[OE-core] [PATCHv3 2/2] oeqa/selftest/signing: Added new test for signing sstate.
[YOCTO #8182] Optional signing sstate archives and signature verification [YOCTO #8559] Signing sstate archives with custom dir for gpg keys Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/signing.py | 48 +++ 1 file changed, 48 insertions(+) diff --git a/meta/lib/oeqa/selftest/signing.py b/meta/lib/oeqa/selftest/signing.py index 879c3e0..c33662b 100644 --- a/meta/lib/oeqa/selftest/signing.py +++ b/meta/lib/oeqa/selftest/signing.py @@ -2,6 +2,7 @@ from oeqa.selftest.base import oeSelfTest from oeqa.utils.commands import runCmd, bitbake, get_bb_var import os import glob +import re from oeqa.utils.decorators import testcase @@ -74,3 +75,50 @@ class Signing(oeSelfTest): # tmp/deploy/rpm/i586/ed-1.9-r0.i586.rpm: rsa sha1 md5 OK self.assertIn('rsa sha1 md5 OK', ret.output, 'Package signed incorrectly.') +@testcase(1382) +def test_signing_sstate_archive(self): +""" +Summary: Test that sstate archives can be signed +Expected:Package should be signed with the correct key +Product: oe-core +Author: Daniel Istrate +AutomatedBy: Daniel Istrate +""" + +test_recipe = 'ed' + +builddir = os.environ.get('BUILDDIR') +sstatedir = os.path.join(builddir, 'test-sstate') + +self.add_command_to_tearDown('bitbake -c clean %s' % test_recipe) +self.add_command_to_tearDown('bitbake -c cleansstate %s' % test_recipe) +self.add_command_to_tearDown('rm -rf %s' % sstatedir) + +# Determine the pub key signature +ret = runCmd('gpg --homedir %s --list-keys' % self.gpg_dir) +pub_key = re.search(r'^pub\s+\S+/(\S+)\s+', ret.output, re.M) +self.assertIsNotNone(pub_key, 'Failed to determine the public key signature.') +pub_key = pub_key.group(1) + +feature = 'SSTATE_SIG_KEY ?= "%s"\n' % pub_key +feature += 'SSTATE_SIG_PASSPHRASE ?= "test123"\n' +feature += 'SSTATE_VERIFY_SIG ?= "1"\n' +feature += 'GPG_PATH = "%s"\n' % self.gpg_dir +feature += 'SSTATE_DIR = "%s"\n' % sstatedir + +self.write_config(feature) + +bitbake('-c cleansstate %s' % test_recipe) +bitbake(test_recipe) + +recipe_sig = glob.glob(sstatedir + '/*/*:ed:*_package.tgz.sig') +recipe_tgz = glob.glob(sstatedir + '/*/*:ed:*_package.tgz') + +self.assertEqual(len(recipe_sig), 1, 'Failed to find .sig file.') +self.assertEqual(len(recipe_tgz), 1, 'Failed to find .tgz file.') + +ret = runCmd('gpg --homedir %s --verify %s %s' % (self.gpg_dir, recipe_sig[0], recipe_tgz[0])) +# gpg: Signature made Thu 22 Oct 2015 01:45:09 PM EEST using RSA key ID 61EEFB30 +# gpg: Good signature from "testuser (nocomment) " +self.assertIn('gpg: Good signature from', ret.output, 'Package signed incorrectly.') + -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] scripts: analyze_patch: Analyze patch and suggest tests.
[YOCTO #8647] - Script to analyse what areas a patch changes and what tests need running This script will analyze files modified by a commit and attempt to suggest what tests to run. It is somewhat dependent of the 'snakefood' tool to determine the import relationship between files. If this pkg is missing a backup file will be used instead: deps.txt Usage: analyze_patch --revision Example: analyze_patch --revision 351c69a Revision: 351c69a Modified files: meta/recipes-support/sqlite/files/0001-using-the-dynamic-library.patch meta/recipes-support/sqlite/sqlite3_3.8.10.2.bb meta/recipes-support/sqlite/sqlite3_3.9.0.bb Suggested tests: Rebuild: sqlite3 Signed-off-by: Daniel Istrate --- scripts/analyze_patch | 300 scripts/deps.txt | 628 ++ 2 files changed, 928 insertions(+) create mode 100755 scripts/analyze_patch create mode 100644 scripts/deps.txt diff --git a/scripts/analyze_patch b/scripts/analyze_patch new file mode 100755 index 000..1b6609b --- /dev/null +++ b/scripts/analyze_patch @@ -0,0 +1,300 @@ +#!/usr/bin/env python + +# Description: This will analyze the files modified by a commit and attempt to suggest what tests to run. +# It uses an adjacent file 'deps.txt' that was generated by 'snakefood' tool: +# sfood | grep -v /usr/lib/python | grep -v /usr/share/pyshared/ | +# grep -v None | grep ".py')," | grep ".py\'))" > deps.txt +# This file has to be edited further: remove the and replace "', '" with '/'. +# In the end you should have something like this: a matrix with 2 columns, which represent +# elements from the left import elements from the right. +# (('bitbake/lib/bb/build.py'), ('bitbake/lib/bb/event.py')) +# (('bitbake/lib/bb/build.py'), ('bitbake/lib/bb/msg.py')) +# +# How to use it: analyze_patch --revision +#analyze_patch -r 2d1071e +# Notes: if revision is not provided, will default to HEAD +# Author: Daniel Istrate + +import argparse +import os +import glob +import ast +import re +from subprocess import PIPE, Popen, STDOUT + +parser = argparse.ArgumentParser() +parser.add_argument('-r', '--revision', help=' changes to analyze.') +args = parser.parse_args() + +revision = args.revision or 'HEAD' + +this_file_path = os.path.dirname(os.path.abspath(__file__)) +poky_dir = os.path.abspath(os.path.join(this_file_path, os.pardir)) +# Move into the the poky dir +os.chdir(poky_dir) + +# Where are the available tests located +bb_test_dir = 'bitbake/lib/bb/tests/' +selftest_dir = 'meta/lib/oeqa/selftest/' +runtime_dir = 'meta/lib/oeqa/runtime/' + +RETOK = 0 + + +def run_cmd(cmd, ignore_err=False): +""" +Run cmd in bash shell +:param cmd: command to be ran. +:param ignore_err: redirect stderr to /dev/null, otherwise redirect stderr to stdout +:return: tuple containing exit code & output of the cmd +""" +DEVNULL = open(os.devnull, 'w') + +if ignore_err: +proc = Popen(args=cmd, stdout=PIPE, stderr=DEVNULL, shell=True, executable='/bin/bash') +else: +proc = Popen(args=cmd, stdout=PIPE, stderr=STDOUT, shell=True, executable='/bin/bash') +retval = proc.communicate()[0] +retcode = proc.returncode + +return retcode, retval + + +def get_modified_files(rev=revision): +""" +Determine modified files by a commit +:param rev: the revision number to determine modified files for. +:return: a list of modified files +""" +cmd = 'git diff-tree --no-commit-id --name-only -r ' + rev +retcode, retval = run_cmd(cmd) + +if retcode != RETOK: +return retcode, retval + +retlist = retval.split('\n') +retlist.remove('') + +return retlist + + +def get_list_of_testuites(test_dir): +""" +Looks for .py files in test_dir +:param test_dir: directory containing (hopefully) test suites +:return: list of test suites +""" +test_suites = [] +test_list = glob.glob(test_dir + '*.py') + +# trim the .py extension and the path to each testsuite +for ts in test_list: +test_suites.append(ts.replace(test_dir, '').replace('.py', '')) + +# remove __init__ from test_suites +try: +test_suites.remove('__init__') +except: +pass + +return test_suites + + +def get_modules_dependencies(mfile): +""" +Get modules dependencies from poky. +It uses 'snakefood' pkg (please make sure it is installed)
[OE-core] [PATCH] scripts: oe-selftest Added new features.
[YOCTO #8750] Allow oe-selftest to run custom test suites based on different criteria 1. Can run custom lists of tests based on different criteria: --run-tests-by eg: --run-tests-by module imagefeatures signing recipetool --run-tests-by id 1377 1273 935 --run-tests-by tag wic sstate bitbake 2. Can list tests based on different criteria: --list-tests-by eg: --list-tests-by module imagefeatures signing recipetool --list-tests-by id 1377 1273 935 --list-tests-by tag wic sstate bitbake 3. Can list all tags that have been set to test cases: --list-tags The list of tags should be kept as minimal as possible. This helps preview the tags used so far. To take advantage of the 'tag' feature: - add @tag(feature=<>) to testcases eg: @tag(feature='signing') for a single tag @tag(feature=(('signing', 'sstate')) or @tag(feature=['signing', 'sstate']) for multiple tags Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 218 +++- 1 file changed, 216 insertions(+), 2 deletions(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 9679962..bc50b2a 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -72,6 +72,12 @@ def get_args_parser(): group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, help='List all available test modules.') group.add_argument('--list-classes', required=False, action="store_true", dest="list_allclasses", default=False, help='List all available test classes.') parser.add_argument('--coverage', action="store_true", help="Run code coverage when testing") +group.add_argument('--run-tests-by', required=False, dest='run_tests_by', default=False, nargs='*', + help='run-tests-by ') +group.add_argument('--list-tests-by', required=False, dest='list_tests_by', default=False, nargs='*', + help='list-tests-by ') +group.add_argument('--list-tags', required=False, dest='list_tags', default=False, action="store_true", + help='List all tags that have been set to test cases.') return parser @@ -156,6 +162,187 @@ def get_tests(exclusive_modules=[], include_hidden=False): return testslist + +class Tc: +def __init__(self, tcname, tcclass, tcmodule, tcid=None, tctag=None): +self.tcname = tcname +self.tcclass = tcclass +self.tcmodule = tcmodule +self.tcid = tcid +# A test case can have multiple tags (as list or as tuples) otherwise str suffice +self.tctag = tctag +self.fullpath = '.'.join(['oeqa', 'selftest', tcmodule, tcclass, tcname]) + + +def get_tests_from_module(tmod): +tlist = [] +prefix = 'oeqa.selftest.' + +try: +import importlib +modlib = importlib.import_module(tmod) +for mod in vars(modlib).values(): +if isinstance(mod, type(oeSelfTest)) and issubclass(mod, oeSelfTest) and mod is not oeSelfTest: +for test in dir(mod): +if test.startswith('test_') and hasattr(vars(mod)[test], '__call__'): +# Get test case id and feature tag +# NOTE: if testcase decorator or feature tag not set will throw error +try: +tid = vars(mod)[test].test_case +except: +print 'DEBUG: tc id missing for ' + str(test) +tid = None +try: +ttag = vars(mod)[test].tag__feature +except: +# print 'DEBUG: feature tag missing for ' + str(test) +ttag = None + +# NOTE: for some reason lstrip() doesn't work for mod.__module__ +tlist.append(Tc(test, mod.__name__, mod.__module__.replace(prefix, ''), tid, ttag)) +except: +pass + +return tlist + + +def get_all_tests(): +tmodules = set() +testlist = [] +prefix = 'oeqa.selftest.' + +# Get all the test modules (except the hidden ones) +for tpath in oeqa.selftest.__path__: +files = sorted([f for f in os.listdir(tpath) if f.endswith('.py') and not +f.startswith(('_', '__')) and f != 'base.py']) +for f in files: +tmodules.add(prefix + f.rstrip('.py')
[OE-core] [PATCH] oeqa/selftest: Added testcase decorators for 2 testcases
bblayers: test_bitbakelayers_showrecipes1384 wic: test_directdisk_bootloader_config 1385 Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/bblayers.py | 1 + meta/lib/oeqa/selftest/wic.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/bblayers.py b/meta/lib/oeqa/selftest/bblayers.py index 5452925..b88c25e 100644 --- a/meta/lib/oeqa/selftest/bblayers.py +++ b/meta/lib/oeqa/selftest/bblayers.py @@ -61,6 +61,7 @@ class BitbakeLayers(oeSelfTest): 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) diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index f4404bf..55f6f82 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -257,7 +257,7 @@ class Wic(oeSelfTest): % image).status) self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) -#@testcase() +@testcase(1385) def test_directdisk_bootloader_config(self): """Test creation of directdisk-bootloader-config image""" image = "directdisk-bootloader-config" -- 2.1.4 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] selftest/buildhistory.py: Test buildhistory does not change sigs
[YOCTO #5953] Add a test to ensure buildhistory does not change signatures. Also removed unused imports. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildhistory.py | 69 -- 1 file changed, 65 insertions(+), 4 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildhistory.py b/meta/lib/oeqa/selftest/buildhistory.py index d8cae46..e8aa05d 100644 --- a/meta/lib/oeqa/selftest/buildhistory.py +++ b/meta/lib/oeqa/selftest/buildhistory.py @@ -1,12 +1,10 @@ -import unittest import os import re -import shutil import datetime -import oeqa.utils.ftools as ftools from oeqa.selftest.base import oeSelfTest -from oeqa.utils.commands import Command, runCmd, bitbake, get_bb_var, get_test_layer +from oeqa.utils.commands import bitbake, get_bb_var +from oeqa.utils.decorators import testcase class BuildhistoryBase(oeSelfTest): @@ -43,3 +41,66 @@ class BuildhistoryBase(oeSelfTest): self.assertTrue(search_for_error, msg="Could not find desired error in output: %s" % error_regex) else: self.assertEqual(result.status, 0, msg="Command 'bitbake %s' has failed unexpectedly: %s" % (target, result.output)) + +@testcase(1386) +def test_buildhistory_does_not_change_signatures(self): +""" +Summary: Ensure that buildhistory does not change signatures +Expected:Only 'do_rootfs' and 'do_build' tasks are rerun +Product: oe-core + Author: Daniel Istrate +AutomatedBy: Daniel Istrate +""" + +tmpdir1_name = 'tmpsig1' +tmpdir2_name = 'tmpsig2' +builddir = os.environ.get('BUILDDIR') +tmpdir1 = os.path.join(builddir, tmpdir1_name) +tmpdir2 = os.path.join(builddir, tmpdir2_name) + +self.track_for_cleanup(tmpdir1) +self.track_for_cleanup(tmpdir2) + +features = 'TMPDIR = "%s"\n' % tmpdir1 +self.write_config(features) +bitbake('core-image-sato -S none') + +features = 'TMPDIR = "%s"\n' % tmpdir2 +features += 'INHERIT += "buildhistory"\n' +self.write_config(features) +bitbake('core-image-sato -S none') + +def get_files(d): +f = [] +for root, dirs, files in os.walk(d): +for name in files: +f.append(os.path.join(root, name)) +return f + +files1 = get_files(tmpdir1 + '/stamps') +files2 = get_files(tmpdir2 + '/stamps') +files2 = [x.replace(tmpdir2_name, tmpdir1_name) for x in files2] + +f1 = set(files1) +f2 = set(files2) +sigdiff = f1 - f2 + +self.assertEqual(len(sigdiff), 2, 'Expected 2 signature differences. Out: %s' % list(sigdiff)) + +unexpected_diff = [] + +# No new signatures should appear apart from do_rootfs and do_build +found_do_rootfs_flag = False +found_do_build_flag = False + +for sig in sigdiff: +if 'do_rootfs' in sig: +found_do_rootfs_flag = True +elif 'do_build' in sig: +found_do_build_flag = True +else: +unexpected_diff.append(sig) + +self.assertTrue(found_do_rootfs_flag, 'Task do_rootfs did not rerun.') +self.assertTrue(found_do_build_flag, 'Task do_build did not rerun') +self.assertFalse(unexpected_diff, 'Found unexpected signature differences. Out: %s' % unexpected_diff) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 1/2] scripts/oe-selftest: Allow to run tests on random/all architecture oeqa/selftest/base.py: Updated to accomodate this feature
[YOCTO #5880] oe-selftest : add an option for random arch Added new feature to oe-selftest: --arch [random/all] 1. random: will set a random MACHINE for each test 2. all: will run tests for all architectures Custom arch sets only weak default values (??=) for MACHINE in local.conf This let test cases that require a specific MACHINE to be able to override it, using (?= or =). eg: oe-selftest --run-tests signing --arch random --> will run all tests switching MACHINE randomly for each test oe-selftest --run-tests signing --arch all --> for each arch will run all tests oe-selftest --run-all-tests --arch random Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/base.py | 39 +-- scripts/oe-selftest| 34 +++--- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 9bddc23..4ee0a8a 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py @@ -16,6 +16,7 @@ import errno import oeqa.utils.ftools as ftools from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer from oeqa.utils.decorators import LogResults +from random import choice @LogResults class oeSelfTest(unittest.TestCase): @@ -29,9 +30,12 @@ class oeSelfTest(unittest.TestCase): self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") +self.archinc_path = os.path.join(self.builddir, "conf/arch.inc") self.testlayer_path = oeSelfTest.testlayer_path self._extra_tear_down_commands = [] -self._track_for_cleanup = [self.testinc_path] +self._track_for_cleanup = [self.testinc_path, self.testinc_bblayers_path, self.archinc_path] +self.arch_list = ['qemuarm', 'qemuarm64', 'qemumips', 'qemuppc', 'qemux86', 'qemux86-64', + 'beaglebone', 'genericx86', 'genericx86-64', 'mpc8315e-rdb', 'edgerouter'] super(oeSelfTest, self).__init__(methodName) def setUp(self): @@ -47,11 +51,25 @@ class oeSelfTest(unittest.TestCase): for f in files: if f == 'test_recipe.inc': os.remove(os.path.join(root, f)) -try: -os.remove(self.testinc_bblayers_path) -except OSError as e: -if e.errno != errno.ENOENT: -raise + +for incl_file in [self.testinc_bblayers_path, self.archinc_path]: +try: +os.remove(incl_file) +except OSError as e: +if e.errno != errno.ENOENT: +raise + +# Get CUSTOMARCH from env (set by --arch argument to oe-selftest) +customarch = os.getenv('CUSTOMARCH') +if customarch: +if customarch == 'random': +machine = self.get_random_arch() +else: +machine = customarch +arch_conf = 'MACHINE ??= "%s"\n' % machine +self.set_arch_config(arch_conf) +print 'Arch: %s' % machine + # tests might need their own setup # but if they overwrite this one they have to call # super each time, so let's give them an alternative @@ -151,3 +169,12 @@ class oeSelfTest(unittest.TestCase): def remove_bblayers_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data)) ftools.remove_from_file(self.testinc_bblayers_path, data) + +def get_random_arch(self): +# Return a random arch from the arch_list +return choice(self.arch_list) + +# write to /conf/arch.inc +def set_arch_config(self, data): +self.log.debug("Writing to: %s\n%s\n" % (self.archinc_path, data)) +ftools.write_file(self.archinc_path, data) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index bc50b2a..8a3df19 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -78,6 +78,8 @@ def get_args_parser(): help='list-tests-by ') group.add_argument('--list-tags', required=False, dest='list_tags', default=False, action="store_true", help='List all tags that have been set to test cases.') +parser.add_argument('--arch', required=False, dest='arch', choices=['random', 'all'], default=None, +help='Run tests on different architecture (random/all).') return parser @@
[OE-core] [PATCH 2/2] selftest: Added MACHINE = "qemux86" to tests that use runqemu
It makes sense for tests that use runqemu to have MACHINE set as qemu. This also avoid issues when running oe-selftest with --arch random/all option. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/devtool.py | 7 --- meta/lib/oeqa/selftest/imagefeatures.py | 9 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 0a44ae7..84665e4 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -875,10 +875,11 @@ class DevtoolTests(DevtoolBase): # Additionally we are testing build-time functionality as well, so # really this has to be done as an oe-selftest test. # + +features = 'MACHINE = "qemux86"\n' +self.write_config(features) + # Check preconditions -machine = get_bb_var('MACHINE') -if not machine.startswith('qemu'): -self.skipTest('This test only works with qemu machines') if not os.path.exists('/etc/runqemu-nosudo'): self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py index 4efb0d9..62ddc52 100644 --- a/meta/lib/oeqa/selftest/imagefeatures.py +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -22,7 +22,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -48,7 +49,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -77,7 +79,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'PREFERRED_VERSION_rpm = "4.%"\n' +features = 'MACHINE = "qemux86"\n' +features += 'PREFERRED_VERSION_rpm = "4.%"\n' features += 'PREFERRED_VERSION_rpm-native = "4.%"\n' # Use openssh in IMAGE_INSTALL instead of ssh-server-openssh in EXTRA_IMAGE_FEATURES as a workaround for bug 8047 features += 'IMAGE_INSTALL_append = " openssh"\n' -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv2 2/2] selftest: Added MACHINE = "qemux86" to tests that use runqemu
It makes sense for tests that use runqemu to have MACHINE set as qemu. This also avoid issues when running oe-selftest with --arch random/all option. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/devtool.py | 7 --- meta/lib/oeqa/selftest/imagefeatures.py | 9 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 0a44ae7..84665e4 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -875,10 +875,11 @@ class DevtoolTests(DevtoolBase): # Additionally we are testing build-time functionality as well, so # really this has to be done as an oe-selftest test. # + +features = 'MACHINE = "qemux86"\n' +self.write_config(features) + # Check preconditions -machine = get_bb_var('MACHINE') -if not machine.startswith('qemu'): -self.skipTest('This test only works with qemu machines') if not os.path.exists('/etc/runqemu-nosudo'): self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py index 4efb0d9..62ddc52 100644 --- a/meta/lib/oeqa/selftest/imagefeatures.py +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -22,7 +22,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -48,7 +49,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -77,7 +79,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'PREFERRED_VERSION_rpm = "4.%"\n' +features = 'MACHINE = "qemux86"\n' +features += 'PREFERRED_VERSION_rpm = "4.%"\n' features += 'PREFERRED_VERSION_rpm-native = "4.%"\n' # Use openssh in IMAGE_INSTALL instead of ssh-server-openssh in EXTRA_IMAGE_FEATURES as a workaround for bug 8047 features += 'IMAGE_INSTALL_append = " openssh"\n' -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv2 1/2] scripts/oe-selftest: Allow to run tests on random/all architecture
Add an option for random arch into oe-selftest: --arch [random/all] 1. random: will set a random MACHINE for each test 2. all: will run tests for all architectures Custom arch sets only weak default values (??=) for MACHINE in local.conf. This let test cases that require a specific MACHINE to be able to override it, using (?= or =). e.g.: oe-selftest --run-tests signing --arch random --> will run all tests switching MACHINE randomly for each test oe-selftest --run-tests signing --arch all --> for each arch will run all tests oe-selftest --run-all-tests --arch random Also update oeqa/selftest/base.py to accomodate this feature. Fix for [YOCTO #5880]. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/base.py | 39 +-- scripts/oe-selftest| 34 +++--- 2 files changed, 60 insertions(+), 13 deletions(-) diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 9bddc23..4ee0a8a 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py @@ -16,6 +16,7 @@ import errno import oeqa.utils.ftools as ftools from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer from oeqa.utils.decorators import LogResults +from random import choice @LogResults class oeSelfTest(unittest.TestCase): @@ -29,9 +30,12 @@ class oeSelfTest(unittest.TestCase): self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") +self.archinc_path = os.path.join(self.builddir, "conf/arch.inc") self.testlayer_path = oeSelfTest.testlayer_path self._extra_tear_down_commands = [] -self._track_for_cleanup = [self.testinc_path] +self._track_for_cleanup = [self.testinc_path, self.testinc_bblayers_path, self.archinc_path] +self.arch_list = ['qemuarm', 'qemuarm64', 'qemumips', 'qemuppc', 'qemux86', 'qemux86-64', + 'beaglebone', 'genericx86', 'genericx86-64', 'mpc8315e-rdb', 'edgerouter'] super(oeSelfTest, self).__init__(methodName) def setUp(self): @@ -47,11 +51,25 @@ class oeSelfTest(unittest.TestCase): for f in files: if f == 'test_recipe.inc': os.remove(os.path.join(root, f)) -try: -os.remove(self.testinc_bblayers_path) -except OSError as e: -if e.errno != errno.ENOENT: -raise + +for incl_file in [self.testinc_bblayers_path, self.archinc_path]: +try: +os.remove(incl_file) +except OSError as e: +if e.errno != errno.ENOENT: +raise + +# Get CUSTOMARCH from env (set by --arch argument to oe-selftest) +customarch = os.getenv('CUSTOMARCH') +if customarch: +if customarch == 'random': +machine = self.get_random_arch() +else: +machine = customarch +arch_conf = 'MACHINE ??= "%s"\n' % machine +self.set_arch_config(arch_conf) +print 'Arch: %s' % machine + # tests might need their own setup # but if they overwrite this one they have to call # super each time, so let's give them an alternative @@ -151,3 +169,12 @@ class oeSelfTest(unittest.TestCase): def remove_bblayers_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data)) ftools.remove_from_file(self.testinc_bblayers_path, data) + +def get_random_arch(self): +# Return a random arch from the arch_list +return choice(self.arch_list) + +# write to /conf/arch.inc +def set_arch_config(self, data): +self.log.debug("Writing to: %s\n%s\n" % (self.archinc_path, data)) +ftools.write_file(self.archinc_path, data) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index bc50b2a..8a3df19 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -78,6 +78,8 @@ def get_args_parser(): help='list-tests-by ') group.add_argument('--list-tags', required=False, dest='list_tags', default=False, action="store_true", help='List all tags that have been set to test cases.') +parser.add_argument('--arch', required=False, dest='arch', choices=['random', 'all'], default=None, +help='Run tests on different architecture (random/all).')
[OE-core] [PATCHv3 2/2] selftest: Added MACHINE = "qemux86" to tests that use runqemu
It makes sense for tests that use runqemu to have MACHINE set as qemu. This also avoid issues when running oe-selftest with --arch random/all option. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/devtool.py | 7 --- meta/lib/oeqa/selftest/imagefeatures.py | 9 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 0a44ae7..84665e4 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -875,10 +875,11 @@ class DevtoolTests(DevtoolBase): # Additionally we are testing build-time functionality as well, so # really this has to be done as an oe-selftest test. # + +features = 'MACHINE = "qemux86"\n' +self.write_config(features) + # Check preconditions -machine = get_bb_var('MACHINE') -if not machine.startswith('qemu'): -self.skipTest('This test only works with qemu machines') if not os.path.exists('/etc/runqemu-nosudo'): self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py index 4efb0d9..62ddc52 100644 --- a/meta/lib/oeqa/selftest/imagefeatures.py +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -22,7 +22,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -48,7 +49,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -77,7 +79,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'PREFERRED_VERSION_rpm = "4.%"\n' +features = 'MACHINE = "qemux86"\n' +features += 'PREFERRED_VERSION_rpm = "4.%"\n' features += 'PREFERRED_VERSION_rpm-native = "4.%"\n' # Use openssh in IMAGE_INSTALL instead of ssh-server-openssh in EXTRA_IMAGE_FEATURES as a workaround for bug 8047 features += 'IMAGE_INSTALL_append = " openssh"\n' -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv3 1/2] scripts/oe-selftest: Allow to run tests on random/all architecture
Add an option for random arch into oe-selftest: --arch [random/all] 1. random: will set a random MACHINE for each test 2. all: will run tests for all architectures Custom arch sets only weak default values (??=) for MACHINE in local.conf. This let test cases that require a specific MACHINE to be able to override it, using (?= or =). e.g.: oe-selftest --run-tests signing --arch random --> will run all tests switching MACHINE randomly for each test oe-selftest --run-tests signing --arch all --> for each arch will run all tests oe-selftest --run-all-tests --arch random Also update oeqa/selftest/base.py to accomodate this feature. Fix for [YOCTO #5880]. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/base.py | 49 -- scripts/oe-selftest| 34 +++-- 2 files changed, 70 insertions(+), 13 deletions(-) diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 9bddc23..d71bbbd 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py @@ -16,6 +16,7 @@ import errno import oeqa.utils.ftools as ftools from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer from oeqa.utils.decorators import LogResults +from random import choice @LogResults class oeSelfTest(unittest.TestCase): @@ -29,9 +30,12 @@ class oeSelfTest(unittest.TestCase): self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") +self.archinc_path = os.path.join(self.builddir, "conf/arch.inc") self.testlayer_path = oeSelfTest.testlayer_path self._extra_tear_down_commands = [] -self._track_for_cleanup = [self.testinc_path] +self._track_for_cleanup = [self.testinc_path, self.testinc_bblayers_path, self.archinc_path] +self.arch_list = ['qemuarm', 'qemuarm64', 'qemumips', 'qemuppc', 'qemux86', 'qemux86-64', + 'beaglebone', 'genericx86', 'genericx86-64', 'mpc8315e-rdb', 'edgerouter'] super(oeSelfTest, self).__init__(methodName) def setUp(self): @@ -47,11 +51,25 @@ class oeSelfTest(unittest.TestCase): for f in files: if f == 'test_recipe.inc': os.remove(os.path.join(root, f)) -try: -os.remove(self.testinc_bblayers_path) -except OSError as e: -if e.errno != errno.ENOENT: -raise + +for incl_file in [self.testinc_bblayers_path, self.archinc_path]: +try: +os.remove(incl_file) +except OSError as e: +if e.errno != errno.ENOENT: +raise + +# Get CUSTOMARCH from env (set by --arch argument to oe-selftest) +customarch = os.getenv('CUSTOMARCH') +if customarch: +if customarch == 'random': +machine = self.get_random_arch() +else: +machine = customarch +arch_conf = 'MACHINE ??= "%s"\n' % machine +self.set_arch_config(arch_conf) +print 'Arch: %s' % machine + # tests might need their own setup # but if they overwrite this one they have to call # super each time, so let's give them an alternative @@ -99,11 +117,21 @@ class oeSelfTest(unittest.TestCase): self.log.debug("Writing to: %s\n%s\n" % (self.testinc_path, data)) ftools.write_file(self.testinc_path, data) +customarch = os.getenv('CUSTOMARCH') +if customarch and 'MACHINE' in data: +machine = get_bb_var('MACHINE') +self.log.warning('Arch overridden: %s' % machine) + # append to /conf/selftest.inc def append_config(self, data): self.log.debug("Appending to: %s\n%s\n" % (self.testinc_path, data)) ftools.append_file(self.testinc_path, data) +customarch = os.getenv('CUSTOMARCH') +if customarch and 'MACHINE' in data: +machine = get_bb_var('MACHINE') +self.log.warning('Arch overridden: %s' % machine) + # remove data from /conf/selftest.inc def remove_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_path, data)) @@ -151,3 +179,12 @@ class oeSelfTest(unittest.TestCase): def remove_bblayers_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data)) ftools.remove_from_file(self.testinc_b
[OE-core] [PATCHv4 1/2] scripts/oe-selftest: Allow to run tests on random/all architecture
Add an option for random MACHINE into oe-selftest: --machine [random/all] 1. random: will set a random MACHINE for each test 2. all: will run tests for all machines Custom machine sets only weak default values (??=) for MACHINE in machine.inc. This let test cases that require a specific MACHINE to be able to override it, using (?= or =). e.g.: oe-selftest --run-tests signing --machine random --> will run all tests switching MACHINE randomly for each test oe-selftest --run-tests signing --machine all --> for each machine will run all tests oe-selftest --run-all-tests --machine random Also update oeqa/selftest/base.py to accomodate this feature. Fix for [YOCTO #5880]. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/base.py | 64 ++ scripts/oe-selftest| 37 ++-- 2 files changed, 86 insertions(+), 15 deletions(-) diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 9bddc23..f4a0383 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py @@ -16,6 +16,8 @@ import errno import oeqa.utils.ftools as ftools from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer from oeqa.utils.decorators import LogResults +from random import choice +import glob @LogResults class oeSelfTest(unittest.TestCase): @@ -29,9 +31,10 @@ class oeSelfTest(unittest.TestCase): self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") +self.machineinc_path = os.path.join(self.builddir, "conf/machine.inc") self.testlayer_path = oeSelfTest.testlayer_path self._extra_tear_down_commands = [] -self._track_for_cleanup = [self.testinc_path] +self._track_for_cleanup = [self.testinc_path, self.testinc_bblayers_path, self.machineinc_path] super(oeSelfTest, self).__init__(methodName) def setUp(self): @@ -47,11 +50,25 @@ class oeSelfTest(unittest.TestCase): for f in files: if f == 'test_recipe.inc': os.remove(os.path.join(root, f)) -try: -os.remove(self.testinc_bblayers_path) -except OSError as e: -if e.errno != errno.ENOENT: -raise + +for incl_file in [self.testinc_bblayers_path, self.machineinc_path]: +try: +os.remove(incl_file) +except OSError as e: +if e.errno != errno.ENOENT: +raise + +# Get CUSTOMMACHINE from env (set by --machine argument to oe-selftest) +custommachine = os.getenv('CUSTOMMACHINE') +if custommachine: +if custommachine == 'random': +machine = get_random_machine() +else: +machine = custommachine +machine_conf = 'MACHINE ??= "%s"\n' % machine +self.set_machine_config(machine_conf) +print 'MACHINE: %s' % machine + # tests might need their own setup # but if they overwrite this one they have to call # super each time, so let's give them an alternative @@ -99,11 +116,21 @@ class oeSelfTest(unittest.TestCase): self.log.debug("Writing to: %s\n%s\n" % (self.testinc_path, data)) ftools.write_file(self.testinc_path, data) +custommachine = os.getenv('CUSTOMMACHINE') +if custommachine and 'MACHINE' in data: +machine = get_bb_var('MACHINE') +self.log.warning('MACHINE overridden: %s' % machine) + # append to /conf/selftest.inc def append_config(self, data): self.log.debug("Appending to: %s\n%s\n" % (self.testinc_path, data)) ftools.append_file(self.testinc_path, data) +custommachine = os.getenv('CUSTOMMACHINE') +if custommachine and 'MACHINE' in data: +machine = get_bb_var('MACHINE') +self.log.warning('MACHINE overridden: %s' % machine) + # remove data from /conf/selftest.inc def remove_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_path, data)) @@ -151,3 +178,28 @@ class oeSelfTest(unittest.TestCase): def remove_bblayers_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data)) ftools.remove_from_file(self.testinc_bblayers_path, data) + +# write to /conf/machine.inc +def set_machine_config(self, data): +self.log.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data)) +ftools.write_file(self.ma
[OE-core] [PATCHv4 2/2] selftest: Added MACHINE = "qemux86" to tests that use runqemu
It makes sense for tests that use runqemu to have MACHINE set as qemu. This also avoid issues when running oe-selftest with --arch random/all option. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/devtool.py | 7 --- meta/lib/oeqa/selftest/imagefeatures.py | 9 ++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 0a44ae7..84665e4 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -875,10 +875,11 @@ class DevtoolTests(DevtoolBase): # Additionally we are testing build-time functionality as well, so # really this has to be done as an oe-selftest test. # + +features = 'MACHINE = "qemux86"\n' +self.write_config(features) + # Check preconditions -machine = get_bb_var('MACHINE') -if not machine.startswith('qemu'): -self.skipTest('This test only works with qemu machines') if not os.path.exists('/etc/runqemu-nosudo'): self.skipTest('You must set up tap devices with scripts/runqemu-gen-tapdevs before running this test') result = runCmd('PATH="$PATH:/sbin:/usr/sbin" ip tuntap show', ignore_status=True) diff --git a/meta/lib/oeqa/selftest/imagefeatures.py b/meta/lib/oeqa/selftest/imagefeatures.py index 4efb0d9..62ddc52 100644 --- a/meta/lib/oeqa/selftest/imagefeatures.py +++ b/meta/lib/oeqa/selftest/imagefeatures.py @@ -22,7 +22,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh empty-root-password allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -48,7 +49,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' +features = 'MACHINE = "qemux86"\n' +features += 'EXTRA_IMAGE_FEATURES = "ssh-server-openssh allow-empty-password"\n' features += 'INHERIT += "extrausers"\n' features += 'EXTRA_USERS_PARAMS = "useradd -p \'\' {}; usermod -s /bin/sh {};"'.format(self.test_user, self.test_user) self.write_config(features) @@ -77,7 +79,8 @@ class ImageFeatures(oeSelfTest): AutomatedBy: Daniel Istrate """ -features = 'PREFERRED_VERSION_rpm = "4.%"\n' +features = 'MACHINE = "qemux86"\n' +features += 'PREFERRED_VERSION_rpm = "4.%"\n' features += 'PREFERRED_VERSION_rpm-native = "4.%"\n' # Use openssh in IMAGE_INSTALL instead of ssh-server-openssh in EXTRA_IMAGE_FEATURES as a workaround for bug 8047 features += 'IMAGE_INSTALL_append = " openssh"\n' -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oe-selftest: Improved --list-classes when determining test names
--list-classes does a weak validation when determining test names: (if method.startswith("test_") which could report any class attribute that starts with 'test_' as a valid test case. This fix checks that the class attribute that starts with 'test_' is also callable (is a method). Fix for [YOCTO #8862] Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 08a5af3..65d6b5e 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -404,7 +404,7 @@ def main(): if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest: print " --", v for method in dir(t): -if method.startswith("test_"): +if method.startswith("test_") and hasattr(vars(t)[method], '__call__'): print " -- --", method except (AttributeError, ImportError) as e: -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] selftest: moved tc test_buildhistory_does_not_change_signatures
Moved test_buildhistory_does_not_change_signatures from buildhistory/BuildhistoryBase to buildoptions/BuildhistoryTests. The test being in the base class was causing it to run multiple times. Fix for [YOCTO #8867] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildhistory.py | 64 ++ meta/lib/oeqa/selftest/buildoptions.py | 64 ++ 2 files changed, 66 insertions(+), 62 deletions(-) diff --git a/meta/lib/oeqa/selftest/buildhistory.py b/meta/lib/oeqa/selftest/buildhistory.py index e8aa05d..38bcd72 100644 --- a/meta/lib/oeqa/selftest/buildhistory.py +++ b/meta/lib/oeqa/selftest/buildhistory.py @@ -42,65 +42,5 @@ class BuildhistoryBase(oeSelfTest): else: self.assertEqual(result.status, 0, msg="Command 'bitbake %s' has failed unexpectedly: %s" % (target, result.output)) -@testcase(1386) -def test_buildhistory_does_not_change_signatures(self): -""" -Summary: Ensure that buildhistory does not change signatures -Expected:Only 'do_rootfs' and 'do_build' tasks are rerun - Product: oe-core -Author: Daniel Istrate -AutomatedBy: Daniel Istrate -""" - -tmpdir1_name = 'tmpsig1' -tmpdir2_name = 'tmpsig2' -builddir = os.environ.get('BUILDDIR') -tmpdir1 = os.path.join(builddir, tmpdir1_name) -tmpdir2 = os.path.join(builddir, tmpdir2_name) - -self.track_for_cleanup(tmpdir1) -self.track_for_cleanup(tmpdir2) - -features = 'TMPDIR = "%s"\n' % tmpdir1 -self.write_config(features) -bitbake('core-image-sato -S none') - -features = 'TMPDIR = "%s"\n' % tmpdir2 -features += 'INHERIT += "buildhistory"\n' -self.write_config(features) -bitbake('core-image-sato -S none') - -def get_files(d): -f = [] -for root, dirs, files in os.walk(d): -for name in files: -f.append(os.path.join(root, name)) -return f - -files1 = get_files(tmpdir1 + '/stamps') -files2 = get_files(tmpdir2 + '/stamps') -files2 = [x.replace(tmpdir2_name, tmpdir1_name) for x in files2] - -f1 = set(files1) -f2 = set(files2) -sigdiff = f1 - f2 - -self.assertEqual(len(sigdiff), 2, 'Expected 2 signature differences. Out: %s' % list(sigdiff)) - -unexpected_diff = [] - -# No new signatures should appear apart from do_rootfs and do_build -found_do_rootfs_flag = False -found_do_build_flag = False - -for sig in sigdiff: -if 'do_rootfs' in sig: -found_do_rootfs_flag = True -elif 'do_build' in sig: -found_do_build_flag = True -else: -unexpected_diff.append(sig) - -self.assertTrue(found_do_rootfs_flag, 'Task do_rootfs did not rerun.') -self.assertTrue(found_do_build_flag, 'Task do_build did not rerun') -self.assertFalse(unexpected_diff, 'Found unexpected signature differences. Out: %s' % unexpected_diff) +# 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 index acf481f..64ced15 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -118,6 +118,70 @@ class BuildhistoryTests(BuildhistoryBase): 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) +@testcase(1386) +def test_buildhistory_does_not_change_signatures(self): +""" +Summary: Ensure that buildhistory does not change signatures +Expected:Only 'do_rootfs' and 'do_build' tasks are rerun +Product: oe-core +Author: Daniel Istrate +AutomatedBy: Daniel Istrate +""" + +tmpdir1_name = 'tmpsig1' +tmpdir2_name = 'tmpsig2' +builddir = os.environ.get('BUILDDIR') +tmpdir1 = os.path.join(builddir, tmpdir1_name) +tmpdir2 = os.path.join(builddir, tmpdir2_name) + +self.track_for_cleanup(tmpdir1) +self.track_for_cleanup(tmpdir2) + +features = 'TMPDIR = "%s"\n' % tmpdir1 +self.write_config(
[OE-core] [PATCHv2] oe-selftest: Improved --list-classes when determining test names
--list-classes does a weak validation when determining test names: (if method.startswith("test_") which could report any class attribute that starts with 'test_' as a valid test case. This fix checks that the class attribute that starts with 'test_' is also callable (is a method). Fix for [YOCTO #8862] Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 08a5af3..1aee057 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -404,7 +404,7 @@ def main(): if isinstance(t, type(oeSelfTest)) and issubclass(t, oeSelfTest) and t!=oeSelfTest: print " --", v for method in dir(t): -if method.startswith("test_"): +if method.startswith("test_") and callable(vars(t)[method]): print " -- --", method except (AttributeError, ImportError) as e: -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oe-selftest: New option --list-tests
This option will list all available tests in a comprehensive manner. Fix for [YOCTO #8868] Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 21 + 1 file changed, 21 insertions(+) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 08a5af3..113daf6 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -82,6 +82,8 @@ def get_args_parser(): help='run-tests-by ') group.add_argument('--list-tests-by', required=False, dest='list_tests_by', default=False, nargs='*', help='list-tests-by ') +group.add_argument('--list-tests', required=False, action="store_true", dest="list_tests", default=False, + help='List all available tests.') group.add_argument('--list-tags', required=False, dest='list_tags', default=False, action="store_true", help='List all tags that have been set to test cases.') return parser @@ -333,6 +335,22 @@ def list_testsuite_by(criteria, keyword): print 'Total found:\t %s' % len(ts) +def list_tests(): +# List all available oe-selftest tests + +ts = get_all_tests() + +print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module') +print '_' * 150 +for t in ts: +if isinstance(t.tctag, (tuple, list)): +print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t.tcid, ', '.join(t.tctag), t.tcname, t.tcclass, t.tcmodule) +else: +print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t.tcid, t.tctag, t.tcname, t.tcclass, t.tcmodule) +print '_' * 150 +print 'Total found:\t %s' % len(ts) + + def list_tags(): # Get all tags set to test cases # This is useful when setting tags to test cases @@ -380,6 +398,9 @@ def main(): keyword = args.list_tests_by[1:] list_testsuite_by(criteria, keyword) +if args.list_tests: +list_tests() + if args.list_tags: list_tags() -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] selftest: Added testcase decorators for 2 tests
1391 for test_devtool_add_fetch_simple from devtool 1392 for test_recipetool_create_simple from recipetool Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/devtool.py| 1 + meta/lib/oeqa/selftest/recipetool.py | 1 + 2 files changed, 2 insertions(+) diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 1eadd6b..f6471bd 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -333,6 +333,7 @@ class DevtoolTests(DevtoolBase): checkvars['SRCREV'] = checkrev self._test_recipe_contents(recipefile, checkvars, []) +@testcase(1391) def test_devtool_add_fetch_simple(self): # Fetch source from a remote URL, auto-detecting name tempdir = tempfile.mkdtemp(prefix='devtoolqa') diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py index 00f415b..6a7ef9d 100644 --- a/meta/lib/oeqa/selftest/recipetool.py +++ b/meta/lib/oeqa/selftest/recipetool.py @@ -401,6 +401,7 @@ class RecipetoolTests(RecipetoolBase): inherits = ['autotools', 'pkgconfig'] self._test_recipe_contents(recipefile, checkvars, inherits) +@testcase(1392) def test_recipetool_create_simple(self): # Try adding a recipe temprecipe = os.path.join(self.tempdir, 'recipe') -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv5] scripts/oe-selftest: Allow to run tests on random/all MACHINEs
Add an option for random MACHINE into oe-selftest: --machine [random/all] 1. random: will set a random MACHINE for each test 2. all: will run tests for all machines Custom machine sets only weak default values (??=) for MACHINE in machine.inc. This let test cases that require a specific MACHINE to be able to override it, using (?= or =). e.g.: oe-selftest --run-tests signing --machine random --> will run all tests switching MACHINE randomly for each test oe-selftest --run-tests signing --machine all --> for each machine will run all tests oe-selftest --run-all-tests --machine random Also update oeqa/selftest/base.py to accomodate this feature. Fix for [YOCTO #5880]. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/base.py | 64 ++ scripts/oe-selftest| 37 ++-- 2 files changed, 86 insertions(+), 15 deletions(-) diff --git a/meta/lib/oeqa/selftest/base.py b/meta/lib/oeqa/selftest/base.py index 9bddc23..dc93731 100644 --- a/meta/lib/oeqa/selftest/base.py +++ b/meta/lib/oeqa/selftest/base.py @@ -16,6 +16,8 @@ import errno import oeqa.utils.ftools as ftools from oeqa.utils.commands import runCmd, bitbake, get_bb_var, get_test_layer from oeqa.utils.decorators import LogResults +from random import choice +import glob @LogResults class oeSelfTest(unittest.TestCase): @@ -29,9 +31,10 @@ class oeSelfTest(unittest.TestCase): self.testinc_path = os.path.join(self.builddir, "conf/selftest.inc") self.local_bblayers_path = os.path.join(self.builddir, "conf/bblayers.conf") self.testinc_bblayers_path = os.path.join(self.builddir, "conf/bblayers.inc") +self.machineinc_path = os.path.join(self.builddir, "conf/machine.inc") self.testlayer_path = oeSelfTest.testlayer_path self._extra_tear_down_commands = [] -self._track_for_cleanup = [self.testinc_path] +self._track_for_cleanup = [self.testinc_path, self.testinc_bblayers_path, self.machineinc_path] super(oeSelfTest, self).__init__(methodName) def setUp(self): @@ -47,11 +50,25 @@ class oeSelfTest(unittest.TestCase): for f in files: if f == 'test_recipe.inc': os.remove(os.path.join(root, f)) -try: -os.remove(self.testinc_bblayers_path) -except OSError as e: -if e.errno != errno.ENOENT: -raise + +for incl_file in [self.testinc_bblayers_path, self.machineinc_path]: +try: +os.remove(incl_file) +except OSError as e: +if e.errno != errno.ENOENT: +raise + +# Get CUSTOMMACHINE from env (set by --machine argument to oe-selftest) +custommachine = os.getenv('CUSTOMMACHINE') +if custommachine: +if custommachine == 'random': +machine = get_random_machine() +else: +machine = custommachine +machine_conf = 'MACHINE ??= "%s"\n' % machine +self.set_machine_config(machine_conf) +print 'MACHINE: %s' % machine + # tests might need their own setup # but if they overwrite this one they have to call # super each time, so let's give them an alternative @@ -99,11 +116,21 @@ class oeSelfTest(unittest.TestCase): self.log.debug("Writing to: %s\n%s\n" % (self.testinc_path, data)) ftools.write_file(self.testinc_path, data) +custommachine = os.getenv('CUSTOMMACHINE') +if custommachine and 'MACHINE' in data: +machine = get_bb_var('MACHINE') +self.log.warning('MACHINE overridden: %s' % machine) + # append to /conf/selftest.inc def append_config(self, data): self.log.debug("Appending to: %s\n%s\n" % (self.testinc_path, data)) ftools.append_file(self.testinc_path, data) +custommachine = os.getenv('CUSTOMMACHINE') +if custommachine and 'MACHINE' in data: +machine = get_bb_var('MACHINE') +self.log.warning('MACHINE overridden: %s' % machine) + # remove data from /conf/selftest.inc def remove_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_path, data)) @@ -151,3 +178,28 @@ class oeSelfTest(unittest.TestCase): def remove_bblayers_config(self, data): self.log.debug("Removing from: %s\n\%s\n" % (self.testinc_bblayers_path, data)) ftools.remove_from_file(self.testinc_bblayers_path, data) + +# write to /conf/machine.inc +def set_machine_config(self, data): +self.log.debug("Writing to: %s\n%s\n" % (self.machineinc_path, data)) +ftools.write_file(self.m
[OE-core] [PATCH] oeqa/selftest/signing: Added test for locked signatures
fix for [YOCTO #8706] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/signing.py | 48 +++ 1 file changed, 48 insertions(+) diff --git a/meta/lib/oeqa/selftest/signing.py b/meta/lib/oeqa/selftest/signing.py index c402e37..1e710e3 100644 --- a/meta/lib/oeqa/selftest/signing.py +++ b/meta/lib/oeqa/selftest/signing.py @@ -6,6 +6,7 @@ import re import shutil import tempfile from oeqa.utils.decorators import testcase +from oeqa.utils.ftools import write_file class Signing(oeSelfTest): @@ -130,3 +131,50 @@ class Signing(oeSelfTest): # gpg: Good signature from "testuser (nocomment) " self.assertIn('gpg: Good signature from', ret.output, 'Package signed incorrectly.') + +class LockedSignatures(oeSelfTest): + +@testcase(1420) +def test_locked_signatures(self): +""" +Summary: Test locked signature mechanism +Expected:Locked signatures will prevent task to run + Product: oe-core +Author: Daniel Istrate +AutomatedBy: Daniel Istrate +""" + +test_recipe = 'ed' +locked_sigs_file = 'locked-sigs.inc' + +self.add_command_to_tearDown('rm -f %s' % os.path.join(self.builddir, locked_sigs_file)) + +bitbake(test_recipe) +# Generate locked sigs include file +bitbake('-S none %s' % test_recipe) + +feature = 'require %s\n' % locked_sigs_file +feature += 'SIGGEN_LOCKEDSIGS_CHECK_LEVEL = "warn"\n' +self.write_config(feature) + +# Build a locked recipe +bitbake(test_recipe) + +# Make a change that should cause the locked task signature to change +recipe_append_file = test_recipe + '_' + get_bb_var('PV', test_recipe) + '.bbappend' +recipe_append_path = os.path.join(self.testlayer_path, 'recipes-test', test_recipe, recipe_append_file) +feature = 'SUMMARY += "test locked signature"\n' + +os.mkdir(os.path.join(self.testlayer_path, 'recipes-test', test_recipe)) +write_file(recipe_append_path, feature) + +self.add_command_to_tearDown('rm -rf %s' % os.path.join(self.testlayer_path, 'recipes-test', test_recipe)) + +# Build the recipe again +ret = bitbake(test_recipe) + +# Verify you get the warning and that the real task *isn't* run (i.e. the locked signature has worked) +patt = r'WARNING: The %s:do_package sig \S+ changed, use locked sig \S+ to instead' % test_recipe +found_warn = re.search(patt, ret.output) + +self.assertIsNotNone(found_warn, "Didn't find the expected warning message. Output: %s" % ret.output) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/buildoptions: Test build does not fail without git rev
Test that layer git revisions are displayed and do not fail without git repository. fix for [YOCTO #8852] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildoptions.py | 32 +++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 6167fb2..80b59bd 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -1,7 +1,7 @@ import os import re import glob as g - +import shutil from oeqa.selftest.base import oeSelfTest from oeqa.selftest.buildhistory import BuildhistoryBase from oeqa.utils.commands import runCmd, bitbake, get_bb_var @@ -103,6 +103,36 @@ class SanityOptionsTest(oeSelfTest): self.assertTrue("WARNING: QA Issue: gzip" in res.output, "WARNING: QA Issue: gzip message is not present in bitbake's output: %s" % res.output) self.assertTrue("WARNING: QA Issue: nfs-utils" in res.output, "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output) +@testcase(1421) +def test_layer_git_revisions_are_displayed_and_do_not_fail_without_git_repo(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 +""" + +test_recipe = 'ed' +corebase = get_bb_var('COREBASE') +git_dir = os.path.join(corebase, '.git') +git_dir_tmp = os.path.join(corebase, '.git_tmp') + +bitbake('-n %s' % test_recipe) +shutil.move(git_dir, git_dir_tmp) + +self.add_command_to_tearDown('mv %s %s' % (git_dir_tmp, git_dir)) + +ret = bitbake('-n %s' % test_recipe) + +patt = r'fatal: Not a git repository \(or any parent up to mount point /home\)\n' \ + r'Stopping at filesystem boundary \(GIT_DISCOVERY_ACROSS_FILESYSTEM not set\)\.' + +found_err = re.search(patt, ret.output) + +self.assertIsNone(found_err, 'Fatal errors found. Output: %s' % ret.output) + + class BuildhistoryTests(BuildhistoryBase): @testcase(293) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/bbtests: Test bitbake --setscene-only option
Bitbake option to restore from sstate only within a build (i.e. execute no real tasks, only setscene) fix for [YOCTO #8876] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/bbtests.py | 14 ++ 1 file changed, 14 insertions(+) diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py index 42ae9d0..b581b2b 100644 --- a/meta/lib/oeqa/selftest/bbtests.py +++ b/meta/lib/oeqa/selftest/bbtests.py @@ -232,3 +232,17 @@ SSTATE_DIR = \"${TOPDIR}/download-selftest\" self.assertEqual(result.status, 0, "Bitbake failed, exit code %s, output %s" % (result.status, result.output)) self.assertFalse(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/generic_GPLv3'))) self.assertTrue(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/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' % task) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv2] oeqa/selftest/bbtests: Test bitbake --setscene-only option
Bitbake option to restore from sstate only within a build (i.e. execute no real tasks, only setscene) fix for [YOCTO #8876] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/bbtests.py | 15 +++ 1 file changed, 15 insertions(+) diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py index 42ae9d0..70e5b29 100644 --- a/meta/lib/oeqa/selftest/bbtests.py +++ b/meta/lib/oeqa/selftest/bbtests.py @@ -232,3 +232,18 @@ SSTATE_DIR = \"${TOPDIR}/download-selftest\" self.assertEqual(result.status, 0, "Bitbake failed, exit code %s, output %s" % (result.status, result.output)) self.assertFalse(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/generic_GPLv3'))) self.assertTrue(os.path.isfile(os.path.join(self.builddir, 'tmp/deploy/licenses/readline/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))) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oeqa/selftest/bbtests: Test bbappend order
BitBake should append to recipe in a predictable order. fix for [YOCTO #9145] test for [YOCTO #9138] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/bbtests.py | 23 +++ 1 file changed, 23 insertions(+) diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py index 70e5b29..26728a4 100644 --- a/meta/lib/oeqa/selftest/bbtests.py +++ b/meta/lib/oeqa/selftest/bbtests.py @@ -247,3 +247,26 @@ SSTATE_DIR = \"${TOPDIR}/download-selftest\" 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' +test_recipe_summary_before = get_bb_var('SUMMARY', test_recipe) +test_recipe_pv = get_bb_var('PV', test_recipe) +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) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 8/9] oeqa/utils/commands: Added method - get_all_bbappends
This method runs 'bitbake-layers show-appends' and returns a dictionary {recipe: [bbappends], ..} Signed-off-by: Daniel Istrate --- meta/lib/oeqa/utils/commands.py | 22 ++ 1 file changed, 22 insertions(+) diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 6ae09d2..8fdb80d 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -184,6 +184,28 @@ def get_tasks_for_recipe(recipe): return tasks +def get_all_bbappends(): +""" Get all bbappends (bitbake-layers show-appends) +:return:a dict with {recipe: [bbappends]} +""" +ret_dict = {} +ret = runCmd('bitbake-layers show-appends') + +for line in ret.output.splitlines(): +bb = re.findall('^(\S+\.bb.*):', line) +bbappend = re.findall('^\s+(\S+\.bbappend)', line) +if bb: +key = bb[0] +value_list = [] +continue +if bbappend: +value = bbappend[0] +value_list.append(value) +ret_dict[key] = value_list +continue + +return ret_dict + def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec='recipes-*/*'): os.makedirs(os.path.join(templayerdir, 'conf')) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 6/9] recipetests: base - Base Class for Test Recipes
Test Recipes should inherit this class. It sets up a custom tmp dir for the recipe under test. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/recipetests/base.py | 25 + 1 file changed, 25 insertions(+) create mode 100644 meta/lib/oeqa/recipetests/base.py diff --git a/meta/lib/oeqa/recipetests/base.py b/meta/lib/oeqa/recipetests/base.py new file mode 100644 index 000..148c123 --- /dev/null +++ b/meta/lib/oeqa/recipetests/base.py @@ -0,0 +1,25 @@ +import os +import shutil +from oeqa.selftest.base import oeSelfTest +import oeqa.utils.ftools as ftools + + +class RecipeTests(oeSelfTest): + +def __init__(self, methodName="runTest"): +super(RecipeTests, self).__init__(methodName) +self.testinc_path = os.path.join(self.builddir, 'conf/testrecipe.inc') +self.required_path = os.path.join(self.builddir, 'conf/required.inc') +self.testrecipe = os.getenv("TESTRECIPE") + +# Use a clean TMPDIR for each run +tmpdir_name = self.builddir + '/tmp_' + self.testrecipe +shutil.rmtree(tmpdir_name, ignore_errors=True) + +feature = 'TMPDIR = "%s"\n' % tmpdir_name +self.set_required_config(feature) + +# write to /conf/requred.inc +def set_required_config(self, data): +self.log.debug("Writing to: %s\n%s\n" % (self.required_path, data)) +ftools.write_file(self.required_path, data) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 1/9] selftest: Moved method from oe-selftest to oeqa/runner.py
Moved methods to runner and added parameters to them in order for them to be used by other runners. Signed-off-by: Daniel Istrate --- meta/lib/oeqa/runner.py | 344 scripts/oe-selftest | 325 +++-- 2 files changed, 359 insertions(+), 310 deletions(-) create mode 100644 meta/lib/oeqa/runner.py diff --git a/meta/lib/oeqa/runner.py b/meta/lib/oeqa/runner.py new file mode 100644 index 000..ccb1e3b --- /dev/null +++ b/meta/lib/oeqa/runner.py @@ -0,0 +1,344 @@ +import os +import logging +import sys +import time +import oeqa.utils.ftools as ftools +from oeqa.utils.commands import bitbake, get_bb_var, get_test_layer + + +class Tc: +""" Holds information about test cases """ + +def __init__(self, tcname, tcclass, tcmodule, tcid=None, tctag=None): +self.tcname = tcname +self.tcclass = tcclass +self.fullpath = '.'.join([tcmodule, tcclass, tcname]) +# Trim prefix from tcmodule +self.tcmodule = tcmodule.split('.')[-1] +self.tcid = tcid +# A test case can have multiple tags (as tuples) otherwise str will suffice +self.tctag = tctag + + +class Runner: + +def __init__(self, caller, base_class, test_mod_dir): +""" +:param caller: eg. selftest, test-recipe (log files will use this name) +:param base_class: eg. oeSelfTest, RecipeTests +:param test_mod_dir: eg oeqa.selftest, oeqa.recipetests +""" + +self.caller = caller +self.base_class = base_class +self.test_mod_dir = test_mod_dir +self.log = self.logger_create(self.caller) +self.builddir = os.environ.get("BUILDDIR") + +def logger_create(self, log_name): +""" Create logger obj with logging file as and symlink to it as """ + +log_link = '%s.log' % log_name +log_file = '%s-%s.log' % (log_name, time.strftime("%Y-%m-%d_%H:%M:%S")) + +if os.path.exists(log_link): +os.remove(log_link) +os.symlink(log_file, log_link) + +log = logging.getLogger(log_name) +log.setLevel(logging.DEBUG) + +fh = logging.FileHandler(filename=log_file, mode='w') +fh.setLevel(logging.DEBUG) + +ch = logging.StreamHandler(sys.stdout) +ch.setLevel(logging.INFO) + +formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s', "%Y-%m-%d %H:%M:%S") +fh.setFormatter(formatter) +ch.setFormatter(formatter) + +log.addHandler(fh) +log.addHandler(ch) + +return log + +def preflight_check(self): +""" Check that the environment is sourced, meta-selftest included in bblayers and current dir is BUILDDIR """ + +self.log.info("Checking that everything is in order before running the tests") + +if not self.builddir: +self.log.error("BUILDDIR isn't set. Did you forget to source your build environment setup script?") +return False + +if os.getcwd() != self.builddir: +self.log.info("Changing cwd to %s" % self.builddir) +os.chdir(self.builddir) + +if "meta-selftest" not in get_bb_var("BBLAYERS"): +self.log.error("You don't seem to have the meta-selftest layer in BBLAYERS") +return False + +self.log.info("Running bitbake -p") +bitbake("-p") + +return True + +def add_include(self, include_files, include_to): +""" Include in include_to (local.conf, bblayers.conf) the specified files """ + +include_msg_header = "# include added by %s\n" % self.caller +include_msg = include_msg_header +if isinstance(include_files, (list, tuple)): +for f in include_files: +include_msg += 'include %s\n' % f +else: +include_msg += 'include %s\n' % include_files + +if include_msg_header not in ftools.read_file(os.path.join(self.builddir, 'conf', include_to)): +self.log.info("Adding: %s in %s" % (include_files, include_to)) +ftools.append_file(os.path.join(self.builddir, 'conf', include_to), include_msg) + +def remove_include(self, remove_files, remove_from): +""" Remove from remove_from (local.conf, bblayers.conf) the specified files """ + +if self.builddir is None: +return + +remove_msg_header = "# include added by %s\n" % self.caller +remove_msg = remove_msg_header +if isinstance(remov
[OE-core] [PATCH 4/9] oeqa/utils/commands: Added 3 new methods for recipes
get_all_available_recipes, is_recipe_valid, get_tasks_for_recipe Signed-off-by: Daniel Istrate --- meta/lib/oeqa/utils/commands.py | 20 1 file changed, 20 insertions(+) diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py index 32e001c..6ae09d2 100644 --- a/meta/lib/oeqa/utils/commands.py +++ b/meta/lib/oeqa/utils/commands.py @@ -165,6 +165,26 @@ def get_test_layer(): break return testlayer + +def get_all_available_recipes(): +ret = bitbake('-s') +available_recipes = re.findall(r'\n(\S+)\s+:', ret.output) + +return available_recipes + + +def is_recipe_valid(recipe): +return recipe in get_all_available_recipes() + + +def get_tasks_for_recipe(recipe): +""" Get available tasks for recipe """ +ret = bitbake('-c listtasks %s' % recipe) +tasks = re.findall(':\s+do_(\S+)\s+', ret.output) + +return tasks + + def create_temp_layer(templayerdir, templayername, priority=999, recipepathspec='recipes-*/*'): os.makedirs(os.path.join(templayerdir, 'conf')) with open(os.path.join(templayerdir, 'conf', 'layer.conf'), 'w') as f: -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 9/9] recipetests: buildrecipe: Test combinations of bbappend
Selectively use each combination of .bbappend files with the recipe; All the combinations should not break the recipe build Signed-off-by: Daniel Istrate --- meta/lib/oeqa/recipetests/buildrecipe.py | 59 +++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/recipetests/buildrecipe.py b/meta/lib/oeqa/recipetests/buildrecipe.py index c303b29..900d042 100644 --- a/meta/lib/oeqa/recipetests/buildrecipe.py +++ b/meta/lib/oeqa/recipetests/buildrecipe.py @@ -1,7 +1,9 @@ from oeqa.recipetests.base import RecipeTests from oeqa.selftest.base import get_available_machines -from oeqa.utils.commands import bitbake, get_tasks_for_recipe +from oeqa.utils.commands import bitbake, get_tasks_for_recipe, get_bb_var, ftools, get_all_bbappends import logging +import os +import random class BuildRecipeTests(RecipeTests): @@ -60,3 +62,58 @@ class BuildRecipeTests(RecipeTests): # Force task on recipe self.log.info('Forcing task %s' % task) bitbake('-C %s %s' % (task, self.testrecipe)) + +def test_combinations_of_bbappend(self): +""" Selectively use each combination of .bbappend files with the recipe """ + +test_recipe_pv = get_bb_var('PV', self.testrecipe) +recipe_append_file = self.testrecipe + '_' + test_recipe_pv + '.bbappend' + +bbappend_msgs = {1: 'msg 1', 2: 'msg 2', 3: 'msg 3', 4: 'msg 4'} +bbappend_files = {} + +# Install all bbappends for recipe +for i in bbappend_msgs: +recipe_append_dir = self.testrecipe + '_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' % bbappend_msgs[i] +ftools.write_file(recipe_append_path, feature) +bbappend_files[i] = recipe_append_path + +self.add_command_to_tearDown('rm -rf %s' % os.path.join(self.testlayer_path, 'recipes-test', + self.testrecipe + '_test_*')) + +test_recipe_bb = '%s_%s.bb' % (self.testrecipe, test_recipe_pv) +all_bbappends = get_all_bbappends() +self.log.info('All bbappends for recipe %s: %s' % (self.testrecipe, all_bbappends.get(test_recipe_bb))) + +# Build recipe with all bbappends +bitbake(self.testrecipe) + +# Mask two random bbappends (some times it might be the same one, which is ok) +for i in range(len(bbappend_files)): +choice1 = random.choice(bbappend_msgs.keys()) +choice2 = random.choice(bbappend_msgs.keys()) +mask1 = bbappend_files.get(choice1) +mask2 = bbappend_files.get(choice2) + +feature = 'BBMASK = "%s"\n' % mask1 +feature += 'BBMASK += "%s"\n' % mask2 +self.write_config(feature) +self.log.info('Applied MASKs [%s, %s]' % (mask1, mask2)) + +# Make sure the masked bbappends don't show up +current_bbappends = get_all_bbappends() +self.log.info('Current bbappends for recipe %s: %s' % (self.testrecipe, current_bbappends.get(test_recipe_bb))) +self.assertNotIn(mask1, current_bbappends.get(test_recipe_bb)) +self.assertNotIn(mask2, current_bbappends.get(test_recipe_bb)) + +# Make sure the summary was updated +current_summary = get_bb_var('SUMMARY', self.testrecipe) +self.log.info('Current summary: "%s"' % current_summary) +self.assertNotIn(bbappend_msgs.get(choice1), current_summary) +self.assertNotIn(bbappend_msgs.get(choice2), current_summary) + +# Build recipe with custom bbappends +bitbake(self.testrecipe) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 7/9] recipetests: buildrecipe: Test suite for recipe tests
Includes tests for: 1. test build recipe for all major architectures 2. test rebuild recipe from sstate 1 (with sstate) 3. test_rebuild_recipe_from_sstate_2 (without sstate) 4. test cleaning operations on recipe 5. test force major tasks on recipe fix for [YOCTO #6370] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/recipetests/buildrecipe.py | 62 1 file changed, 62 insertions(+) create mode 100644 meta/lib/oeqa/recipetests/buildrecipe.py diff --git a/meta/lib/oeqa/recipetests/buildrecipe.py b/meta/lib/oeqa/recipetests/buildrecipe.py new file mode 100644 index 000..c303b29 --- /dev/null +++ b/meta/lib/oeqa/recipetests/buildrecipe.py @@ -0,0 +1,62 @@ +from oeqa.recipetests.base import RecipeTests +from oeqa.selftest.base import get_available_machines +from oeqa.utils.commands import bitbake, get_tasks_for_recipe +import logging + + +class BuildRecipeTests(RecipeTests): + +log = logging.getLogger('test-recipe.build-recipe') + +def test_build_recipe_for_all_major_architectures(self): +""" Build the recipe with all major architectures(qemux86, qemux86-64, qemuarm, qemuppc, qemumips) """ + +machines = get_available_machines() +qemu_machines = [m for m in machines if 'qemu' in m] + +# Build the recipe for all major architectures +for m in qemu_machines: +self.log.info('Building recipe "%s" for architecture "%s"' % (self.testrecipe, m)) +self.write_config('MACHINE = "%s"' % m) +bitbake(self.testrecipe) + +def test_rebuild_recipe_from_sstate_1(self): +""" Rebuild the recipe from sstate with sstate file for the recipe """ +bitbake(self.testrecipe) +bitbake('-c clean %s' % self.testrecipe) +bitbake(self.testrecipe) + +def test_rebuild_recipe_from_sstate_2(self): +""" Rebuild the recipe from sstate without sstate file for the recipe """ +bitbake(self.testrecipe) +bitbake('-c cleansstate %s' % self.testrecipe) +bitbake(self.testrecipe) + +def test_cleaning_operations_on_recipe(self): +""" Perform cleaning operations on the recipe(cleansstate, clean, cleanall) """ + +clean_tasks = ['cleansstate', 'clean', 'cleanall'] + +for task in clean_tasks: +bitbake(self.testrecipe) +self.log.info('Performing %s for recipe %s' % (task, self.testrecipe)) +bitbake('-c %s %s' % (task, self.testrecipe)) + +def test_force_major_tasks_on_recipe(self): +""" Force all major tasks on the recipe (bitbake -C ) """ +major_tasks = ['unpack', 'patch', 'configure', 'compile', 'install', 'populate_sysroot', 'package', + 'package_write_rpm', 'package_write_deb', 'package_write_ipk'] + +feature = 'PACKAGE_CLASSES = "package_rpm package_deb package_ipk"\n' +self.write_config(feature) + +available_tasks = get_tasks_for_recipe(self.testrecipe) + +for task in major_tasks: +# Check if task is available for recipe +if task not in available_tasks: +self.log.warning('Task %s not available for recipe %s' % (task, self.testrecipe)) +continue +# Force task on recipe +self.log.info('Forcing task %s' % task) +bitbake('-C %s %s' % (task, self.testrecipe)) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 2/9] selftest: Moved coverage functionality from oe-selftest to oeqa/runner.py
Signed-off-by: Daniel Istrate --- meta/lib/oeqa/runner.py | 108 +++- scripts/oe-selftest | 106 +-- 2 files changed, 108 insertions(+), 106 deletions(-) diff --git a/meta/lib/oeqa/runner.py b/meta/lib/oeqa/runner.py index ccb1e3b..5bfd4d1 100644 --- a/meta/lib/oeqa/runner.py +++ b/meta/lib/oeqa/runner.py @@ -2,6 +2,7 @@ import os import logging import sys import time +import unittest import oeqa.utils.ftools as ftools from oeqa.utils.commands import bitbake, get_bb_var, get_test_layer @@ -35,7 +36,8 @@ class Runner: self.log = self.logger_create(self.caller) self.builddir = os.environ.get("BUILDDIR") -def logger_create(self, log_name): +@staticmethod +def logger_create(log_name): """ Create logger obj with logging file as and symlink to it as """ log_link = '%s.log' % log_name @@ -342,3 +344,107 @@ class Runner: print 'Looking for:\t %s' % ', '.join(str(x) for x in keyword) print 'Total found:\t %s' % len(ts) +@staticmethod +def coverage_setup(run_tests, run_all_tests): +""" Set up the coverage measurement for the testcases to be run """ +builddir = os.environ.get("BUILDDIR") +coveragerc = "%s/.coveragerc" % builddir +data_file = "%s/.coverage." % builddir +data_file += ((run_tests and '.'.join(run_tests)) or (run_all_tests and "all_tests") or "") +if os.path.isfile(data_file): +os.remove(data_file) +with open(coveragerc, 'w') as cps: +cps.write("[run]\n") +cps.write("data_file = %s\n" % data_file) +cps.write("branch = True\n") +# Measure just BBLAYERS, scripts and bitbake folders +cps.write("source = \n") +for layer in get_bb_var('BBLAYERS').split(): +cps.write("%s\n" % layer) +corebase = get_bb_var('COREBASE') +cps.write("%s\n" % os.path.join(corebase, 'scripts')) +cps.write("%s\n" % os.path.join(corebase, 'bitbake')) + +return coveragerc + +@staticmethod +def coverage_report(): +""" Loads the coverage data gathered and reports it back """ +try: +# Coverage4 uses coverage.Coverage +from coverage import Coverage +except: +# Coverage under version 4 uses coverage.coverage +from coverage import coverage as Coverage + +import cStringIO as StringIO +from coverage.misc import CoverageException + +cov_output = StringIO.StringIO() +# Creating the coverage data with the setting from the configuration file +cov = Coverage(config_file=os.environ.get('COVERAGE_PROCESS_START')) +try: +# Load data from the data file specified in the configuration +cov.load() +# Store report data in a StringIO variable +cov.report(file = cov_output, show_missing=False) +print "\n%s" % cov_output.getvalue() +except CoverageException as e: +# Show problems with the reporting. Since Coverage4 not finding any data to report raises an exception +print "%s" % str(e) +finally: +cov_output.close() + +@classmethod +def buildResultClass(cls, args): +"""Build a Result Class to use in the testcase execution""" + +class StampedResult(unittest.TextTestResult): +""" +Custom TestResult that prints the time when a test starts. As oe-selftest +can take a long time (ie a few hours) to run, timestamps help us understand +what tests are taking a long time to execute. +If coverage is required, this class executes the coverage setup and reporting. +""" +def startTest(self, test): +import time +self.stream.write(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + " - ") +super(StampedResult, self).startTest(test) + +def startTestRun(self): +""" Setup coverage before running any testcase """ +if args.coverage: +try: +# check if user can do coverage +import coverage +print "Coverage is enabled" + +# In case the user has not set the
[OE-core] [PATCH 3/9] selftest: Moved list_classes, list_modules, run methods to runner.py
Signed-off-by: Daniel Istrate --- meta/lib/oeqa/runner.py | 59 scripts/oe-selftest | 65 ++--- 2 files changed, 72 insertions(+), 52 deletions(-) diff --git a/meta/lib/oeqa/runner.py b/meta/lib/oeqa/runner.py index 5bfd4d1..e729478 100644 --- a/meta/lib/oeqa/runner.py +++ b/meta/lib/oeqa/runner.py @@ -344,6 +344,65 @@ class Runner: print 'Looking for:\t %s' % ', '.join(str(x) for x in keyword) print 'Total found:\t %s' % len(ts) +def list_modules(self): +""" List all available modules """ + +self.log.info('Listing all available test modules:') +testslist = self.get_tests(include_hidden=True) +for test in testslist: +module = test.split('.')[-1] +print module + ' (hidden)' if module.startswith('_') else module + +def list_all_classes(self): +""" List all tests with their corresponding class and module (Hierarchy format) """ + +testslist = self.get_tests(include_hidden=True) +for test in testslist: +module = test.split('.')[-1] +print module + ' (hidden)' if module.startswith('_') else module +try: +import importlib +modlib = importlib.import_module(test) +for v in vars(modlib): +t = vars(modlib)[v] +if isinstance(t, type(self.base_class)) and issubclass(t, self.base_class) and t != self.base_class: +print " --", v +for method in dir(t): +if method.startswith("test_") and callable(vars(t)[method]): +print " -- --", method + +except (AttributeError, ImportError) as e: +print e +pass + +def run(self, testlist, args): +""" +:param testlist: ['oeqa.selftest.archiver', 'oeqa.selftest.bblayers', ..] +:param args: the args the calling script was invoked with (used by coverage) +""" + +suite = unittest.TestSuite() +loader = unittest.TestLoader() +loader.sortTestMethodsUsing = None +runner = unittest.TextTestRunner(verbosity=2, resultclass=self.buildResultClass(args)) + +for test in testlist: +self.log.info("Loading tests from: %s" % test) +try: +suite.addTests(loader.loadTestsFromName(test)) +except AttributeError as e: +self.log.error("Failed to import %s" % test) +self.log.error(e) +return 1 + +result = runner.run(suite) +self.log.info("Finished") + +if result.wasSuccessful(): +return 0 +else: +return 1 + @staticmethod def coverage_setup(run_tests, run_all_tests): """ Set up the coverage measurement for the testcases to be run """ diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 9f71154..ba73502 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -27,11 +27,6 @@ import os import sys -import unittest -import logging -import argparse -import subprocess -import time as t sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') import scriptpath @@ -40,8 +35,7 @@ scriptpath.add_oe_lib_path() import argparse_oe import oeqa.selftest -import oeqa.utils.ftools as ftools -from oeqa.utils.commands import runCmd, get_bb_var, get_test_layer +from oeqa.utils.commands import get_bb_var, get_test_layer from oeqa.selftest.base import oeSelfTest, get_available_machines from oeqa.runner import Runner @@ -102,40 +96,23 @@ def main(): criteria = args.list_tests_by[0] keyword = args.list_tests_by[1:] test_runner.list_testsuite_by(criteria, keyword) +return 0 if args.list_tests: test_runner.list_tests() +return 0 if args.list_tags: test_runner.list_tags() +return 0 if args.list_allclasses: -args.list_modules = True +test_runner.list_all_classes() +return 0 if args.list_modules: -log.info('Listing all available test modules:') -testslist = test_runner.get_tests(include_hidden=True) -for test in testslist: -module = test.split('.')[-1] -info = '' -if module.startswith('_'): -info = ' (hidden)' -print module + info -if args.list_allclasses: -
[OE-core] [PATCH 5/9] scripts: test-recipe Tool for running tests on recipes
It shares many functionality with oe-selftest. It requires an aditional argument --recipe in order to know on which recipe to test against. Test recipes should be located at: meta/lib/oeqa/recipetests/ Signed-off-by: Daniel Istrate --- scripts/test-recipe | 168 1 file changed, 168 insertions(+) create mode 100755 scripts/test-recipe diff --git a/scripts/test-recipe b/scripts/test-recipe new file mode 100755 index 000..3fe80a5 --- /dev/null +++ b/scripts/test-recipe @@ -0,0 +1,168 @@ +#!/usr/bin/env python + +# Copyright (c) 2016, Intel Corporation. +# All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2 as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +# DESCRIPTION: Will run recipe tests on each provided recipe. +# +# USAGE: recipe-test --recipes --run-all-tests +# +# OPTIONS: --recipes +# --list-tests +# --list-tests-by +# --run-all-tests +# --run-tests-by +# +# NOTE: tests are located in lib/oeqa/recipetests +# +# AUTHOR: Daniel Istrate +# + + +import sys +import os +import unittest + +sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') +import scriptpath +scriptpath.add_bitbake_lib_path() +scriptpath.add_oe_lib_path() +import argparse_oe + +import oeqa.recipetests +from oeqa.utils.commands import get_test_layer, get_bb_var, bitbake, is_recipe_valid +from oeqa.selftest.base import oeSelfTest +from oeqa.recipetests.base import RecipeTests + +from oeqa.runner import Runner + +test_runner = Runner('test-recipe', RecipeTests, oeqa.recipetests) +log = test_runner.log + + +def get_args_parser(): +description = 'Will run recipe tests on provided recipe.' +parser = argparse_oe.ArgumentParser(description=description) +group = parser.add_mutually_exclusive_group(required=True) +group.add_argument('--run-tests', required=False, action='store', nargs='*', dest="run_tests", default=None, + help='Select what tests to run (modules, classes or test methods). ' +'Format should be: ..') +group.add_argument('--run-all-tests', required=False, action="store_true", dest="run_all_tests", default=False, + help='Run all (unhidden) tests') +group.add_argument('--list-modules', required=False, action="store_true", dest="list_modules", default=False, + help='List all available test modules.') +group.add_argument('--list-classes', required=False, action="store_true", dest="list_allclasses", default=False, + help='List all available test classes.') +parser.add_argument('--coverage', action="store_true", help="Run code coverage when testing") +group.add_argument('--run-tests-by', required=False, dest='run_tests_by', default=False, nargs='*', + help='run-tests-by ') +group.add_argument('--list-tests-by', required=False, dest='list_tests_by', default=False, nargs='*', + help='list-tests-by ') +group.add_argument('--list-tests', required=False, action="store_true", dest="list_tests", default=False, + help='List all available tests.') +group.add_argument('--list-tags', required=False, dest='list_tags', default=False, action="store_true", + help='List all tags that have been set to test cases.') +parser.add_argument('-r', '--recipes', nargs='+', default=False, dest='recipes', +help='recipe(s) to run tests against.') +return parser + + +def main(): +parser = get_args_parser() +args = parser.parse_args() + +if args.list_tests: +test_runner.list_tests() +return 0 + +if args.list_tags: +test_runner.list_tags() +return 0 + +if args.list_allclasses: +test_runner.list_all_classes() +return 0 + +if args.list_modules: +test_ru
[OE-core] [PATCHv2] oeqa/selftest/buildoptions: Test build does not fail without git rev
Test that layer git revisions are displayed and do not fail without git repository. fix for [YOCTO #8852] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildoptions.py | 46 +- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index e2d12c3..693f069 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -1,7 +1,8 @@ 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 @@ -111,6 +112,49 @@ class SanityOptionsTest(oeSelfTest): line = self.getline(res, "QA Issue: nfs-utils") self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output) +@testcase(1421) +def test_layer_git_revisions_are_displayed_and_do_not_fail_without_git_repo(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' +dummy_layer_content += 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' +dummy_layer_content += 'BBFILE_COLLECTIONS += "%s"\n' % dummy_layer_name +dummy_layer_content += 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' % dummy_layer_name +dummy_layer_content += 'BBFILE_PRIORITY_%s = "6"\n' % 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) + +patt = r'fatal: Not a git repository \(or any parent up to mount point /\S+\)\n' \ + r'Stopping at filesystem boundary \(GIT_DISCOVERY_ACROSS_FILESYSTEM not set\)\.' + +found_err = re.search(patt, ret.output) + +shutil.rmtree(dirpath) + +self.assertIsNone(found_err, 'Fatal errors found. Output: %s' % ret.output) + + class BuildhistoryTests(BuildhistoryBase): @testcase(293) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv3] oeqa/selftest/buildoptions: Test build does not fail without git rev
Test that layer git revisions are displayed and do not fail without git repository. fix for [YOCTO #8852] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildoptions.py | 43 +- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index e2d12c3..ee2a101 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -1,7 +1,8 @@ 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 @@ -111,6 +112,46 @@ class SanityOptionsTest(oeSelfTest): line = self.getline(res, "QA Issue: nfs-utils") self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output) +@testcase(1421) +def test_layer_git_revisions_are_displayed_and_do_not_fail_without_git_repo(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' +dummy_layer_content += 'BBFILES += "${LAYERDIR}/recipes-*/*/*.bb ${LAYERDIR}/recipes-*/*/*.bbappend"\n' +dummy_layer_content += 'BBFILE_COLLECTIONS += "%s"\n' % dummy_layer_name +dummy_layer_content += 'BBFILE_PATTERN_%s = "^${LAYERDIR}/"\n' % dummy_layer_name +dummy_layer_content += 'BBFILE_PRIORITY_%s = "6"\n' % 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) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCHv4] oeqa/selftest/buildoptions: Test build does not fail without git rev
Test that layer git revisions are displayed and do not fail without git repository. fix for [YOCTO #8852] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildoptions.py | 43 +- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index e2d12c3..135514a 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -1,7 +1,8 @@ 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 @@ -111,6 +112,46 @@ class SanityOptionsTest(oeSelfTest): line = self.getline(res, "QA Issue: nfs-utils") self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output) +@testcase(1421) +def test_layer_git_revisions_are_displayed_and_do_not_fail_without_git_repo(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) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 2/3] selftest/buildoptions: Renamed one test case
'test_layer_git_revisions_are_displayed_and_do_not_fail_without_git_repo' was renamed to 'test_layer_without_git_dir' which is shorter. fix for [YOCTO #9243] Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildoptions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 1a427f1..491ce50 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -139,7 +139,7 @@ do_install_append_pn-gzip () { self.assertTrue(line and line.startswith("WARNING:"), "WARNING: QA Issue: nfs-utils message is not present in bitbake's output: %s" % res.output) @testcase(1421) -def test_layer_git_revisions_are_displayed_and_do_not_fail_without_git_repo(self): +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 -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH] oe-selftest: Fixed --list-tests-by tag option
Commit 35be67951305950ba797dc2efddbc7d88fc0556a broke the --list-tests-by tag option. This patch fixes that. Having a module in lib/oeqa/selftest named testmodule: class TestClass(oeSelfTest): @tag(feature='tag1') def test_func1(self): pass @tag(feature=('tag1', 'tag2')) def test_func2(self): pass @tag(feature=('tag2', 'tag3')) def test_func3(self): pass @tag(feature=('tag1', 'tag2', 'tag3')) def test_func4(self): pass $ oe-selftest --list-tests-by tag tag1 ID TAG(s)NAMECLASS MODULE -- - tag1 test_func1 TestClass testmodule tag1, tag2test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule __ Filtering by:tag Looking for: tag1 Total found: 3 $ oe-selftest --list-tests-by tag tag1 tag2 ID TAG(s)NAMECLASS MODULE -- - tag1 test_func1 TestClass testmodule tag1, tag2test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule tag2, tag3test_func3 TestClass testmodule __ Filtering by:tag Looking for: tag1, tag2 Total found: 4 $ oe-selftest --list-tests-by tag tag* ID TAG(s)NAMECLASS MODULE -- - tag1 test_func1 TestClass testmodule tag1, tag2test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule tag2, tag3test_func3 TestClass testmodule __ Filtering by:tag Looking for: tag* Total found: 4 Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 9444244..d18348d 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -32,6 +32,8 @@ import logging import argparse import subprocess import time as t +import re +import fnmatch sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') import scriptpath @@ -197,7 +199,7 @@ class Tc: self.tcclass = tcclass self.tcmodule = tcmodule self.tcid = tcid -# A test case can have multiple tags (as list or as tuples) otherwise str suffice +# A test case can have multiple tags (as tuples) otherwise str will suffice self.tctag = tctag self.fullpath = '.'.join(['oeqa', 'selftest', tcmodule, tcclass, tcname]) @@ -243,19 +245,17 @@ def get_all_tests(): testlist += get_tests_from_module(tmod) return testlist + def get_testsuite_by(criteria, keyword): # Get a testsuite based on 'keyword' # criteria: name, class, module, id, tag # keyword: a list of tests, classes, modules, ids, tags -import re -import fnmatch - ts = [] all_tests = get_all_tests() def get_matches(values): -# Get a items and return the ones that match with keyword(s) +# Get an item and return the ones that match with keyword(s) # values: the list of items (names, modules, classes...) result = [] remaining = values[:] @@ -267,9 +267,9 @@ def get_testsuite_by(criteria, keyword): else: # Wildcard matching pattern = re.compile(fnmatch.translate(r"%s" % key)) -added = [ x for x in remaining if pattern.match(x) ] +added = [x for x in remaining if pattern.match(x)] result.extend(added) -remaining = [ x for x in remaining if not x in added ] +remaining = [x for x in remaining if x not in added] return result @@ -292,14 +292,23 @@ def get_testsuite_by(criteria, keyword): elif criteria == 'tag': values = set() for tc in all_tests: -# tc can have multiple tags (as list or tuple) otherwise as str -if isinstance(tc.tctag, (list, tuple)): +# tc can have multiple tags (as tuple) otherwise str will suffice +if isinstance(tc.tctag, tuple): values |= { str(tag) for tag in tc.tctag } else: values.add(str(tc.tctag)) tags = get_matches(list(values)) -ts = [ tc for tc in all_tests if str(tc.tctag) in tags ] + +for tc in all_tests: +for tag in tags: +if isinstance(tc.tctag, tuple) and tag in tc.tctag: +ts.append(tc) +elif tag
[OE-core] [PATCH 1/3] oe-selftest: Updated --list-tests and --list-tests-by
The output table is now able to adjust it's size so the content is nicely aligned. fix for [YOCTO #9243] Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 34 +- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index 9444244..ada71d2 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -32,6 +32,7 @@ import logging import argparse import subprocess import time as t +from tabulate import tabulate sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') import scriptpath @@ -309,19 +310,22 @@ def list_testsuite_by(criteria, keyword): # criteria: name, class, module, id, tag # keyword: a list of tests, classes, modules, ids, tags -ts = sorted([ (tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword) ]) +ts = sorted([(tc.tcid, tc.tctag, tc.tcname, tc.tcclass, tc.tcmodule) for tc in get_testsuite_by(criteria, keyword)]) +test_list = [] -print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module') -print '_' * 150 for t in ts: if isinstance(t[1], (tuple, list)): -print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t[0], ', '.join(t[1]), t[2], t[3], t[4]) +test_list.append((t[0], ', '.join(t[1]), t[2], t[3], t[4])) else: -print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % t -print '_' * 150 +test_list.append(t) + +header = ['ID', 'TAG(s)', 'NAME', 'CLASS', 'MODULE'] +print '' +print tabulate(test_list, header) +print '_' * 30 print 'Filtering by:\t %s' % criteria print 'Looking for:\t %s' % ', '.join(str(x) for x in keyword) -print 'Total found:\t %s' % len(ts) +print 'Total found:\t %s\n' % len(ts) def list_tests(): @@ -329,15 +333,19 @@ def list_tests(): ts = get_all_tests() -print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % ('id', 'tag', 'name', 'class', 'module') -print '_' * 150 +test_list = [] + for t in ts: if isinstance(t.tctag, (tuple, list)): -print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t.tcid, ', '.join(t.tctag), t.tcname, t.tcclass, t.tcmodule) +test_list.append((t.tcid, ', '.join(t.tctag), t.tcname, t.tcclass, t.tcmodule)) else: -print '%-4s\t%-20s\t%-60s\t%-25s\t%-20s' % (t.tcid, t.tctag, t.tcname, t.tcclass, t.tcmodule) -print '_' * 150 -print 'Total found:\t %s' % len(ts) +test_list.append((t.tcid, t.tctag, t.tcname, t.tcclass, t.tcmodule)) + +header = ['ID', 'TAG(s)', 'NAME', 'CLASS', 'MODULE'] +print '' +print tabulate(test_list, header) +print '_' * 30 +print 'Total found:\t %s\n' % len(ts) def list_tags(): -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core
[OE-core] [PATCH 3/3] oe-selftest: Fixed --list-tests-by tag option
Commit 35be67951305950ba797dc2efddbc7d88fc0556a broke the --list-tests-by tag option. This patch fixes that. Having a module in lib/oeqa/selftest named testmodule: class TestClass(oeSelfTest): @tag(feature='tag1') def test_func1(self): pass @tag(feature=('tag1', 'tag2')) def test_func2(self): pass @tag(feature=('tag2', 'tag3')) def test_func3(self): pass @tag(feature=('tag1', 'tag2', 'tag3')) def test_func4(self): pass $ oe-selftest --list-tests-by tag tag1 ID TAG(s)NAMECLASS MODULE -- - tag1 test_func1 TestClass testmodule tag1, tag2test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule __ Filtering by:tag Looking for: tag1 Total found: 3 $ oe-selftest --list-tests-by tag tag1 tag2 ID TAG(s)NAMECLASS MODULE -- - tag1 test_func1 TestClass testmodule tag1, tag2test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule tag2, tag3test_func3 TestClass testmodule __ Filtering by:tag Looking for: tag1, tag2 Total found: 4 $ oe-selftest --list-tests-by tag tag* ID TAG(s)NAMECLASS MODULE -- - tag1 test_func1 TestClass testmodule tag1, tag2test_func2 TestClass testmodule tag1, tag2, tag3 test_func4 TestClass testmodule tag2, tag3test_func3 TestClass testmodule __ Filtering by:tag Looking for: tag* Total found: 4 Signed-off-by: Daniel Istrate --- scripts/oe-selftest | 29 +++-- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/scripts/oe-selftest b/scripts/oe-selftest index ada71d2..d06e097 100755 --- a/scripts/oe-selftest +++ b/scripts/oe-selftest @@ -33,6 +33,8 @@ import argparse import subprocess import time as t from tabulate import tabulate +import re +import fnmatch sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)) + '/lib') import scriptpath @@ -198,7 +200,7 @@ class Tc: self.tcclass = tcclass self.tcmodule = tcmodule self.tcid = tcid -# A test case can have multiple tags (as list or as tuples) otherwise str suffice +# A test case can have multiple tags (as tuples) otherwise str will suffice self.tctag = tctag self.fullpath = '.'.join(['oeqa', 'selftest', tcmodule, tcclass, tcname]) @@ -244,19 +246,17 @@ def get_all_tests(): testlist += get_tests_from_module(tmod) return testlist + def get_testsuite_by(criteria, keyword): # Get a testsuite based on 'keyword' # criteria: name, class, module, id, tag # keyword: a list of tests, classes, modules, ids, tags -import re -import fnmatch - ts = [] all_tests = get_all_tests() def get_matches(values): -# Get a items and return the ones that match with keyword(s) +# Get an items and return the ones that match with keyword(s) # values: the list of items (names, modules, classes...) result = [] remaining = values[:] @@ -268,9 +268,9 @@ def get_testsuite_by(criteria, keyword): else: # Wildcard matching pattern = re.compile(fnmatch.translate(r"%s" % key)) -added = [ x for x in remaining if pattern.match(x) ] +added = [x for x in remaining if pattern.match(x)] result.extend(added) -remaining = [ x for x in remaining if not x in added ] +remaining = [x for x in remaining if x not in added] return result @@ -293,14 +293,23 @@ def get_testsuite_by(criteria, keyword): elif criteria == 'tag': values = set() for tc in all_tests: -# tc can have multiple tags (as list or tuple) otherwise as str -if isinstance(tc.tctag, (list, tuple)): +# tc can have multiple tags (as tuple) otherwise str will suffice +if isinstance(tc.tctag, tuple): values |= { str(tag) for tag in tc.tctag } else: values.add(str(tc.tctag)) tags = get_matches(list(values)) -ts = [ tc for tc in all_tests if str(tc.tctag) in tags ] + +for tc in all_tests: +for tag in tags: +if isinstance(tc.tctag, tuple) and tag in tc.tctag: +ts.append(tc) +elif tag
[OE-core] [PATCH] selftest: Added testcase decorator to tests
1418test_recipetool_create_cmake 1422test_qemu 1423test_devtool_add_git_local 1433test_devtool_upgrade_git 1434test_sanity_unsafe_binary_references 1435test_read_only_image Signed-off-by: Daniel Istrate --- meta/lib/oeqa/selftest/buildoptions.py | 2 ++ meta/lib/oeqa/selftest/devtool.py | 2 ++ meta/lib/oeqa/selftest/recipetool.py | 1 + meta/lib/oeqa/selftest/wic.py | 1 + 4 files changed, 6 insertions(+) diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py index 2fc77e1..ff34e9a 100644 --- a/meta/lib/oeqa/selftest/buildoptions.py +++ b/meta/lib/oeqa/selftest/buildoptions.py @@ -57,6 +57,7 @@ class ImageOptionsTests(oeSelfTest): res = runCmd("grep ccache %s" % (os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")), ignore_status=True) self.assertEqual(0, res.status, msg="No match for ccache in m4 log.do_compile. For further details: %s" % os.path.join(get_bb_var("WORKDIR","m4"),"temp/log.do_compile")) +@testcase(1435) def test_read_only_image(self): self.write_config('IMAGE_FEATURES += "read-only-rootfs"') bitbake("core-image-sato") @@ -124,6 +125,7 @@ do_install_append_pn-gzip () { 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(1434) def test_sanity_unsafe_binary_references(self): self.write_config('WARN_QA_append = " unsafe-references-in-binaries"') diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py index 32025be..132a73d 100644 --- a/meta/lib/oeqa/selftest/devtool.py +++ b/meta/lib/oeqa/selftest/devtool.py @@ -201,6 +201,7 @@ class DevtoolTests(DevtoolBase): bindir = bindir[1:] self.assertTrue(os.path.isfile(os.path.join(installdir, bindir, 'pv')), 'pv binary not found in D') +@testcase(1423) def test_devtool_add_git_local(self): # Fetch source from a remote URL, but do it outside of devtool tempdir = tempfile.mkdtemp(prefix='devtoolqa') @@ -1138,6 +1139,7 @@ class DevtoolTests(DevtoolBase): self.assertNotIn(recipe, result.output) self.assertFalse(os.path.exists(os.path.join(self.workspacedir, 'recipes', recipe)), 'Recipe directory should not exist after resetting') +@testcase(1433) def test_devtool_upgrade_git(self): # Check preconditions self.assertTrue(not os.path.exists(self.workspacedir), 'This test cannot be run with a workspace directory under the build directory') diff --git a/meta/lib/oeqa/selftest/recipetool.py b/meta/lib/oeqa/selftest/recipetool.py index a04ee87..e72911b 100644 --- a/meta/lib/oeqa/selftest/recipetool.py +++ b/meta/lib/oeqa/selftest/recipetool.py @@ -424,6 +424,7 @@ class RecipetoolTests(RecipetoolBase): inherits = ['autotools'] self._test_recipe_contents(os.path.join(temprecipe, dirlist[0]), checkvars, inherits) +@testcase(1418) def test_recipetool_create_cmake(self): # Try adding a recipe temprecipe = os.path.join(self.tempdir, 'recipe') diff --git a/meta/lib/oeqa/selftest/wic.py b/meta/lib/oeqa/selftest/wic.py index 56ce8c8..a569fbf 100644 --- a/meta/lib/oeqa/selftest/wic.py +++ b/meta/lib/oeqa/selftest/wic.py @@ -266,6 +266,7 @@ class Wic(oeSelfTest): % image).status) self.assertEqual(1, len(glob(self.resultdir + "%s-*direct" % image))) +@testcase(1422) def test_qemu(self): """Test wic-image-minimal under qemu""" self.assertEqual(0, bitbake('wic-image-minimal').status) -- 2.1.0 -- ___ Openembedded-core mailing list Openembedded-core@lists.openembedded.org http://lists.openembedded.org/mailman/listinfo/openembedded-core