poky/scripts/lib/compatlayer/cases/common.py
Patrick Ohly efd3b0ee30 yocto-compat-layer: fix also other command invocations
In commit 5b9ac62ab535d, one place was fixed where a command was
invoked such that failures caused double stack traces and stderr was
lost. The same problem also occurs elsewhere, triggered for example by
a layer with parsing problems.

Now a new utility method is used instead of repeating the code.

(From OE-Core rev: b6c72c0d169473e2626938be2ee59f850624612e)

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2017-04-10 23:00:42 +01:00

52 lines
1.8 KiB
Python

# Copyright (C) 2017 Intel Corporation
# Released under the MIT license (see COPYING.MIT)
import os
import unittest
from compatlayer import get_signatures, LayerType, check_command
from compatlayer.case import OECompatLayerTestCase
class CommonCompatLayer(OECompatLayerTestCase):
def test_readme(self):
readme_file = os.path.join(self.tc.layer['path'], 'README')
self.assertTrue(os.path.isfile(readme_file),
msg="Layer doesn't contains README file.")
data = ''
with open(readme_file, 'r') as f:
data = f.read()
self.assertTrue(data,
msg="Layer contains README file but is empty.")
def test_parse(self):
check_command('Layer %s failed to parse.' % self.tc.layer['name'],
'bitbake -p')
def test_show_environment(self):
check_command('Layer %s failed to show environment.' % self.tc.layer['name'],
'bitbake -e')
def test_signatures(self):
if self.tc.layer['type'] == LayerType.SOFTWARE:
raise unittest.SkipTest("Layer %s isn't BSP or DISTRO one." \
% self.tc.layer['name'])
sig_diff = {}
curr_sigs = get_signatures(self.td['builddir'], failsafe=True)
for task in self.td['sigs']:
if task not in curr_sigs:
continue
if self.td['sigs'][task] != curr_sigs[task]:
sig_diff[task] = '%s -> %s' % \
(self.td['sigs'][task], curr_sigs[task])
detail = ''
if sig_diff:
for task in sig_diff:
detail += "%s changed %s\n" % (task, sig_diff[task])
self.assertFalse(bool(sig_diff), "Layer %s changed signatures.\n%s" % \
(self.tc.layer['name'], detail))