* [PATCH 1/7] oeqa/utils: replace some tabs with spaces
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
@ 2014-12-23 16:08 ` Paul Eggleton
2014-12-23 16:08 ` [PATCH 2/7] oeqa/utils: fix testcase decorator to allow calling tests individually Paul Eggleton
` (5 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2014-12-23 16:08 UTC (permalink / raw)
To: openembedded-core
Python code should use spaces only for indentation.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/lib/oeqa/utils/commands.py | 10 ++---
meta/lib/oeqa/utils/decorators.py | 84 +++++++++++++++++++--------------------
2 files changed, 47 insertions(+), 47 deletions(-)
diff --git a/meta/lib/oeqa/utils/commands.py b/meta/lib/oeqa/utils/commands.py
index d29c1b1..5b601d9 100644
--- a/meta/lib/oeqa/utils/commands.py
+++ b/meta/lib/oeqa/utils/commands.py
@@ -110,11 +110,11 @@ def runCmd(command, ignore_status=False, timeout=None, assert_error=True, **opti
def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **options):
if postconfig:
- postconfig_file = os.path.join(os.environ.get('BUILDDIR'), 'oeqa-post.conf')
- ftools.write_file(postconfig_file, postconfig)
- extra_args = "-R %s" % postconfig_file
+ postconfig_file = os.path.join(os.environ.get('BUILDDIR'), 'oeqa-post.conf')
+ ftools.write_file(postconfig_file, postconfig)
+ extra_args = "-R %s" % postconfig_file
else:
- extra_args = ""
+ extra_args = ""
if isinstance(command, basestring):
cmd = "bitbake " + extra_args + " " + command
@@ -122,7 +122,7 @@ def bitbake(command, ignore_status=False, timeout=None, postconfig=None, **optio
cmd = [ "bitbake" ] + [a for a in (command + extra_args.split(" ")) if a not in [""]]
try:
- return runCmd(cmd, ignore_status, timeout, **options)
+ return runCmd(cmd, ignore_status, timeout, **options)
finally:
if postconfig:
os.remove(postconfig_file)
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 7f845db..1ae1162 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -86,14 +86,14 @@ class testcase(object):
self.test_case = test_case
def __call__(self, func):
- def wrapped_f(*args):
- return func(*args)
- wrapped_f.test_case = self.test_case
- return wrapped_f
+ def wrapped_f(*args):
+ return func(*args)
+ wrapped_f.test_case = self.test_case
+ return wrapped_f
class NoParsingFilter(logging.Filter):
def filter(self, record):
- return record.levelno == 100
+ return record.levelno == 100
def LogResults(original_class):
orig_method = original_class.run
@@ -101,51 +101,51 @@ def LogResults(original_class):
#rewrite the run method of unittest.TestCase to add testcase logging
def run(self, result, *args, **kws):
orig_method(self, result, *args, **kws)
- passed = True
- testMethod = getattr(self, self._testMethodName)
-
- #if test case is decorated then use it's number, else use it's name
- try:
- test_case = testMethod.test_case
- except AttributeError:
- test_case = self._testMethodName
-
- #create custom logging level for filtering.
- custom_log_level = 100
- logging.addLevelName(custom_log_level, 'RESULTS')
- caller = os.path.basename(sys.argv[0])
-
- def results(self, message, *args, **kws):
- if self.isEnabledFor(custom_log_level):
- self.log(custom_log_level, message, *args, **kws)
- logging.Logger.results = results
-
- logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'),
+ passed = True
+ testMethod = getattr(self, self._testMethodName)
+
+ #if test case is decorated then use it's number, else use it's name
+ try:
+ test_case = testMethod.test_case
+ except AttributeError:
+ test_case = self._testMethodName
+
+ #create custom logging level for filtering.
+ custom_log_level = 100
+ logging.addLevelName(custom_log_level, 'RESULTS')
+ caller = os.path.basename(sys.argv[0])
+
+ def results(self, message, *args, **kws):
+ if self.isEnabledFor(custom_log_level):
+ self.log(custom_log_level, message, *args, **kws)
+ logging.Logger.results = results
+
+ logging.basicConfig(filename=os.path.join(os.getcwd(),'results-'+caller+'.log'),
filemode='w',
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%H:%M:%S',
level=custom_log_level)
- for handler in logging.root.handlers:
- handler.addFilter(NoParsingFilter())
- local_log = logging.getLogger(caller)
+ for handler in logging.root.handlers:
+ handler.addFilter(NoParsingFilter())
+ local_log = logging.getLogger(caller)
- #check status of tests and record it
+ #check status of tests and record it
for (name, msg) in result.errors:
- if self._testMethodName == str(name).split(' ')[0]:
- local_log.results("Testcase "+str(test_case)+": ERROR")
- local_log.results("Testcase "+str(test_case)+":\n"+msg)
- passed = False
+ if self._testMethodName == str(name).split(' ')[0]:
+ local_log.results("Testcase "+str(test_case)+": ERROR")
+ local_log.results("Testcase "+str(test_case)+":\n"+msg)
+ passed = False
for (name, msg) in result.failures:
- if self._testMethodName == str(name).split(' ')[0]:
- local_log.results("Testcase "+str(test_case)+": FAILED")
- local_log.results("Testcase "+str(test_case)+":\n"+msg)
- passed = False
+ if self._testMethodName == str(name).split(' ')[0]:
+ local_log.results("Testcase "+str(test_case)+": FAILED")
+ local_log.results("Testcase "+str(test_case)+":\n"+msg)
+ passed = False
for (name, msg) in result.skipped:
- if self._testMethodName == str(name).split(' ')[0]:
- local_log.results("Testcase "+str(test_case)+": SKIPPED")
- passed = False
- if passed:
- local_log.results("Testcase "+str(test_case)+": PASSED")
+ if self._testMethodName == str(name).split(' ')[0]:
+ local_log.results("Testcase "+str(test_case)+": SKIPPED")
+ passed = False
+ if passed:
+ local_log.results("Testcase "+str(test_case)+": PASSED")
original_class.run = run
return original_class
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 2/7] oeqa/utils: fix testcase decorator to allow calling tests individually
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
2014-12-23 16:08 ` [PATCH 1/7] oeqa/utils: replace some tabs with spaces Paul Eggleton
@ 2014-12-23 16:08 ` Paul Eggleton
2014-12-23 16:08 ` [PATCH 3/7] oeqa/selftest: fix test_event_handler for changes in bitbake output Paul Eggleton
` (4 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2014-12-23 16:08 UTC (permalink / raw)
To: openembedded-core
Without this, running tests individually failed with a traceback:
$ oe-selftest --run-test
buildoptions.ImageOptionsTests.test_incremental_image_generation
2014-12-23 14:40:37,636 - selftest - INFO - Checking that everything is in order before running the tests
2014-12-23 14:40:38,408 - selftest - INFO - Running bitbake -p
2014-12-23 14:40:40,235 - selftest - INFO - Loading tests from:
oeqa.selftest.buildoptions.ImageOptionsTests.test_incremental_image_generation
Traceback (most recent call last):
File "/home/user/poky/scripts/oe-selftest", line 179, in <module>
ret = main()
File "/home/user/poky/scripts/oe-selftest", line 164, in main
suite.addTests(loader.loadTestsFromName(test))
File "/usr/lib64/python2.7/unittest/loader.py", line 91, in loadTestsFromName
module = __import__('.'.join(parts_copy))
File "/home/user/poky/meta/lib/oeqa/selftest/buildoptions.py", line 12, in <module>
class ImageOptionsTests(oeSelfTest):
File "/home/user/poky/meta/lib/oeqa/selftest/buildoptions.py", line 14, in ImageOptionsTests
@testcase(761)
NameError: global name 'func' is not defined
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/lib/oeqa/utils/decorators.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/meta/lib/oeqa/utils/decorators.py b/meta/lib/oeqa/utils/decorators.py
index 1ae1162..2d5db24 100644
--- a/meta/lib/oeqa/utils/decorators.py
+++ b/meta/lib/oeqa/utils/decorators.py
@@ -89,6 +89,7 @@ class testcase(object):
def wrapped_f(*args):
return func(*args)
wrapped_f.test_case = self.test_case
+ wrapped_f.__name__ = func.__name__
return wrapped_f
class NoParsingFilter(logging.Filter):
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 3/7] oeqa/selftest: fix test_event_handler for changes in bitbake output
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
2014-12-23 16:08 ` [PATCH 1/7] oeqa/utils: replace some tabs with spaces Paul Eggleton
2014-12-23 16:08 ` [PATCH 2/7] oeqa/utils: fix testcase decorator to allow calling tests individually Paul Eggleton
@ 2014-12-23 16:08 ` Paul Eggleton
2014-12-23 16:08 ` [PATCH 4/7] oeqa/selftest: skip test_incremental_image_generation if not using rpm Paul Eggleton
` (3 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2014-12-23 16:08 UTC (permalink / raw)
To: openembedded-core
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/lib/oeqa/selftest/bbtests.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py
index 68f97bd..2a85f10 100644
--- a/meta/lib/oeqa/selftest/bbtests.py
+++ b/meta/lib/oeqa/selftest/bbtests.py
@@ -27,7 +27,7 @@ class BitbakeTests(oeSelfTest):
def test_event_handler(self):
self.write_config("INHERIT += \"test_events\"")
result = bitbake('m4-native')
- find_build_started = re.search("NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Preparing runqueue", result.output)
+ find_build_started = re.search("NOTE: Test for bb\.event\.BuildStarted(\n.*)*NOTE: Preparing RunQueue", result.output)
find_build_completed = re.search("Tasks Summary:.*(\n.*)*NOTE: Test for bb\.event\.BuildCompleted", result.output)
self.assertTrue(find_build_started, msg = "Match failed in:\n%s" % result.output)
self.assertTrue(find_build_completed, msg = "Match failed in:\n%s" % result.output)
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 4/7] oeqa/selftest: skip test_incremental_image_generation if not using rpm
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
` (2 preceding siblings ...)
2014-12-23 16:08 ` [PATCH 3/7] oeqa/selftest: fix test_event_handler for changes in bitbake output Paul Eggleton
@ 2014-12-23 16:08 ` Paul Eggleton
2014-12-23 16:08 ` [PATCH 5/7] oeqa/selftest: improve failure messages for devtool tests Paul Eggleton
` (2 subsequent siblings)
6 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2014-12-23 16:08 UTC (permalink / raw)
To: openembedded-core
We have just implemented incremental ipk image generation, but at the
moment this test doesn't support that, so skip it if not using rpm.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/lib/oeqa/selftest/buildoptions.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/meta/lib/oeqa/selftest/buildoptions.py b/meta/lib/oeqa/selftest/buildoptions.py
index a250cae..381741e 100644
--- a/meta/lib/oeqa/selftest/buildoptions.py
+++ b/meta/lib/oeqa/selftest/buildoptions.py
@@ -13,6 +13,9 @@ class ImageOptionsTests(oeSelfTest):
@testcase(761)
def test_incremental_image_generation(self):
+ image_pkgtype = get_bb_var("IMAGE_PKGTYPE")
+ if image_pkgtype != 'rpm':
+ self.skipTest('Not using RPM as main package format')
bitbake("-c cleanall core-image-minimal")
self.write_config('INC_RPM_IMAGE_GEN = "1"')
self.append_config('IMAGE_FEATURES += "ssh-server-openssh"')
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 5/7] oeqa/selftest: improve failure messages for devtool tests
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
` (3 preceding siblings ...)
2014-12-23 16:08 ` [PATCH 4/7] oeqa/selftest: skip test_incremental_image_generation if not using rpm Paul Eggleton
@ 2014-12-23 16:08 ` Paul Eggleton
2014-12-23 16:08 ` [PATCH 6/7] oeqa/selftest: populate pkgdata/shlibs in test_recipetool_create_git Paul Eggleton
2014-12-23 16:08 ` [PATCH 7/7] oeqa/selftest: fix test_force_task so it doesn't taint the entire build Paul Eggleton
6 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2014-12-23 16:08 UTC (permalink / raw)
To: openembedded-core
assertTrue prints "False is not True" if it fails, which is pretty much
useless. Use a more appropriate assertion test where practical and add a
message where it isn't.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/lib/oeqa/selftest/devtool.py | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index e8ff536..e158ad9 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -25,15 +25,15 @@ class DevtoolTests(oeSelfTest):
result = runCmd('devtool create-workspace %s' % tempdir)
self.assertTrue(os.path.isfile(os.path.join(tempdir, 'conf', 'layer.conf')))
result = runCmd('bitbake-layers show-layers')
- self.assertTrue(tempdir in result.output)
+ self.assertIn(tempdir, result.output)
# Try creating a workspace layer with the default path
self.track_for_cleanup(workspacedir)
self.add_command_to_tearDown('bitbake-layers remove-layer */workspace')
result = runCmd('devtool create-workspace')
self.assertTrue(os.path.isfile(os.path.join(workspacedir, 'conf', 'layer.conf')))
result = runCmd('bitbake-layers show-layers')
- self.assertTrue(tempdir not in result.output)
- self.assertTrue(workspacedir in result.output)
+ self.assertNotIn(tempdir, result.output)
+ self.assertIn(workspacedir, result.output)
def test_recipetool_create(self):
# Try adding a recipe
@@ -74,7 +74,7 @@ class DevtoolTests(oeSelfTest):
recipefile = os.path.join(tempdir, 'libmatchbox.bb')
srcuri = 'git://git.yoctoproject.org/libmatchbox'
result = runCmd('recipetool create -o %s %s -x %s' % (recipefile, srcuri, tempsrc))
- self.assertTrue(os.path.isfile(recipefile))
+ self.assertTrue(os.path.isfile(recipefile), 'recipetool did not create recipe file; output:\n%s' % result.output)
checkvars = {}
checkvars['LICENSE'] = 'LGPLv2.1'
checkvars['LIC_FILES_CHKSUM'] = 'file://COPYING;md5=7fbc338309ac38fefcd64b04bb903e34'
@@ -111,7 +111,7 @@ class DevtoolTests(oeSelfTest):
result = runCmd('wget %s' % url, cwd=tempdir)
result = runCmd('tar xfv pv-1.5.3.tar.bz2', cwd=tempdir)
srcdir = os.path.join(tempdir, 'pv-1.5.3')
- self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')))
+ self.assertTrue(os.path.isfile(os.path.join(srcdir, 'configure')), 'Unable to find configure script in source directory')
# Test devtool add
self.track_for_cleanup(workspacedir)
self.add_command_to_tearDown('bitbake -c cleansstate pv')
@@ -127,9 +127,9 @@ class DevtoolTests(oeSelfTest):
# Test devtool build
result = runCmd('devtool build pv')
installdir = get_bb_var('D', 'pv')
- self.assertTrue(installdir)
+ self.assertTrue(installdir, 'Could not query installdir variable')
bindir = get_bb_var('bindir', 'pv')
- self.assertTrue(bindir)
+ self.assertTrue(bindir, 'Could not query bindir variable')
if bindir[0] == '/':
bindir = bindir[1:]
self.assertTrue(os.path.isfile(os.path.join(installdir, bindir, 'pv')), 'pv binary not found in D')
@@ -167,9 +167,9 @@ class DevtoolTests(oeSelfTest):
result = runCmd("sed -i 's!^\.TH.*!.TH MDADM 8 \"\" v9.999-custom!' %s" % os.path.join(tempdir, 'mdadm.8.in'))
bitbake('mdadm -c package')
pkgd = get_bb_var('PKGD', 'mdadm')
- self.assertTrue(pkgd)
+ self.assertTrue(pkgd, 'Could not query PKGD variable')
mandir = get_bb_var('mandir', 'mdadm')
- self.assertTrue(mandir)
+ self.assertTrue(mandir, 'Could not query mandir variable')
if mandir[0] == '/':
mandir = mandir[1:]
with open(os.path.join(pkgd, mandir, 'man8', 'mdadm.8'), 'r') as f:
@@ -223,7 +223,7 @@ class DevtoolTests(oeSelfTest):
elif re.search('minicom_[^_]*.bb$', line):
self.assertEqual(line[:3], ' M ', 'Unexpected status in line: %s' % line)
else:
- self.assertTrue(False, 'Unexpected modified file in status: %s' % line)
+ raise AssertionError('Unexpected modified file in status: %s' % line)
def test_devtool_extract(self):
# Check preconditions
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 6/7] oeqa/selftest: populate pkgdata/shlibs in test_recipetool_create_git
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
` (4 preceding siblings ...)
2014-12-23 16:08 ` [PATCH 5/7] oeqa/selftest: improve failure messages for devtool tests Paul Eggleton
@ 2014-12-23 16:08 ` Paul Eggleton
2014-12-23 16:08 ` [PATCH 7/7] oeqa/selftest: fix test_force_task so it doesn't taint the entire build Paul Eggleton
6 siblings, 0 replies; 9+ messages in thread
From: Paul Eggleton @ 2014-12-23 16:08 UTC (permalink / raw)
To: openembedded-core
Build some recipes so that we have the needed data in the sysroot for
recipetool to refer to when scanning for dependencies.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/lib/oeqa/selftest/devtool.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/meta/lib/oeqa/selftest/devtool.py b/meta/lib/oeqa/selftest/devtool.py
index e158ad9..74fb325 100644
--- a/meta/lib/oeqa/selftest/devtool.py
+++ b/meta/lib/oeqa/selftest/devtool.py
@@ -66,6 +66,8 @@ class DevtoolTests(oeSelfTest):
self.assertEqual(checkvars, {}, 'Some variables not found')
def test_recipetool_create_git(self):
+ # Ensure we have the right data in shlibs/pkgdata
+ bitbake('libpng pango libx11 libxext')
# Try adding a recipe
tempdir = tempfile.mkdtemp(prefix='devtoolqa')
self.track_for_cleanup(tempdir)
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread* [PATCH 7/7] oeqa/selftest: fix test_force_task so it doesn't taint the entire build
2014-12-23 16:08 [PATCH 0/7] oe-selftest QA test fixes Paul Eggleton
` (5 preceding siblings ...)
2014-12-23 16:08 ` [PATCH 6/7] oeqa/selftest: populate pkgdata/shlibs in test_recipetool_create_git Paul Eggleton
@ 2014-12-23 16:08 ` Paul Eggleton
2014-12-23 16:20 ` Paul Eggleton
6 siblings, 1 reply; 9+ messages in thread
From: Paul Eggleton @ 2014-12-23 16:08 UTC (permalink / raw)
To: openembedded-core
Using -f sets a taint on the specified task, and m4-native is in the
dependency chain for just about everything, which means that everything
gets forced to rebuild. We don't need the influence of this test to
extend outside of the test itself, so ensure that the taint gets cleared
at the end of the test.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
---
meta/lib/oeqa/selftest/bbtests.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/meta/lib/oeqa/selftest/bbtests.py b/meta/lib/oeqa/selftest/bbtests.py
index 2a85f10..5708d3d 100644
--- a/meta/lib/oeqa/selftest/bbtests.py
+++ b/meta/lib/oeqa/selftest/bbtests.py
@@ -71,6 +71,7 @@ class BitbakeTests(oeSelfTest):
@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']
for task in look_for_tasks:
--
1.9.3
^ permalink raw reply related [flat|nested] 9+ messages in thread